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.