• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat Thread Pool configured as 3,000

 
Tahseen Jamal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a high end server with 32 GB RAM and only Tomcat running on it. CPU usage is very low.

Initially threadpool size was 500. Recently I made it 1,000 because tomcat was crashing with 500 as threadpool. Now it is perfectly fine.

But as the traffic increases am thinking of increasing this threadpool value more.

Question is can I increase the value to something like 3,000 or 4,000? I mean I have a high end Quard Core Server with very less CPU usage and high RAM.

How would I know when my threadpool limit has come and increasing it further would not help?


Tahseen
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The number of threads you can spin off depends on the OS's address space limit for a given process, how much heap space you've reserved when starting the java process and the specified stack size per thread.
Roughly, you could say if you're max address space is 2 GB, and you've reserved a max 1 GB heap, you can start about 2000 threads with a default 512 KB stacksize.
How usefull that is, depends on your application and how it makes use of threads. There's really only one way to find out and that is to play around with the settings and profile your application.
 
Tahseen Jamal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What do you mean by Max Address Space? RAM?

We have 32 GB RAM and can easily allocate 4GB RAM to heap. Which means I can easily do 4,000 threads?

And how would stack size impact?


Jelle Klap wrote:The number of threads you can spin off depends on the OS's address space limit for a given process, how much heap space you've reserved when starting the java process and the specified stack size per thread.
Roughly, you could say if you're max address space is 2 GB, and you've reserved a max 1 GB heap, you can start about 2000 threads with a default 512 KB stacksize.
How usefull that is, depends on your application and how it makes use of threads. There's really only one way to find out and that is to play around with the settings and profile your application.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The maximum available address space is determined by the operating system, and possibly it's configuration. It's kind of a hard limit on the amount of RAM made available to any process, Java or otherwise. Going with the figures you specified, if you start the java process, specify a maximum heapspace of 4 GB and start 4000 threads at 512 KB per stack, the address space provided to the java process would have to be around 6 GB. If the OS can provide a process with that much address space, everything will be fine. If not, the JVM will throw an OutOfMemoryError when too many threads are started and it has no more available address space to assign a new stack. Note that a thread's stack size is not deducted from the heap space allocated to the JVM!
 
Tahseen Jamal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The machine is running Tomcat with the Application war file.

It is a high end quad core machine with 32GB RAM. CPU Utilization is very low.

Heap is 4GB, threadpool is 1,000 with default stacksize

Can I make threadpool 2,000? Shouldn't be a problem isn't it?


Jelle Klap wrote:The maximum available address space is determined by the operating system, and possibly it's configuration. It's kind of a hard limit on the amount of RAM made available to any process, Java or otherwise. Going with the figures you specified, if you start the java process, specify a maximum heapspace of 4 GB and start 4000 threads at 512 KB per stack, the address space provided to the java process would have to be around 6 GB. If the OS can provide a process with that much address space, everything will be fine. If not, the JVM will throw an OutOfMemoryError when too many threads are started and it has no more available address space to assign a new stack. Note that a thread's stack size is not deducted from the heap space allocated to the JVM!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic