开发者

Singleton design pattern in a Cluster environment [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed开发者_如何转开发 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜