Fine tuning the web stack
This topic discusses how to fine tune the web stack to optimize the handling of HTTP requests in terms of the rate of service and throughput. The task is to configure the web stack to behave predictably under load and to leverage the available hardware resources to service HTTP requests as quickly as possible.
This section includes the following information:
For this discussion, when deploying a web application, consider the following abstraction layers of the web stack:
Web Application |
Servlet Engine/Container |
JVM |
Operating System |
Hardware/VM |
With these layers in mind, the goals are:
- Configure stack behavior so that it is predictable (in terms of JVM CPU and heap resource usage) under load
Leverage available hardware resources to maximize the performance of the dedicated web stack
Predictable behavior means the behavior of JVM CPU and heap usage can be approximated in terms of workload. And specifically in the case of a web application, predictable behavior is used to determine a level of JVM CPU and heap usage at the workload before use case times degrade. Once this level is determined, you can adjust the stack for your expected workload employing vertical/horizontal scaling as necessary.
Also, to minimize the number of configurable parameters and for simplicity, the discussion here uses a single dedicated web stack: The hardware or virtual machine (VM) is assumed to host only the single instance of the Tomcat/web application with no other service or web application running on the same hardware/VM.
Lastly, when allocating memory to a process on any hardware or VM hosting a web application, allocate so that the OS layer will not swap. Swapping introduces unpredictable service behavior in terms of time required for servicing an HTTP request. Your OS platform has tools, such as perfmon and sar, to monitor the swap behavior.
One method to ensure available memory for your java process is to leverage Java Support for Large Memory Pages. This feature is ON by default for the Solaris OS and OFF by default for Windows and Linux. If you are running Linux with version 2.6 kernel or Windows Server 2003 or higher, you can turn this feature on to lock the necessary memory to your java process. The basic instructions are found here: http://www.oracle.com/technetwork/java/javase/tech/largememory-jsp-137182.html