views:

22

answers:

2

Here's the scenario:

Many users access an application (running on tomcat), the user's data is segmented into multiple databases, say each db containing 1000 user's data.

Now is it somehow possible to have 100s of tomcat servers running on 'inexpensive' PC class machines with each connecting to a single db, with user's session getting passed to appropriate tomcat and becoming 'Sticky' there. Can have some sort of 'gateway' deciding which user goes where and doing the load-balancing appropriately.

Would make a great scalability solution :)

A: 

Yes, it is possible to do so.

You have to set Apache HTTP server + mod_jk in front of tomcat server pool.

Then you can configure the load balancing strategy and enjoy your 100 tomcats serving user requests.

Juriy
@Juriy: Can you plz elaborate? The way I've seen is apache would send the user request to 'Any' tomcat, here I'd need an informed decision to send user to correct Tomcat because only 1 Tomcat server (out of those 100) would be having 'this' user's data.
Gala101
There will be a problem with the strategy of "sticky sessions": since in case one Tomcat goes down, user will be "dropped" from session. The better way is to set up session replication (sharing of session data between nodes)
Juriy
+1  A: 

The way Juriy has already started on was mod_jk, can be found at the JK Mod site(can't link due to not enough rep yet), which talks about load balancing.

Now, if you need Apache to send the user to a specific machine based on the user, then you just need to make sure that session-cookie(issued they first get there) doesn't expire. Of course, what happens if they clear their session cookie?

From the sounds of it, you want to do something similar to database sharding. Is that more or less correct?

ClutchDude
I think Database sharding along with dedicated tomcat instance(s) per shard.. Only tricky part would be to make user's session stick to correct tomcat+shard combo.
Gala101