How are singleton classes managed in a clustered environment
posted 11 years ago
With the typical singleton implementations - a static variable holding a reference to The Only Instance - you'd get at least one per JVM, maybe more if the class with the static variable got loaded by multiple ClassLoaders. Usually that's ok. Most of my singletons are read-only caches intended to reduce the number of trips to the database or some remote source and one query per JVM is still much better than one per web page request.
But singleton is a pattern, not an implementation, and it might be life and death critical to you to make one instance per cluster with some kind of inter-server communication. That is pretty difficult, especially if you want any kind of failover, but I've definitely seen it done. [ October 15, 2004: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi