View and modify the number of concurrent Tomcat

  • Last update:June 02, 2021
  • I. Problem description

    When a user accesses a report, the server uses a thread to process report calculations.

    If the number of visitors is too large and the amount of report calculations is large, there will be a lot of people competing for server CPU threads at the same time. The server's responsiveness will be weakened, so we need to reasonably control the number of server threads.

    II. Solution

    1. Setting method

    We can control the number of threads by modifying the configuration of the Tomcat server.

    Open the %Tomcat_HOME%/conf/server.xml document and find the column of <Connector port="8080"....>.

    Add the corresponding parameter to control the number of threads after Connector port = "8080". The control parameters are as follows:

    Parameter Meaning  Default Value 
      maxThreadsThe maximum number of threads started by Tomcat, that is, the number of tasks processed at the same time 200
      acceptCountWhen the number of threads started by Tomcat reaches the maximum, the number of requests queued is accepted 100

    To adjust Tomcat's default maximum number of connections, you can increase the values of these two attributes, and make acceptCount greater than or equal to maxThreads. After the setting is completed, the following is as follows:

      <Connector port="8080" protocol="HTTP/1.1" 
                   connectionTimeout="20000" 
                   redirectPort="8443" acceptCount="500" maxThreads="400" />


    2. Precautions

    The maximum number of connections allowed by the web server is also restricted by the kernel parameter settings of the operating system. Usually, it is about 2000 for Windows and 1000 for Linux.

    The number of connections here cannot directly give the best configuration. It needs to be adjusted and tested continuously according to your actual situation to achieve the most reasonable configuration.


    Attachment List


    Theme: Performance Optimization
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    9s后關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy