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

More elegant processing of dates in JavaScript based on Day.js

Table of contents Why use day.js Moment.js Day.js...

Solution to span width not being determined in Firefox or IE

Copy code The code is as follows: <html xmlns=...

Problems with using multiple single quotes and triple quotes in MySQL concat

When dynamically concatenating strings, we often ...

How to place large images in a small space on a web page

Original source: www.bamagazine.com There are nar...

Detailed explanation of Linux copy and paste in VMware virtual machine

1. Linux under VMware Workstation: 1. Update sour...

Vue component to realize carousel animation

This article example shares the specific code of ...

How to enable the root account in Ubuntu 20.04

After Ubuntu 20.04 is installed, there is no root...

Determine whether MySQL update will lock the table through examples

Two cases: 1. With index 2. Without index Prerequ...

JavaScript MouseEvent Case Study

MouseEvent When the mouse performs a certain oper...

CSS code to achieve 10 modern layouts

Preface I watched web.dev's 2020 three-day li...

Display and hide HTML elements through display or visibility

Sometimes we need to control whether HTML elements...