Tomcat+Mysql high concurrency configuration optimization explanation

Tomcat+Mysql high concurrency configuration optimization explanation

1.Tomcat Optimization Configuration

(1) Change Tomcat's catalina.bat

Change Java to server mode, increase the memory of jvm, and add

setJAVA_OPTS=-server -Xms1024m -Xmx2048m -Xss512K -XX:PermSize=128m -XX:MaxPermSize=256m
setCATALINA_OPTS=-server -Xms512m -Xmx512m

As shown below:

Xms: Initial memory

Xmx: Maximum memory

(2) Change Tomcat's Server.xml

Add the following configuration in <Servicename="Catalina"> (tested, 2000 concurrent connections within 10 seconds are no problem).

<Executorname="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="800"minSpareThreads="25" maxIdleTime="60000"/>
<Connectorexecutor="tomcatThreadPool"
port="80"protocol="HTTP/1.1"
connectionTimeout="60000"
keepAliveTimeout="15"
maxKeepAliveRequests="200"         
           disableUploadTimeout="false"
           enableLookups="false"
redirectPort="8443"/>

Note that the maxThreads number should not be adjusted too large, which may easily cause the following errors:

2. Optimize MySQL configuration

(1) Change MySql's my.ini (windows) or my.cnf (linux)

max_connections=12000 //The maximum number of connections is generally between 0 and 15000, try not to exceed 15000
max_user_connections=0 // Maximum number of user connections, 0 means no limit interactive_timeout=31536000 // Timeout, set to one year to avoid the following error in the connection pool wait_timeout=31536000 

query_cache_size=512m //Query cache, try to set it larger to avoid the following error 

key_buffer_size=1024m
query_cache_type = 1
max_allowed_packet=600m

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • MySQL Series 10 MySQL Transaction Isolation to Implement Concurrency Control
  • Detailed explanation of MySQL multi-version concurrency control mechanism (MVCC) source code
  • Implementation of MySQL's MVCC multi-version concurrency control
  • MySQL high concurrency method to generate unique order number
  • MySQL lock control concurrency method
  • Mysql transaction concurrency problem solution
  • How to solve the high concurrency problem in MySQL database
  • MySQL concurrency control principle knowledge points
  • Implementation of MySQL multi-version concurrency control MVCC
  • How to handle concurrent updates of MySQL data
  • How does MySQL achieve multi-version concurrency?

<<:  Vue3+TypeScript encapsulates axios and implements request calls

>>:  Solution to 1449 and 1045 exceptions when connecting to MySQL

Recommend

Usage and demonstration of ref in Vue

ref definition: used to register reference inform...

Example of horizontal arrangement of li tags in HTMl

Most navigation bars are arranged horizontally as...

Vue3+TypeScript encapsulates axios and implements request calls

No way, no way, it turns out that there are peopl...

How to ensure that every page of WeChat Mini Program is logged in

Table of contents status quo Solution Further sol...

Sample code for installing ElasticSearch and Kibana under Docker

1. Introduction Elasticsearch is very popular now...

WeChat Mini Program Basic Tutorial: Use of Echart

Preface Let’s take a look at the final effect fir...

CentOS7 installation GUI interface and remote connection implementation

Use the browser (webdriver)-based selenium techno...

JavaScript's unreliable undefined

undefined In JavaScript, if we want to determine ...

RHCE installs Apache and accesses IP with a browser

1. at is configured to write "This is a at t...

Vue implements the function of calling the mobile phone camera and album

This article shares the specific code of Vue to a...

JavaScript implements select all and unselect all operations

This article shares the specific code for JavaScr...

Various correct postures for using environment variables in Webpack

Table of contents Write in front Business code us...

Deleting files with spaces in Linux (not directories)

In our daily work, we often come into contact wit...

Recommend 60 paging cases and good practices

<br />Structure and hierarchy reduce complex...

Detailed tutorial on installing and configuring MySQL 5.7.20 under Centos7

1. Download the MySQL 5.7 installation package fr...