Measuring the number of queued requests for tomcat

前端 未结 2 895
一整个雨季
一整个雨季 2021-02-13 12:29

So with tomcat you can set the acceptCount value (default is 100) which means when all the worker threads are busy - new connections are placed in a queue (until it is full, aft

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 12:41

    The accept queue cannot be monitored, but you can get the number of queued requests for tomcat using Executor.

    
    
    

    The configuration maxThreads="20" means the threadpool has 20 workers at most, can process 20 requests simultaneously.

    maxQueueSize="30" means that the threadpool can queued at most 30 unprocessed requests. Thus, you can monitor the queueSize attribute via JMX to get the number of queued requests.

    But by default, the threadpool queue will never hold any requests because the default value of maxConnections is the value of maxThreads, which means when all workers are busy, new requests are queued in the accept queue.

    By setting maxConnections="50", tomcat can accept more requests than maxThreads(20). In the example above, the Executor threadpool can handle 20 requests, the extra 30 requests will hold in the threadpool queue, any more requests further will be queue in the accept queue.

    So now you can monitor the number of requests queued in threadpool using MBean 'Catalina:type=Executor,name=tomcatThreadPool' and attribute name 'queueSize'

提交回复
热议问题