Oracle9i Application Server Oracle HTTP Server powered by Apache Performance Guide Release 1.0.2 for AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, and Sun Solaris Intel October 2000 Part No.
Oracle9i Application Server Oracle HTTP Server powered by Apache Performance Guide, Release 1.0.2 Part No. A86828-01 Copyright © 2000, Oracle Corporation. All rights reserved. Authors: Pallavi Bhowmik, and Julia Pond. Contributors: Corinne Arne, Rupesh Das, Danielle Higgins, Prashanth Joshi, Rajesh Konanganparambath, Saurabh Pandey, and Sriram V.R. Nagaraja Rao .
Contents Send Us Your Comments .................................................................................................................. vii Preface............................................................................................................................................................ ix 1 Performance Overview Performance Terms .............................................................................................................................
Monitoring the Web Server............................................................................................................... Using the mod_status Utility ...................................................................................................... Logging Server Statistics to a File............................................................................................... Monitoring JServ Processes .....................................................................................
Using Single Thread Model Servlets.......................................................................................... What is OracleJSP? ............................................................................................................................. OracleJSP Page Performance Tuning .............................................................................................. Impact of Session Management.....................................................................................
vi
Send Us Your Comments Oracle9i Application Server, Oracle HTTP Server powered by Apache Performance Guide, Release 1.0.2 Part No. A86828-01 Oracle Corporation welcomes your comments and suggestions on the quality and usefulness of this publication. Your input is an important part of the information used for revision.
viii
Preface Audience This guide is written for Oracle Internet Application Server 8i developers and system administrators who are responsible for configuring and tuning the Oracle HTTP Server powered by Apache. Assumptions There are many sources of information on configuring and tuning web servers, Apache in particular. This guide refers to those sources when expedient, and, where practical, quantifies the performance gains resulting from configuration actions found in those sources.
Convention Example Explanation italics file1 Identifies a variable in text; replace this place holder with a specific value or string. angle brackets Identifies a variable in code; replace this place holder with a specific value or string. courier owsctl start wrb Text to be entered exactly as it appears. Also used for functions. square brackets [-c string] Identifies an optional item.
Product and Documentation For U.S.A customers, Oracle Store is at: ■ http://store.oracle.com Links to Stores in other countries are provided from this site. Product documentation can be found at: ■ http://docs.oracle.com Customer Service Global Customer Service contacts are listed at: ■ http://www.oracle.com/support Education and Training Training information and worldwide schedules are available from: ■ http://education.oracle.
xii
1 Performance Overview This chapter discusses performance and tuning concepts, and briefly describes Oracle9i Application Server architecture.
Performance Terms Performance Terms Following are performance terms used in this book: concurrency The ability to handle multiple requests simultaneously. Threads and processes are examples of concurrency mechanisms. latency The time that one system component spends waiting for another component in order to complete the entire task. Latency can be defined as wasted time. In networking discussions, latency is defined as the travel time of a packet from source to destination.
What is Performance Tuning? ■ Wait Time ■ Critical Resources ■ Effects of Excessive Demand ■ Adjustments to Relieve Problems Response Time Because response time equals service time plus wait time, you can increase performance in this area by: ■ Reducing wait time ■ Reducing service time Figure 1–1 illustrates ten independent tasks competing for a single resource. Figure 1–1 Sequential processing of independent tasks In this example, only task 1 runs without waiting.
What is Performance Tuning? In parallel processing with multiple resources, more resources are available to the tasks. Each independent task executes immediately using its own resource: no wait time is involved. System Throughput System throughput is the amount of work accomplished in a given amount of time. You can increase throughput by: ■ ■ Reducing service time Reducing overall response time by increasing the amount of scarce resources available.
What is Performance Tuning? Critical Resources Resources such as CPU, memory, I/O capacity, and network bandwidth are key to reducing service time. Adding resources increases throughput and reduces response time.
What is Performance Tuning? Effects of Excessive Demand Excessive demand increases response time and reduces throughput, as shown in Figure 1–4. If there is any possibility of the demand rate exceeding the achievable throughput, a demand limiter (such as MaxClients in the Oracle HTTP Server and security.maxConnections in JServ) is essential. Look at the possible demands that may be placed on the system and design the application or configure the system with these constraints in mind.
Evaluating Performance Setting Performance Targets Whether you are designing or maintaining a system, you should set specific performance goals so that you know how and what to optimize. If you alter parameters without a specific goal in mind, you can waste time tuning your system without significant gain. An example of a specific performance goal is an order entry response time under three seconds.
Performance Methodology Performance Methodology Achieving optimal effectiveness in your system requires planning, monitoring, and periodic adjustment. The first step in performance tuning is to determine the goals you need to achieve and to design effective usage of available technology into your applications.
Performance Methodology Factors in Improving Performance Performance spans several areas: ■ ■ ■ ■ ■ Application design: Designing applications that efficiently utilize hardware resources and handle increasing numbers of users effectively. Sizing and configuration: Determining the type of hardware needed to support your performance goals. See Chapter 3, "Sizing and Configuration". Parameter tuning: Setting configurable parameters to achieve the best performance for your application.
Architecture Architecture Figure 1–6 shows the architecture of Oracle9i Application Server. This guide addresses the performance and configuration of these components: ■ Oracle HTTP Server powered by Apache ■ Apache JServ ■ OracleJSP See the Oracle9i Application Server Overview Guide for a list of publications that describe other components.
2 Monitoring Your Web Server This chapter describes utilities and processes you can use to gather information from your system. This information helps you to determine the best use of your resources.
Monitoring Processor Use Monitoring Processor Use To determine process utilization, you should gather CPU statistics. You should also monitor system scalability by adding users and increasing the system workload. Use utilities such as sar (System Activity Reporter) and mpstat to monitor process use. Using the sar Utility (AIX, HP-UX, Intel Solaris) You can use sar to sample cumulative activity counters in the operating system at specified intervals.
Monitoring the Web Server The sar command (-u option) provides the following statistics: Table 2–1 CPU statistics, as reported by the sar utility CPU Statistics Description %usr percentage of time in which the processor is running in user mode %sys percentage of processes running in system time %wio percentage the processor spends waiting on I/O requests %idle percentage that the processor is idle Using the top Utility You can use the top utility to view the ongoing processor activity in real tim
Monitoring the Web Server Using the mod_status Utility To enable monitoring, edit the httpd.conf file to replace your_domain.com with the hostname of the server you want to monitor. SetHandler server-status Order deny, allow Deny from all Allow from your_domain.com Ensure that the ExtendedStatus directive is set to On, so that the maximum amount of information is displayed. When you allow access from all domains, instead of just your_domain.
Monitoring the Web Server Figure 2–1 Server status page Interpreting Server Status Information The display (with ExtendedStatus enabled) shows that 6 requests are being processed and four servers are idle. You can determine what stage of processing each server is in from the value in the M (Mode column). In Figure 2–1, 6 servers are sending replies and 4 servers are waiting for connections.
Monitoring the Web Server has been completed, there is a W in the M (mode) column for the process, the process is probably not responding. Another situation that is important to monitor is that of the system being CPU bound, where CPU utilization is around 90%. The server status page displays CPU usage and the number of processes spawned. If the system is approaching the httpd process limit (the MaxClients directive’s setting in httpd.
Monitoring the Web Server The script is designed to be run by cron (or an equivalent daemon that executes commands at intervals). To use the script, you must modify the following configuration variables: Table 2–2 Log status script variables Variable Value $wherelog The pathname of the log file location, for example: /private/admin/logs/ The script creates a file name, such as: 20010945. $port Port number of the server to monitor. The default is 80. $server The server host name.
Monitoring JServ Processes Monitoring JServ Processes After you start the Oracle9i Application Server, you can check to ensure that all JServ processes have started normally. 1. Remove the comments in the JServ status handler section of the jserv.conf file to enable monitoring and specify the host(s) that can access JServ status (the default is localhost). Be aware of security implications when selecting the hosts that will be allowed to access status information on your system.
Monitoring JServ Processes Figure 2–3 JServ status display The Status column shows the current shared memory (shm) state of each process.
Monitoring JServ Processes Note: The Status column is populated only for processes that are started in manual mode. It is not populated for a single process started in automatic mode. The symbols that appear in parentheses after the word Up or Down have the following meanings: 2-10 Symbol Meaning + The process is running. - The process is stopped. X The process was terminated in a harsh shutdown.
3 Sizing and Configuration This chapter provides guidelines for sizing and configuration which can help you meet performance goals. It also discusses performance factors, such as memory consumption, I/O issues, and network and software constraints.
Understanding Concurrent Users and User Population relationship between the number of potential users and the number of concurrent users. This is determined by the think time and the average response time for your application. To determine memory requirements, you also need to consider the number of concurrent executing users (not the total user population) times the cost per user. Note: The MaxClients setting in your httpd.conf file limits the number of concurrently executing users.
Determining Memory Requirements Determining CPU Requirements For most applications, the majority of the CPU utilization is spent in processing the application’s code. The CPU requirement of any application depends on its complexity and workload, as shown in Table 3–2. You will need to monitor the CPU requirements of applications throughout the development cycle. See Chapter 2, "Monitoring Your Web Server" for information on how to do this.
Determining Memory Requirements ■ Memory for Non-HTTP Server Software and Operating System ■ HTTP Server Memory Requirements ■ JServ Memory Requirements ■ Determining Java Heap Size ■ Servlet and OracleJSP pages Memory Requirements ■ Number of JServ Processes Memory for Non-HTTP Server Software and Operating System In an idle system with memory resources freely available, your operating system statistics may indicate that the resident memory usage is close to the virtual size.
Determining Memory Requirements To maximize performance, set the maximum heap size to accommodate application requirements. To determine how much Java heap you need, include calls in your program to the Runtime.getRuntime().totalMemory() and Runtime.getRuntime().freeMemory methods in the java.lang package. Subtract free memory from total memory; the difference is the amount of heap that the application consumed. Suppose you determine that you need 128MB of heap.
Determining Memory Requirements The amount of memory needed depends on whether sessions are used; a session consumes about 0.5KB. For maximum performance, if sessions are not being used, turn them off in the OracleJSP application as follows: <%@ page session=”false” %>
HelloWorld As a starting point, figure that each active user consumes at least 150K to 200K for Java applications, plus the size of the server processes.Determining Memory Requirements Figure 3–1 Request distribution Sizing and Configuration 3-7
Determining Memory Requirements 3-8 Oracle HTTP Server powered by Apache Performance Guide
4 Optimizing HTTP Server Performance This chapter provides information on improving the Oracle HTTP Server’s performance, including tuning TCP parameters, the effects of changing the MaxClients parameter, SSL caching, and logging. Contents ■ TCP Tuning ■ MaxClients ■ SSL Session Caching ■ Impact of Logging ■ HTTP/1.
TCP Tuning TCP Tuning Correctly tuned TCP parameters can improve performance dramatically. This section contains recommendations for TCP tuning and a brief explanation of each parameter. The table below contains recommended TCP parameter settings. Table 4–1 Recommended TCP parameter settings for Intel Solaris Parameter Setting Comments 32768 See "Increasing TCP Connection Table Access Speed" on page 4-6. tcp_conn_hash_size 4-2 tcp_close_wait_interval 60000 Parameter name in Solaris 2.6.
TCP Tuning Table 4–2 Tuning HP-UX for Performance Benchmarking Parameter Scope Default Value Tuned Value tcp_time_wait_interval ndd/dev/tcp 60,000 60,000 tcp_conn_req_max ndd/dev/tcp 20 1,024 tcp_ip_abort_interval ndd/dev/tcp 600,000 60,000 tcp_keepalive_interval ndd/dev/tcp 7,20,00,000 900,000 tcp_rexmit_interval_initial ndd/dev/tcp 1,500 1,500 tcp_rexmit_interval_max ndd/dev/tcp 60,000 60,000 tcp_rexmit_interval_min ndd/dev/tcp 500 500 tcp_xmit_hiwater_def ndd/dev/tcp 32
TCP Tuning Table 4–4 AIX TCP Parameters (using no command) Parameter Model Default Value Recommended Value rfc1323 /etc/rc.net 0 1 sb_max /etc/rc.net 65,536 1,31,072 tcp_mssdflt /etc/rc.net 512 1,024 ipqmaxlen /etc/rc.net 50 100 tcp_sendspace /etc/rc.net 16,384 65,536 tcp_recvspace /etc/rc.net 16,384 65,536 xmt_que_size /etc/rc.net 30 150 Linux Tunables Raising Network Limits on Linux Systems for 2.1.
TCP Tuning You will find some other possibilities to tune TCP in /proc/sys/net/ipv4/: ■ tcp_timestamps ■ tcp_windowscaling ■ tcp_sack There is a brief description of TCP parameters in /Documentation/networking/ip-sysctl.txt. Tuning at Compile Time All the above TCP parameter values are set default by a header file in the Linux kernel source directory /LINUX-SOURCE-DIR/include/linux/skbuff.h These values are default. This is run time configurable.
TCP Tuning With the tuned TCP stacks, it was possible to get a maximum throughput between 1.5 and 1.8 Mbits via a 2Mbit satellite link, measured with netperf. Setting TCP parameters To set the connection table hash parameter, on Intel Solaris, you must add the following line to your /etc/system file, and then restart the system: set tcp:tcp_conn_hash_size=32768 On Tru64, tcbhashsize can be set at /etc/sysconfigtab. A sample script, tcpset.
TCP Tuning Specifying Retention time for Connection Table entries The TCP connection table maintains data associated with connections. The server maintains a TCP connection table entry for some time after a connection is closed, so that it can identify and properly dispose of any leftover incoming packets from the client. Access speed to this table impacts performance; the access speed depends on the number of entries in the table, and on its hash size.
TCP Tuning On most web servers, the defaults will be sufficient, but if you have more than 1024 concurrent users, these settings may be too low. In that case, connections will be dropped in the handshake state because the queues are full. You can determine whether this is a problem on your system by inspecting the values for tcpListenDrop, tcpListenDropQ0, and tcpHalfOpenDrop with netstat -s. If either of the first two values are nonzero, you should increase the maximums.
MaxClients large data transfers significantly. Use the following commands to enlarge the window. On Intel Solaris: prompt>/usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 32768 prompt>/usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 32768 On HP-UX: prompt>/usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwater_def 32768 prompt>/usr/sbin/ndd -set /dev/tcp tcp_recv_hiwater_def 32768 Because the client typically receives the bulk of the data, it would help to enlarge the TCP receive windows on end users’ systems.
SSL Session Caching could be reduced, to act as a throttle on the number of concurrent requests on the server. SSL Session Caching The Oracle HTTP server caches a client’s SSL session information by default. With session caching, only the first connection to the server incurs high latency. For example, in a simple test to connect and disconnect to an SSL-enabled server, the elapsed time for 5 connections was 11.4 seconds without SSL session caching.
HTTP/1.1 to log IP addresses. You can resolve IP addresses to host names off-line, with the logresolve utility (found in the $ORACLE_HOME/Apache/Apache/bin/ directory). For more information, see Dale Gaudet’s Apache Performance Notes at: http://www.apache.org/docs/misc/perf-tuning.html Error logging The server notes unusual activity in an error log. The ErrorLog and LogLevel directives identify the log file and the level of detail of the messages recorded. The default level is warn.
HTTP/1.1 Shorter Response Times Persistent connections can improve total response time for a web interaction that involves multiple HTTP requests, because the delay of setting up a connection only happens once. Consider the total time required, without persistent connections, for a client to retrieve a web page with three images from the server.
HTTP/1.1 This is a 20% reduction in service time. When the system is under load, the benefit of reducing connection time with persistent connections is even greater, due to the corresponding reduction of the TCP queue. Reduction in Server Workload Another benefit of persistent connections is reduction of the work load on the server. Because the server need not repeat the work to set up the connection with a client, it is free to perform other work.
Apache Versions The problem is that when a connection becomes idle, and the server closes it because the keep alive time limit has expired, the client host may not perform the TCP protocol steps required to complete the closure of the connection. The host, having sent the close request, is left with the connection in the FIN_WAIT_2 state taking up memory until it gets the appropriate packets back from the client, or until an internal flush occurs.
5 Optimizing Apache JServ This chapter describes the JServ architecture, and discusses ways you can improve its performance. It also includes performance information on OracleJSP pages (the Oracle implementation of Sun Microsystems’ JavaServer Pages 1.1.
JServ Overview JServ Overview Apache JServ is made up of an Apache module called mod_jserv, which runs in the httpd process, and a servlet engine, which runs in a Java process. mod_jserv, which is implemented in C, functions as a dispatcher, routing each servlet request to a JServ process for execution. The servlet engine runs in its own JVM and is solely responsible for parsing the request and generating a response. As Figure 5–1 shows, multiple JServs can service requests.
Optimizing Servlet Performance Optimizing Servlet Performance This section discusses strategies for optimizing JServ performance: loading servlets when starting the JVM, and load balancing. The terms “repository” and “zone” are used in this discussion. Servlets, repositories, and zones are analogous to files, directories and virtual hosts. A servlet is a single unit, a repository is a collection of servlets, and a zone is a collection of repositories.
Optimizing Servlet Performance parameters to false, since there is a performance cost in checking the repositories on every execution of a servlet. Change these parameters in the zone properties file: autoreload.classes=false autoreload.file=false Load Balancing It is often beneficial to spread the servlet application load among multiple JServ processes, especially when the application is run on a multiprocessor or if the servlets and HTTP server are run on separate nodes.
Optimizing Servlet Performance 3. Edit jserv2.properties as follows: port=8002 log.file=/usr/local/jserv/logs/jserv2.log Note: If your HTTP server will be running on a different host than the JServ processes, you must also add the IP address of the host running the HTTP server to the security.allowedAddresses parameter in each jserv.properties file. If JServ is included in your CLASSPATH, you can start the JServ processes with these commands: java JServ jserv1.properties java JServ jserv2.
Optimizing Servlet Performance ApJServHost JServ2 ajpv12://127.0.0.1:8002 ApJServRoute JS1 JServ1 ApJServRoute JS2 JServ2 ApJServShmFile /usr/local/apache/logs/jserv_shm * The ApJServMount directive, with /servlets balance://set/root, now balances requests for servlets in /servlets between JServ1 and JServ2. * The ApJServBalance directive identifies JServ1 and JServ2 as the processes that share the load. The ’2’ following JServ2 is a weight value.
Optimizing Servlet Performance b. If the request is not part of a session, mod_jserv selects an engine based on the process ID of the httpd process and the number of entries in the list of available JServs, as follows: JServ_id to handle the request = httpd_pid % number of JServs in the list This method distributes requests across the available JServ engines fairly evenly.
What is OracleJSP? singleThreadModelServlet.initialCapacity = 10 singleThreadModelServlet.incrementCapacity = 0 singleThreadModelServlet.maximumCapacity = 10 Warning: The value for singleThreadModelServlet.maximumCapacity in the zone properties file must be at least as large as the value for security.maxConnections in the jserv.properties file. If it is not, and the number of requests sent to the JServ process exceeds the maximum capacity, requests will fail. What is OracleJSP? OracleJSP 1.1.0.
OracleJSP Page Performance Tuning Developer Mode Another parameter that has a significant effect on performance is developer mode. It is a useful feature for debugging during development, but it degrades performance. The default value is true, so you will need to set it to false in the jserv.properties file as follows: servlet.oracle.jsp.JspServlet.
OracleJSP Page Performance Tuning Update statement batching The JDBC driver accumulates a number of execution requests (the batch value) and passes them to the database to be processed at the same time. You can configure the batch value to control how frequently processing occurs. JDBC statement caching Cache executable statements that are repeatedly used, to avoid re-parsing, statement object recreation, and recalculation of parameter size definitions.
Index A D Apache JServ Protocol 1.
jserv.conf, 2-8 jserv.properties, JSP, 5-8 5-4 L latency defined, 1-2 first-request, 5-3 network, 3-1 load balancing, 5-4 load variances, 1-8 logging, 4-10 M MaxClients concurrent users and, 3-2 configuring, 4-9 increasing, 2-6 memory usage, 3-4 mod_jserv, 5-2, 5-6 mod_status, 2-3, 2-7 monitoring CPU usage, 2-2 httpds processes, 2-4, 2-5 JServ processes, 2-8 server, 2-6 server side status, 2-3 server, automating, 2-6 mpstat, 2-2 O Oracle Internet Application Server 8i architecture, 1-10 oracle.jsp.
T think time defined, 1-2 resources and, 3-1 thread limit, 3-6 throughput defined, 1-2 demand limiter and, increasing, 1-4 1-6 U unit consumption, 1-6 uptime, 2-4 users, concurrent, 3-2 utilities sar, 2-2 W wait time contention and, 1-4 defined, 1-2 parallel processing and, 1-4 Z zone, defined, 5-3 zone.
Index-4