Single instance(singleton) of a class in a java application deployed in many nodes
<p>In an technical discussion, I had this question of how to maintain a Single instance across nodes,
then I answered the below approaches</p>

<p>1) DB based solution</p>

<p>2) Distributed Cache</p>

<p>3) Sharding</p>

<p>4)Maintain the Singleton single Instance in load balancer</p>

<p>Interviewer was expecting something more, since he replied 
DB based and Cache will work and sharding will not work and no comments on load balancer approach, then further he added that let us assume that DB and Cache approach are not allowed in your application, give me another option
I was stuck at this point.</p>

<p>Then I googled and found the following </p>

<p><a href="https://stackoverflow.com/questions/12032895/how-to-create-singleton-java-class-for-multiple-jvm-support">How to create singleton java class for multiple jvm support?</a></p>

<p><a href="https://stackoverflow.com/questions/1194129/singleton-in-cluster-environment">Singleton in Cluster environment</a></p>

<p><a href="https://javaarchitectforum.com/2013/02/19/singleton-design-pattern-with-example/" rel="nofollow noreferrer">https://javaarchitectforum.com/2013/02/19/singleton-design-pattern-with-example/</a></p>

<p>Also found some support from the application servers</p>

<p><a href="http://www.onjava.com/pub/a/onjava/2003/08/20/jboss_clustering.html" rel="nofollow noreferrer">http://www.onjava.com/pub/a/onjava/2003/08/20/jboss_clustering.html</a></p>

<p><a href="http://docs.oracle.com/cd/E12840_01/wls/docs103/cluster/service_migration.html#wp1051458" rel="nofollow noreferrer">http://docs.oracle.com/cd/E12840_01/wls/docs103/cluster/service_migration.html#wp1051458</a></p>

<p><a href="http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGPlatformProgGuide/html/s1005runningthesameschedulableservice01.html" rel="nofollow noreferrer">http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGPlatformProgGuide/html/s1005runningthesameschedulableservice01.html</a></p>

<p>Kindly help me with your thoughts which would be the best approach to implement single instance(singleton) across nodes</p>