Singleton object will create instances per jvm basis. How it works in clustering environment?
What are the alternatives?
Singleton object will create instances per jvm basis. How it works in clustering environment?
What are the alternatives?
Technically, you can use Terracotta to cluster the JVM. I think it will guarantee the singleton instance.
But I think it's not what you want. Singletons are just "global state". So you don't need the same instance as long as the state (field values) in it is the same. I don't know how you cluster your application, but I guess you can have cluster-wide data.
One alternative is to not create a Singleton:
http://code.google.com/p/google-singleton-detector/
Google thinks they're a bad idea.
Clustered caching sounds like what you want. Maybe a Terracotta or a Coherence is a better idea.