Tomcat + MySQL high concurrency configuration optimization

Source: Internet
Author: User

1.Tomcat optimized configuration

(1) Change the catalina.bat of Tomcat

Turn Java into server mode, increase the JVM's memory, add at the beginning of the file

setjava_opts=-server-xms1024m-xmx2048m-xss512k-xx:permsize=128m-xx:maxpermsize=256m

setcatalina_opts=-server-xms512m-xmx512m

Such as:

Xms: Initial Memory

XMX: Max Memory

(3) Change the server.xml of Tomcat

The following configuration is added in the <service name= "Catalina" > (2000 concurrency is not a problem in the pro test for 10 seconds).

<executorname= "Tomcatthreadpool" nameprefix= "catalina-exec-"

maxthreads= "minsparethreads=" maxidletime= "60000"/>

<connectorexecutor= "Tomcatthreadpool"

Port= "protocol=" http/1.1 "

Connectiontimeout= "60000"

keepalivetimeout= "15"

maxkeepaliverequests= "200"

Disableuploadtimeout= "false"

Enablelookups= "false"

redirectport= "8443"/>

Note that the number of maxthreads should not be adjusted too large, it is easy to produce the following error:

2,mysql optimized configuration

(1) Change MySQL my.ini (Windows) or MY.CNF (Linux)

max_connections=12000//maximum number of connections generally between 0~15000, try not to exceed 15000

max_user_connections=0//maximum number of user connections, 0 is not limited

interactive_timeout=31536000//time-out, set to one year, avoid connection pool errors

wait_timeout=31536000

QUERY_CACHE_SIZE=512M//query cache, try to set a larger, avoid errors

key_buffer_size=1024m

Query_cache_type= 1

max_allowed_packet=600m

Tomcat + MySQL high concurrency configuration optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.