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

Vue implements three-level navigation display and hiding

This article example shares the specific code of ...

MySQL 5.7 cluster configuration steps

Table of contents 1. Modify the my.cnf file of se...

About the problem of writing plugins for mounting DOM in vue3

Compared with vue2, vue3 has an additional concep...

Convert XHTML CSS pages to printer pages

<br />In the past, creating a printer-friend...

A summary of some of the places where I spent time on TypeScript

Record some of the places where you spent time on...

Perfect solution to MySQL common insufficient memory startup failure

1. If MySQL is not started successfully, check th...

Solution to MySQL 8.0 cannot start 3534

MySQL 8.0 service cannot be started Recently enco...

The most comprehensive explanation of the locking mechanism in MySQL

Table of contents Preface Global Lock Full databa...

Docker case analysis: Building a Redis service

Table of contents 1 Create mount directories and ...

Simple usage example of MySQL 8.0 recursive query

Preface This article uses the new features of MyS...

Mysql master-slave synchronization Last_IO_Errno:1236 error solution

What is the reason for the Last_IO_Errno:1236 err...

How to Fix File System Errors in Linux Using ‘fsck’

Preface The file system is responsible for organi...