1

We're running a game application .WAR on Tomcat 6 on an Amazon EC2 server, 8 core processor, 7gb RAM. The application uses a MySQL database hosted on Amazon RDS.

This Facebook application takes ages to access when a mere 20-30 users are playing it. Big difference from 1-2 users. The entire .WAR is ~4mb, all static content hosted elsewhere.

The server has never been close to running out of RAM. The CPU utilization has never been higher than 13.5-14%. Even with ~500 users that completely slowed everything to a standstill. The thread count or threadpools isn't close to being maxed out. I heightened maxthreads but it didn't make a noticeable difference.

My theory is that Tomcat can only use one processor core, which would explain why it was slowed to a halt even though CPU usage was stably at 13-14% at the activity spike.
But I'm struggling to understand why it would only use one CPU core. There is no processor cap in server.xml. The app contains several servlets (4 or 5). There is no mention of SingleThreadModel in the Java code.

WHAT could be causing the application to run extremely slowly? If there is only 1-5 people on the application it runs fine. With 20-30 people it's barely contactable.

5
  • How big is the heap?
    – mahnsc
    Nov 20, 2011 at 4:24
  • I've tried increasing the heap, it's at 4500mb now. 7gb RAM. Made no difference Nov 22, 2011 at 1:36
  • I ran a profiler, and it seems like 99% of the waiting time seems to be database calls. The database has never had a write/read throughput of more than 5kb/s but it only has a few connections on average, never had more than 10 or so. This seems to be the bottleneck, number of connections between the app and the db. Nov 22, 2011 at 1:41
  • Both the server and database is both hosted by Amazon in the same data center, so bandwidth/network latency shouldn't be an issue. Looking at the profiler results: PoolingDataSource.getConnection() - 0ms players - SELECT - 3ms Uninstrumented time - 10sec+ PoolingDataSource.getConnection() - 0ms friends - SELECT - 1ms Nov 22, 2011 at 1:44
  • The app uses dbcp-commons 1.4. This very application works for my friend, he has a localhost database though. But what could hinder the application from starting more connections? It seems to have too few, and the ones it has takes ages to complete, but looking at the databases stats it has never taken more than 20ms to complete an operation. Nov 22, 2011 at 1:46

1 Answer 1

0

This may be a flaw in application design. We also have one application that exerts same behavior. A significant portion of its code is synchronized, so no matter how many CPUs we give to it - it effectively runs in a single thread. You can do pretty much nothing in this situation other then running multiple instances of the same application and balance load between them.

1
  • 1
    This very application can handle hundreds of concurrent users on another server, so the fact that my server can't handle even 5-10 can't come down to lack of multithreading, because even 1 cpu should be able to easily handle 5 users. Nov 22, 2011 at 1:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .