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

来源:互联网 发布:spring 事务源码 编辑:程序博客网 时间:2024/06/14 01:52

原文:

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
<subsystemxmlns="urn:jboss:domain:web:1.0">
 
 <connectorenable-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
<subsystemxmlns="urn:jboss:domain:threads:1.0">
    <bounded-queue-thread-poolname="http-executor"
        blocking="true">
        <core-threadscount="10"per-cpu="20"/>
        <queue-lengthcount="10"per-cpu="20"/>
        <max-threadscount="10"per-cpu="20"/>
        <keepalive-timetime="10"unit="seconds"/>
    </bounded-queue-thread-pool>
</subsystem>

The most important Connector attributes are defined into the core-threads andmax-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 JConsolethreads 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.


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 遇到会飞的蟑螂怎么办 狗粘了老鼠胶怎么办 家有蟑螂怎么办小窍门 人感染狗的螨虫怎么办 棉拖鞋里面的臭怎么办 卧室老有酸臭味怎么办 养狗屋子有腥味怎么办 房间里进了壁虎怎么办 家中进了只老鼠怎么办 医保卡迟迟不发怎么办 医保断了一个月怎么办 没办离职的社保怎么办 家里吊顶上有老鼠怎么办 房间里进老鼠了怎么办 衣服上有老鼠屎怎么办 如果被老鼠咬了怎么办 儿童被老鼠咬了怎么办 蟑螂爬到衣柜里怎么办 床垫里有老鼠屎怎么办 汽车里进了老鼠怎么办 狗狗感染蜱虫怎么办 脸上有螨虫怎么办才能去除 老鼠被剪丁丁后怎么办 1楼下水道钻老鼠怎么办 月经来了奶水少了怎么办 孕37周霉菌严重怎么办 家里进了飞蚂蚁怎么办 家里进了大蜘蛛怎么办 衣服上有蟑螂卵怎么办 被子上有蟑螂卵怎么办 厨房里的小飞虫怎么办 水果生的小飞虫怎么办 家里的厕所有虫怎么办 人吃了蟑螂药怎么办 静电贴粘不住了怎么办 会飞的蚂蚁咬了怎么办 家里有白蚁怎么办能除根 华为畅享5s黑屏怎么办 家里有个蚂蚁窝怎么办 宿舍有老鼠爬床怎么办 楼上的狗叫扰民怎么办