JBoss调优(四)web服务器线程池调优

本文详细探讨了如何调整Web服务器的线程池配置,以更好地匹配实际的网络请求负载,从而显著提高应用服务器的整体性能。通过合理设置线程数量和其他参数,可以有效避免资源瓶颈并充分利用服务器硬件能力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文:

http://www.mastertheboss.com/jboss-server/jboss-performance/jboss-as-7-performance-tuning?showall=&start=3


Tuning Web server thread pool

 

There are a large set of tuning aspects which ultimately influence the performance of the web server. One of the most important factors is tuning the HTTP Connector thread pool settings to more closely match the web request load you have. This is difficult to do, but is very important to get right for best performance.
The amount of threads which are allowed by the web server are referenced through the executor attribute:

?
1
2
3
4
5
6
7
8
9
10
11
12
< subsystem xmlns = "urn:jboss:domain:web:1.0" >
 
  < connector enable-lookups = "false" enabled = "true"        
  executor = "http-executor"
  max-connections = "200"
  max-post-size = "2048" max-save-post-size = "4096"
  name = "http" protocol = "HTTP/1.1"
  proxy-name = "proxy" proxy-port = "8081"
  redirect-port = "8443" scheme = "http"
  secure = "false" socket-binding = "http" />
. . .
</ subsystem >

Then, within the threads subsystem, you can define the number of threads which will be used by the pool, along with the other thread attributes (see Chapter 2, Configuring the Application Server, for more details about the thread subsystem):
?
1
2
3
4
5
6
7
8
9
< subsystem xmlns = "urn:jboss:domain:threads:1.0" >
     < bounded-queue-thread-pool name = "http-executor"
         blocking = "true" >
         < core-threads count = "10" per-cpu = "20" />
         < queue-length count = "10" per-cpu = "20" />
         < max-threads count = "10" per-cpu = "20" />
         < keepalive-time time = "10" unit = "seconds" />
     </ bounded-queue-thread-pool >
</ subsystem >

The most important Connector attributes are defined into the core-threads and max-threads. Setting these values too low means that you may not have enough threads to handle all of the requests, in which case, requests have to sit idle for some time without being handled until another request thread is freed up. Too low of a value also means that JBoss Web server will be unable to take advantage of your server machine's hardware.


On the other hand, be careful before increasing these thread counts blindly. By increasing the thread count too much, you will:
•    Consume a good chunk of memory
•    Your system will spend too much time-context switching


You should, at first, investigate if it's rather a problem of individual requests taking too long. Are your threads returning to the pool? If, for example, database connections are not released, threads pile up waiting to obtain a database connection thereby making it impossible to process additional requests.


In such a scenario, simply adding more thread will make things even worse by introducing a greater stress on the CPU and on the garbage collector. You can discover this kind of problem by simply taking a thread dump in your application to find out where your web server threads are stuck. For example, in this picture, taken from JConsole threads tab, you can see how an idle thread should look like, by looking at its stack trace:


jboss 7 performance tuning howto book

On the other hand, the following HTTP thread is busy at doing input/output operations which could mean, for example, the web server is acquiring data from an external resource.

jboss 7 book performance tuning
The above snapshots gives you also a clue on how you can monitor the number of web server running threads. Just fill in the executor name (http-executor) in the lower textfield, and you will have a filtered list of all your web server threads.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值