Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glassfish thread pool issues

We're using Glassfish 3.0.1 and experiencing very long response times; in the order of 5 minutes for 25% of our POST/PUT requests, by the time the response comes back the front facing load balancer has timed out.

My theory is that the requests are queuing up and waiting for an available thread.

The reason I think this is because the access logs reveal that the requests are taking a few seconds to complete however the time at which the requests are being executed are five minutes later than I'd expect.

Does anyone have any advice for debugging what is going on with the thread pools? or what the optimum settings should be for them?

Is it required to do a thread dump periodically or will a one off dump be sufficient?

like image 507
Louis Q Avatar asked Dec 05 '12 09:12

Louis Q


People also ask

What is an ideal ThreadPool size?

So the ideal thread pool size is 4 cores * 2 * ( 1 + 9 ) = 80. If all 100ms are calculation, 0ms is waiting. the blocking coefficent is 0. The ideal thread pool size is 4 * 2 * 1 = 8.

Should we use thread pools and why?

A thread pool helps mitigate the issue of performance by reducing the number of threads needed and managing their lifecycle. Essentially, threads are kept in the thread pool until they're needed, after which they execute the task and return the pool to be reused later.

How many maximum threads can be created using a ThreadPool?

ThreadPool can automatically increase or reduce the number of active threads to maximize task execution efficiency. The maximum allowed number of processing threads in a pool is 1023. The pool allocates a maximum of 1000 threads in an I/O operation.

What happens when thread pool is full in Java?

You'll most likely just get worse performance. Keep in mind with Task and ThreadPool. QueueUserWorkItem , the threads are re-used when they're done. If you create a task or queue a threadpool thread, it may or may not create a new thread to execute your code.


1 Answers

At first glance, this seems to have very little to do with the threadpools themselves. Without knowing much about the rest of your network setup, here are some things I would check:

  • Is there a dead/nonresponsive node in the load balancer pool? This can cause all requests to be tried against this node until they fail due to timeout before being redirected to the other node.
  • Is there some issue with initial connections between the load balancer and the Glassfish server? This can be slow or incorrect DNS lookups (though the server should cache results), a missing proxy, or some other network-related problem.
  • Have you checked that the clocks are synchronized between the machines? This could cause the logs to get out of sync. 5min is a pretty strange timeout period.

If all these come up empty, you may simply have an impedance mismatch between the load balancer and the web server and you may need to add webservers to handle the load. The load balancer should be able to give you plenty of stats on the traffic coming in and how it's stacking up.

like image 176
saarp Avatar answered Oct 16 '22 03:10

saarp