Common Tomcat Optimization

Source: Internet
Author: User

The performance of Tomcat is much worse than WebLogic or websphere. However, WebLogic or WebSphere are expensive. Some entrepreneurial websites may not be able to pay for it. Free Open-source Tomcat is enough to deal with general websites. For example, Tomcat can be used if the concurrent access volume of a website is less than 1000.

To use tomcat, You need to modify some default configurations to improve Tomcat performance and concurrency. The following are some records.

 

1. Increase Tomcat memory

By default, Tomcat uses a maximum of 128 MB of memory, which can be modified.
The tomcat/bin/Catalina. BAT file increases its memory.

Set the following statement

Set catalina_opts =-xms512m-xmx1024m

 

2. modify the number of concurrent connections and compress the page

Modify the conf/server. xml file

Before modification:

<Connection Port = "8080"
Protocol = "HTTP/1.1"


Redirectport = "8443"

Connectiontimeout = "20000"

/>

After modification:

<Connection Port = "8080"
Protocol = "HTTP/1.1"


Maxhttpheadersize = "8192"
Usebodyencodingforuri = "true"

Maxthreads = "1000"


Redirectport = "8443"

Enablelookups = "false"

Compression = "on"


Compressionminsize = "2048"

Compressablemimetype = "text/html, text/XML, text/JavaScript, text/CSS, text/plain"


Connectiontimeout = "20000"


Disableuploadtimeout = "true"

/>


Maxthreads Tomcat uses threads to process each request received. This value indicates the maximum number of threads that Tomcat can create.


Acceptcount indicates the number of requests that can be placed in the processing queue when the number of threads that can be used to process requests is used. requests exceeding this number are not processed.


Connectiontimeout network connection timeout, in milliseconds. If it is set to 0, it indicates that the request Never times out. This setting has potential risks. Generally, it can be set to 30000 ms.


Minsparethreads the number of threads created during Tomcat initialization.


Once the thread created by maxsparethreads exceeds this value, Tomcat closes the socket thread that is no longer needed.


Compression = "on" enable the compression function


Compressionminsize enables the size of compressed output content. The default value is 2 kb.


Compressablemimetype compression type

 

3. Server Load balancer

In addition, if the concurrency in the running process exceeds the Tomcat capacity, you can use Apache + Tomcat to achieve load balancing of the Tomcat cluster.

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.