2. Measuring Web server performance measurement web server's performance is a people balk at the task, but we are here to give some caveats, and pointing you know where more of the details of the content. It is not like some simple tasks, such as measuring the rate of CPU or CPU-ratio measurement procedure, web server performance optimization, including Xu adjust many variables to achieve our goals. Many of the measurement strategy contains a seemingly simple browser is in fact a large number of requests sent to the server, which we call the client program to measure the response time. Client and server-side in the same machine to it? Server in the test when it comes to running any other program? Client and server-side communication is through the LAN, 100baseT, 10baseT or using a modem? Whether the client has repeatedly requested the same page, or random access to different pages? (These affect the performance of the cache service) client sends the request regular or sudden? You are in the final run under the configuration of services or in the debug configuration environment to run services? The client request contains a picture or only HTML pages? Whether there is a request by servlets and JSP, CGI, program, service-side include (Server-Side Includes, SSI is a allows you to use Dynamic HTML file technology)? All of this will be that we should be concerned about, and it is almost impossible to accurately all the questions are clearly listed.
1. Stress test tools "CPU facilitate their devices," stress tests only the help of a number of tools can be implemented.
Most web stress testing tool for the realization of the principle remains the large number of pages by repeating the request to simulate a multi-user concurrent access to the system under test so as to generate pressure on purpose. Means to put pressure through the pressure recording, or write scripts with multiple processes or threads in the form of the client is running, so that man-made through various types of pressure, we can observe the system under test conditions in a variety of pressures Under the performance, thereby positioning system bottlenecks, as the basis for tuning the system. Already existing performance testing tools are numerous, the number of no less than one hundred kinds, from a single small open-source tools such as Aapache free web performance testing tool that comes with Apache Benchmark, open-source Jmeter to a large and comprehensive performance testing of commercial software, such as Mercury's LoadRunner and so on. Any performance test tool has its pros and cons, we can choose according to the actual situation in the most appropriate tools. Here you can find some web stress testing tool http://www.softwareqatest.com/qatweb1.html # LOAD
Here we use the tools to support the web application service certification before they can, to support the receiver to send cookies, Not only that Tomcat support multiple authentication methods, such as basic authentication, form-based authentication, mutual authentication and client authentication, while some tools only supports HTTP basic authentication. A true simulation of performance testing tool for user authentication is an important part of the authentication mechanism because it will have a web site's performance characteristics have a significant impact. Based on your products, the use of different authentication methods, you need the tools from the above list, select the use of this feature of the test tool.
Apache Benchmark and http_load the form of a command-line tool, very easy to use. Apache Benchmark to mimic a single URL request and repeated execution, you can use different command-line parameters to control the implementation of the iteration the number of concurrent users and so on. One of its features can be periodically print out the process of the information, and other tools can only give an overall report.
2. Stress test tool for introducing 3. Adjustment in the external environment, Tomcat and the application of the stress test, if the performance of your application, not satisfied with the results, you can take some performance tuning measures, and of course the assumption that the application no problem, we are here to talk about Tomcat adjustments. Because Tomcat is running depends on the JVM, so here we Tomcat adjustments to a detailed description can be divided into two categories:
The external environment to adjust to adjust the non-Tomcat components, such as Tomcat to run the operating system and run Tomcat in java virtual machine.
Modify the Tomcat's own parameters, adjust the Tomcat configuration file parameters.
Here we will explain in detail about the content of external environment to adjust, Tomcat itself to adjust the contents of the will set out in Part 2.
1.JAVA virtual machine performance optimization Tomcat itself does not directly run on a computer, based on the need to rely on the hardware, operating system and a java virtual machine. You can choose your own need to choose a different operating systems and the corresponding version of the JDK (as long as is consistent with Sun released Java specification), but we recommend you use Sun's release of the JDK. To ensure that you are using the latest version, because the Sun and other companies have been to improve the performance of the java virtual machine to do some upgrades. Some reports show the performance JDK1.4 than JDK1.3 increased by nearly 10% to 20%.
Can be used to set the Java virtual machine memory, but if you choose wrong, then the virtual machine will not compensate. Available through the command line way to change the use of virtual machine memory size. The following table shows there are two parameters used to set the virtual machine using the memory size.
Parameter Description-Xms <size> JVM heap size of the initialization-Xmx <size> JVM maximum heap size of these two values is generally based on the need for setting. Initialize the size of the heap implementation of a virtual machine when it starts to apply to the system memory size. In general, this parameter is not important. But there are some applications where large load will be sharply up more memory, this time is that this parameter is very important, if the virtual machine starts to set the memory used by a relatively small and in this case there are many objects initialization, the virtual machine must be repeated to increase the memory to satisfy the use. Because of this reason, we generally put-Xms and-Xmx set to same size, while the maximum value of the heap is limited to use of physical memory in the system. Generally used a larger amount of data the application will use the persistent objects, memory usage may grow rapidly. When an application needs the memory beyond the maximum heap when the virtual machine will prompt the memory overflow and lead to the collapse of application services. It is generally recommended maximum heap is set to the maximum available memory of 80%.
Tomcat can use the default memory 128MB, in a larger application projects, this point is not enough memory and need to transfer large.
Windows, in the file (tomcat_home) / bin / catalina.bat, Unix, under, in the file (tomcat_home) / bin / catalina.sh front add the following settings:
JAVA_OPTS = '-Xms 【Initialize】-Xmx memory size of the maximum amount of memory you can use 【】'
This two parameter values need to transfer large. For example:
JAVA_OPTS = '-Xms256m-Xmx512m'
That initialize memory 256MB, you can use the maximum amount of memory to 512MB.
Another consideration is that Java provides garbage collection mechanism. Virtual machine virtual machine heap size determines the cost of refuse collection to the time and frequency. An acceptable rate of garbage collection and application of related and should be the actual garbage collection by analyzing the time and frequency to adjust. If the heap size of the lot, then the full garbage collection will be very slow, but the frequency will be reduced. If you put the memory heap size and the need for consistent, complete collection quickly, but it will become more frequent. The purpose of adjusting the heap size is to minimize the garbage collection time to a specific period of time to maximize handling customer requests. When the benchmark test in order to ensure the best performance, we should set up large size of the heap to ensure that garbage collection is not the whole benchmarking process as well.
If the system takes a lot of time to collect garbage, please reduce the heap size. A complete garbage collection should not exceed 3-5 seconds. If garbage collection becomes a bottleneck, you need to specify the generation of the size, check the detailed output of garbage collection to study the garbage collection parameters on the performance. In general, you should use 80% of physical memory heap size. When adding a processor, remember to increase the memory, as the distribution can be parallel, but garbage collection is not parallel.
2. Operating System Performance Optimization of the operating system here that is running web server software, of course, different operating systems is designed for different purposes. Example, OpenBSD is a security-oriented, so its kernel, there are many limitations to prevent different forms of service attack (OpenBSD's a motto is "the default is the most secure"). These restrictions may be more used to run an active web server.
Our common goal is to use Linux operating system to use, so it has a higher limit. Systems using the BSD kernel with a file named "Generic" kernel, indicating that all drives are statically connected. This will make the system easy to use, but if you want to create a custom kernel to enhance some of these limitations, it would need to exclude unneeded equipment. Many of the Linux kernel drivers are loaded dynamically. But the words, the memory is becoming cheaper and cheaper, so it loads an additional device driver becomes not very important. Important to have more memory, and make more room on the server's available memory.
Tip: Although the memory is already quite cheap, but still try not to buy cheaper memory. Those brands of memory, though a little expensive, but from the reliability, the cost will be higher.
If you are using the Windows operating system, Tomcat, it is best to select the server version. Because the non-server versions, the end-user license number or the operating system itself, can bear the number of users, the number of available network connections, or other aspects of the limited number of respects. And based on security considerations must always apply the latest patches to the operating system.
3.Tomcat integration with other web server, tomcat can also be used although the web server, but its handling of static html's not as fast as apache, and its function as a web server, far less apache, so we want to integrate apache and tomcat, html and jsp the function will be part of a clear division of labor, so that tomcat only deals with jsp part, the other by the apache, IIS, etc. The web server processing, thereby greatly saving tomcat limited work "threads."
4. Load balancing the load-balancing ideas, the multi-platform server symmetrical manner, each server has the same status that can provide services outside alone without other servers to complement it. Through the load-sharing technology, the request is sent outside by a certain symmetry in the rules assigned to a particular server, while the server receives the request independently to respond to client requests.
Services provided by a group of servers in an application server cluster (cluster), and to provide a unified external address. When a service request is sent to the cluster, in accordance with certain rules to select a server, and transfer services directed to the server, commitment to a balanced load-sharing will soon.
Through the application of load balancing technology to application service more than one server can provide services with limited restrictions, we can use multiple servers at the same time a large number of users. When a server fails, the load balancing server will automatically detect and stop the service request was distributed to the server is working correctly by the other servers continue to provide services to ensure service reliability.
Load balancing methods to achieve roughly four categories: The first is through DNS, but only to achieve a simple rotation distribution, can not handle failure, and the second if it is based on MS IIS, Windows 2003 server itself brought a load balancing service, the third is a hardware approach, through the switch functions or specialized equipment, load balancing can be achieved, a fourth software means, through a load-balancing servers, the above install the software. Done using the Apache Httpd Server load balancer, Tomcat using the Tomcat cluster nodes can be done more than a fourth way. More flexible in this way, the cost is relatively low. Another major advantage is that you can depending on the application server of the situation and take some strategy.
4. Self-adjusting in this section will show you detailed examples of some acceleration can speed up Tomcat to run the skills and methods, no matter what operating system or what is the Java virtual machine. In some cases, you may not have control over the deployment of the operating system environment or the Java virtual machine. In this case, you need to understand the following line by line, some of the recommendations, but you should be revised to make it take effect. I think the following approach is Tomcat the best way to adjust the performance of their own.
1. Disable DNS queries when the web applications to the client to record the information, it will also record the client's IP address or domain name server to check through the machine names are converted to IP addresses. DNS query needs to take up the network, and including the possibility of many of the very distant from the server or the server does not work up the process to obtain the corresponding IP, this will consume some time. In order to eliminate the performance impact of DNS queries that we can turn off DNS queries, methods to modify server.xml file enableLookups parameter values:
<Connector className = "org.apache.coyote.tomcat4.CoyoteConnector" port = "80" minProcessors = "5" maxProcessors = "75" enableLookups = "false" redirectPort = "8443" acceptCount = "100" debug = "0" connectionTimeout = "20000" useURIValidationHack = "false" disableUploadTimeout = "true" />
<Connector port = "80" maxThreads = "150" minSpareThreads = "25" maxSpareThreads = "75" enableLookups = "false" redirectPort = "8443" acceptCount = "100" debug = "0" connectionTimeout = "20000" disableUploadTimeout = " true "/>
Unless you need to connect to the site each HTTP client machine name, otherwise we recommend in a production environment turn off DNS query function. By means other than through the Tomcat to get the machine name. This not only saves network bandwidth, query time and memory, and the smaller flow rate will log data will become less, it is obvious also saves disk space. Right flow for smaller sites to disable DNS queries may not be apparent effect of high flow sites, but this is still a sound strategy. Who to see a low-traffic web site traffic surge overnight, then?
2. Adjustment of threads
Another one can be the application connector (Connector) for performance control of the parameters is to create a number of threads processing the request. Tomcat using the thread pool to accelerate response time to process the request. In Java, the thread is a program run-time path is in a program has nothing to do with the other thread of control, capable of stand-alone code segment. They share the same address space. To help programmers write multi-threaded CPU maximum utilization and efficient procedures to maintain a minimum idle time and thus receive more requests.
Tomcat4 can minProcessors and maxProcessors by modifying the values to control the number of threads. These values after the installation has been set to the default value and is enough to use, but as the site instead of the expansion of large these values. minProcessors created when the server starts processing the request the number of threads should be sufficient to handle a small load. That is, if one day only occurs five times per second click event, and the task of dealing with each request needs a second, then the pre-set number of threads to 5 would be sufficient. But in your site traffic to a larger need to set up when a larger number of threads, specify a value for the parameter maxProcessors. maxProcessors's value is also an upper limit should be to prevent the flow can not control (or a malicious service attacks), which led to the use of memory beyond the size of the virtual machine. If you want to increase the number of concurrent connections, it should also increase these two parameters.
The Tomcat5 on these parameters have been adjusted, see the following table:
Property Name Description maxThreads Tomcat using threads to handle each request received. This value indicated that Tomcat to create the maximum number of threads.
acceptCount specify when all that can be used to process the request the number of threads are used, you can put the number of requests handled in the queue, more than this number will not be processing the request.
connnectionTimeout network connection timeout, unit: milliseconds. Setting of 0 means never timeout, so that settings are hidden dangers. Normally be set to 30000 milliseconds.
minSpareThreads Tomcat initialization number of threads created.
maxSpareThreads Once you create a thread more than this value, Tomcat shuts down the socket thread is no longer needed.
The best way is to set up a few more tests and to observe the response time and memory usage. On different machines, operating system or virtual machine combination of circumstances may be different, but not all of the web site's traffic are the same, so there is no broad-brush proposal to determine the number of threads value.
3. Accelerate the JSP compilation speed when the first visit to a JSP file, it will be converted to Java serverlet source code, and then be compiled into Java byte code. You can control the use of which the compiler, by default, Tomcat using the command line to use the javac compiler. You can also use a faster compiler, but here we will describe how to optimize them.
Another approach is not to use the realization of all JSP pages, but the use of a number of different variables java template engine. Obviously this is a big decision to cross, but the fact that at least this method is only study. If you want to learn more about the Tomcat can use the template language, you can refer to Jason Hunter and William Crawford co-author of "Java Servlet Programming" book (O'Reilly's published).
Tomcat 4.0 can be used in the popular and free Jikes compiler. Jikes compiler, the speed should be because of Sun's Java compiler. First of all you want to install Jikes (available at http://oss.software.ibm.com/pub/jikes more information), and then need to set the environment variable contains the system is running JIKESPATH required JAR files. After the installation is also need to set a good Jikes to compile JSP to servlet using Jikes, need to modify the web.xml file jspCompilerPlugin values:
<servlet-name> jsp </ servlet-name>
<param-name> logVerbosityLevel </ param-name>
<param-value> WARNING </ param-value>
<param-name> jspCompilerPlugin </ param-name>
<! - <param-name>
</ param-name> ->
<param-name> classpath </ param-name>
/ usr / local / lib / java / servletapi / servlet.ja
r </ param-value>
<load-on-startup> 3 </ load-on-startup>
In Tomcat 4.1 (or later), JSP compiler from Tomcat inside the Ant is included in the program controller of immediate implementation. This sounds a little strange, but that is part of Ant intentional, there is an API document to guide developers to start a new JVM is not the case, the use of Ant. This is to use Ant for Java development a big advantage. In addition, this also means that you are now able to use any Ant build javac support means, there is one on the Apache Ant user manual javac page list. It is easy to use, because you only need to define an element name "compiler", and in value, there is a compiler compiler support for the name of the sample is as follows:
<servlet-name> jsp </ servlet-name>
<param-name> logVerbosityLevel </ param-name>
<param-value> WARNING </ param-value>
<param-name> compiler </ param-name>
<param-value> jikes </ param-value>
<load-on-startup> 3 </ load-on-startup>
Ant is available compiler compiler invoked the name of an alias classic
Standard JDK 1.1/1.2 compiler
Standard JDK 1.3/1.4 compiler
jikes The Jikes compiler
JVC Microsoft Microsoft command-line compiler from the Microsoft SDK for Java / Visual J + +
KJC The kopi compiler
GCJ The gcj compiler (included as part of gcc)
SJ Symantec Symantec's Java compiler
extJavac Runs either the modern or classic compiler in a JVM of its own
Because JSP pages in the first use have been compiled, then you may want to update immediately after a new jsp page is compiled it. In fact, this process can be completely automated, because it can confirm is that the new production server and the JSP page on the server running the test result is the same.
The Tomcat4 the bin directory there is a script called jspc. It is only running translation stage, rather than the compilation stage, use it in the current directory generated Java source files. It is a powerful debugging JSP pages means.
Through the browser and then confirm the results of compilation. This ensures the file is converted to serverlet, has been compiled that can be of immediate implementation. This will also accurately mimic the real user access to JSP pages, you can see the functionality provided to users. Also pay close attention to this last-minute changes and bug appears to modify its J
Tomcat provides a request to compile JSP pages through the function. For example, you can enter in the browser address bar http://localhost:8080/exa......ate.jsp?jsp_precompile=true, so Tomcat will be compiled data.jsp rather than execute it. This will be picked up, after all, a shortcut to test the correctness of the page.
4. Other than the operating system we mentioned earlier through a number of restrictive measures to prevent malicious service attacks, the same Tomcat also provided to prevent malicious attacks or prohibit access to certain machine settings.
Tomcat provides two parameters for your configuration: RemoteHostValve and RemoteAddrValve.
By configuring these two parameters, allowing you to filter the request from the host or IP address, and allow or deny what the host / IP. Similarly, in Apache's httpd file there for each directory Allow / Deny specified.
For example, you can set the Admin Web application allows only local access, set as follows:
<Context Path="/path/to/secret_files" ...>
<Valve ClassName="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1" deny=""/>
If no host is given to allow the designation, then the match and refused to host the host will be rejected, in addition are allowed. Similarly, if not given a designated refuse to host, then allowed to host matches with the host will be allowed, in addition are rejected.
5. Capacity planning capacity planning is to use Tomcat in a production environment to improve performance, I must mention another important topic. If you do not, under the expected network traffic to consider the hardware and bandwidth to do so then no matter how you make configuration changes and testing to no avail.
Here the reference to the capacity of the first plan to make a brief definition: the capacity plan is the assessment of the hardware, operating systems and network bandwidth, determine the scope of services application services to find suitable hardware and software requirements and software features of an activity. Therefore, the software mentioned here includes not only Tomcat, but also used in conjunction with the Tomcat any third-party web server software.
If the purchase of hardware and software or deployment of the system capacity planning before you know nothing about, do not know if the existing hardware and software environment that can support the number of visits, and even worse, until you have been delivered and deployed in a production environment after the awareness of product the configuration there is a problem further changes may be too late. At this time only increase hardware investment, increasing hard disk capacity and even to buy a better server. If you had done a capacity planning then it would not engage in such a bruised and battered by.
We'll stick with Tomcat-related content.
First, the use of machinery in order to determine the capacity of Tomcat program, you should look at the list from the project to proceed kinds of studies and plans:
1. What kind of hardware using the hardware system? How many computers? Use a large, or the use of multiple minicomputer? Each computer to use a few CPU? How much memory? What kind of storage devices to use, I / O processing speed What are the requirements? How to maintain these computers? Different JVM to run on these hardware how well (such as IBM AIX systems only in the design of hardware systems to run on)?
2. The use of network bandwidth limit how much bandwidth? web application, how to deal with too many requests?
3. Server operating system, which operating system used as the site server is the best? The operating system to use in determining which JVM is the best? For example, JVM in this system, whether to support local multi-threaded, symmetric multi-processing? Which system allows web servers faster, more stable and cheaper. Whether to support multi-CPU?
4. Tomcat described below capacity planning capacity planning for the Tomcat to do the steps:
1) quantify the load. If the site is up and running, you can use the tools described earlier imitation of user access, determine the demand for resources.
2) the test results or the testing process for analysis. Need to know those requests resulted in overloading or use excessive resources, and compare with other requests, so that the system's bottlenecks identified. For example: If the servlet on the steps in the query database, spent a long time, then we need to consider the use of the buffer pool to reduce the response time.
3) to determine the minimum performance standards. For example, you do not want users to spend 20 seconds to wait for the return of the results page, meaning that even in traffic to reach the limit, the user waiting time can not exceed 20 seconds (from click on the link to see a return to the first return data ). This time includes the database query time and file access time. The performance of similar products in different companies may have different standards, usually best taken by peers in the minimum standards or to assess this standard.
4) to determine how the rational use of the underlying resources, and each test. The underlying resources, including CPU, memory, storage, bandwidth, operating system, JVM and so on. In a variety of production environments in both deployment and testing in order to observe whether it meet the demand. Tomcat, when as many as possible in the test using several JVM, and adjust the JVM memory and Tomcat using the thread pool size of the test. Meanwhile, in order to achieve a stable and reasonable use of resources for the full effect of the test needs to appear in the process bottleneck in hardware systems for processing to determine a reasonable allocation of resources. This process is the most complex, and generally refer to the absence of a value can only be inferred by the theory and lessons learned.
5) If the adoption of Step 4, if the repeated tests to achieve an optimal combination, we can deploy the same product in a production environment.
It should also be borne in mind must be documented and the results of your testing process, as may also be tested later, so that you can take before the test results as a reference. In addition the testing process to be repeated numerous times, each time the conditions may not be the same, so that only record the results can be compared and the best conditions for choice.
So that we passed the test to find the best combination of various resources have been a reasonable configuration, system performance has been greatly improved.
6. Additional information is very clear that this is also very difficult to elaborate a comprehensive and detailed performance optimization process. If you do more research, then might do a better job tuning, such as the Java program performance tuning, operating system, the adjustment of a variety of complex environments and applications and all other things associated with the application. Some text here that some of the resources mentioned in the text links to relevant content, as well as a number of references of this article.
1. Web performance test data and tools to 1) Jmeter Wiki page, Jmeter for a 100% Java open source performance testing tools developed by http://wiki.apache.org/jakarta-jmeter/
2) Apache Benchmark instructions http://httpd.apache.org/docs-2.0/programs/ab.html
3) A number of Java-related testing tools introduction, including integration with Tomcat to test a tool for http://blog.csdn.net/wyingquan/
4) LoadRunner? Is a predictable system behavior and performance of industry-standard-class load testing tools. It does this by tens of millions of analog data to the user to implement the concurrent load to test the entire enterprise architecture to help you find and identify problems faster.
2. This paper presents relevant content introduction 1) Apache 2.x + Tomcat 4.x to do load balancing, describes how to configure the cluster jk load balancing.
2) capacity planning, collection of a number of web sites on the development of capacity planning examples:
3) evaluation Tomcat5 load balancing and clustering,
4) Apache with Tomcat installation and integration of the integration of articles http://www.javaresearch.o......?column=23&thread=18139
5) performance testing tools, introduces the principles of performance testing tools and ideas http://www.51testing.com/emagzine/No2_2.htm
6) Java Memory Leak http://www.matrix.org.cn/resource/article/409.html
7) Web server and application server What is the difference?
8) elaborate on the performance of the database clustering problem http://www.theserverside.com/articles/article.tss?l=DB_Break
Related Posts of Tomcat Performance Tuning (change)
Tomcat performance tuning program an operating system tuning is optimized for the operating system is increasing as the memory capacity can be used to improve the frequency of CPU, ensure that the file system read and write speed and so on. After pressure
In the Tomcat and application of the stress test, if the performance of your application, not satisfied with the results, you can take some performance tuning measures, and of course the premise is the application process does not, we here speak only Tomc
Some time ago is reflected in a production system using the struts2 pages display too slow. Log in and found true, some performance tuning was carried out research and testing. 1, according to the instructions struts2 official tuning some parameter change
Reproduced in: http://klevein.iteye.com/blog/871168 Tomcat performance tuning program, and the operating system tuning to optimize the operating system, it is possible to increase the available memory capacity, increase the CPU frequency to ensure th
Recommended Books :oracle database 10g performance tuning tips& Techniques you performance tools dba_tables: dba_tab_columns: dba_clusters: dba_indexes: dba_ind_columns: index_stats: index_histogram: dba_tab_histograms: Execution statistics to us
Has to be responsible for an old system to do performance tuning. First of all want to be able through the sampling method on the line to do a performance, an understanding of the situation. I think of before exposure to flies perf4j. Tool itself is
Oracle Remove duplicate data an efficient way Oracle performance tuning overview of the basic methods Oracle sql performance tuning adjustment oracle performance tuning tips Use the index in the index Oracle performance tuning adjustment ORACLE SQL P
tomcat performance tuning points: 1. EnableLookups: Set to true if you want calls to request.getRemoteHost() to perform DNS lookups in order to return the actual host name of the remote client. Set to false to skip the DNS lookup and return the IP address
Dynamic view of diagnostic tools v $ buffer_pool_statistics v $ buffer_pool v $ db_cache_advice v $ sysstat v $ sesstat v $ system_event v $ session_wait v $ bh v $ cache Statpack OEM's tuning to reduce the use of performance indicator informatio
Now you need to use the JBOSS server project an overall tuning, collected some data, prepared from the following aspects of performance tuning JBOSS: (1) First, unresolved jboss encountered no anti-(suspended animation) to be the problem. When the co