I want to config tomcat server with mysql 5.1 community edition (on win server 2008 x64) to run a big project on a single machine. I’ve a gwt application and I need to run more than 300 instances of it on a single HP server.
Each instance uses a separate MySQL DB (db1 to db300) & so need a separate connection pool, this is part of my connection pool configuration for db1 (similar to other dbs):
<Resource name="jdbc/mysql/db1" auth="Container" type="javax.sql.DataSource" initialSize="5" maxActive="100" maxIdle="20" maxWait="30000" removeAbandoned="true" removeAbandonedTimeout="5" validationQuery="select now();" .../>
For 300 instances the number of active connection would be 300*100 = 30000 active connections!
Now I want to know if it is possible to open such a huge number of connections to 300 MySQL databases on a single server.
If no, so what’s the solution and if yes then how much resources (RAM and CPU) will be used?
Is connection pooling the best way or is there another way?
If connection pooling is the best choice then what could be the best setting for my resource section to create my pools?
The number of active connections would only be 30000 if every single one of the 300 instances needed to use 100 at a time. If they’re idle they’d only be using somewhere between 1500 (from initialSize) and 6000 (from maxIdle) based on your configuration. You’ll probably want to lower these values to handle 300 instances. Perhaps
initialSize="2" maxActive="10" maxIdle="5"is sufficient?If you really expect all instances to be using that many connections then one server is probably not enough. It’s nearly impossible to say how much RAM or CPU you’ll need though, it really depends on what you’re doing and how much activity you expect.