• JBoss AS 7性能调优(三)


    原文:http://www.mastertheboss.com/jboss-performance/jboss-as-7-performance-tuning/page-4


    调优Webserver线程池

    还有非常多须要调优的地方终于影响Webserver的性能。当中一个最重要的因素是调优HTTP线程池设置,以匹配web请求的负载。

    这事实上是非常难做到的,但可通过调优获得最佳性能。

    webserver的线程数量是通过executor的属性来设置的:

    <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>

    然后,在线程子系统中,能够定义将要使用的池的线程数,连同其它线程属性(參见第2章。配置应用程序server,以获取有关线程子系统具体介绍):

    <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>

    最重要的连接器的属性是core-threadsmax-threads,这些值设置的太低,可能没有足够的线程来处理全部的请求,在这样的情况下,请求不被处理必须等待一段时间,直到还有一个请求线程被释放。

    过低的值也意味着JBoss的Webserver将无法充分利用server硬件的优势。

    还有一方面,要小心设置这些线程数,线程数设置过高会导致:
    •    消耗大量的内存;
    •    系统会消耗很多其它的时间做上下文切换。

    你应该首先调查是否存在个别的请求耗用过长的时间。线程是否返回到池中?假设存在这样的情况,可能原因是。数据库连接没有释放,线程排队等待获取一个数据库连接,从而使其它请求无法得到处理。

    在这样的情况下,简单地添加很多其它的线程会消耗很多其它CPU,GC更加频繁,从而使事情变得更糟。在应用程序中你能够通过採取简单的线程转储(thread dump),找出webserver线程到底在哪里堵塞。比如在这张图片中,从JConsole的线程选项卡中,通过观察它的堆栈跟踪。你能够看到看起来和以下类似的空暇线程idle thread):


    还有一方面,以下的HTTP线程忙于做输入/输出操作。可能的原因是,比如Webserver正在从外部资源获取数据。


    从上面的快照能够指导你怎样监视Webserver上执行的线程,仅仅需在最以下的文本框填写executor的名称(http-executor),就会显示全部Webserver线程的列表。

  • 相关阅读:
    leetcode701. Insert into a Binary Search Tree
    leetcode 958. Check Completeness of a Binary Tree 判断是否是完全二叉树 、222. Count Complete Tree Nodes
    leetcode 110. Balanced Binary Tree
    leetcode 104. Maximum Depth of Binary Tree 111. Minimum Depth of Binary Tree
    二叉树
    leetcode 124. Binary Tree Maximum Path Sum 、543. Diameter of Binary Tree(直径)
    5. Longest Palindromic Substring
    128. Longest Consecutive Sequence
    Mac OS下Android Studio的Java not found问题,androidfound
    安卓 AsyncHttpClient
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5316307.html
Copyright © 2020-2023  润新知