Note that there are some explanatory texts on larger screens.

plurals
  1. POHorizontal sharding, Java EE & JNDI
    text
    copied!<p>In a few months I'm going to have to horizontally partition my application. There are certain services within my application which need loads of CPU and memory, and for scaleability I'm going to want to shard it across multiple JVMs. </p> <p>I have an EAR that encapsulates the services that I need to partition. When I do this clients of the services (such as the UI) will need to be able to address a particular instance of the service. For example, lets say I have a service named Account, but I actually have 3 instances of that service running in three different JVMs (but all in the same Java EE domain). Assuming I have a Service Locator that can map from an account ID to a particular VM, how would I access the EJBs that can service that particular account?</p> <p>A potential solution I can see is to take advantage of the JNDI name that the application container gives to the EJBs in separate applications. If I deploy the module three different times with different names, I can do JNDI lookups to get to them:</p> <p>java:global/AccountServer1/AccountFacade</p> <p>java:global/AccountServer2/AccountFacade</p> <p>java:global/AccountServer3/AccountFacade</p> <p>In order for this to work, I could never use dependency injection to get to an AccountFacade, I would have to use AccountLocator EJB capable of taking an AccountID and mapping it to one of the Account applications. If I wanted to get tricky, I could probably implement a "Local" account facade that did the lookup transparently assuming that the arguments to the methods could identify which server to use...</p> <p>Is this approach workable? Are there better alternatives?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload