Over a million developers have joined DZone.
Platinum Partner

JMeter load testing against Apache Webserver: Errors and Resolutions

· Java Zone

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

have been working on a fairly simple JMeter load script that I can run a series of 4 sequential pages against an Apache server, but the goal was to have the server support 2,000 concurrent requests for 5 minutes without error.

Most of my issues in this exercise have been with JMeter and the client machine used to test the Apache server.

To begin, I must state I was originally configuring Apache with a prefork MPM:

StartServers        100
MinSpareServers      75
MaxSpareServers     100
ServerLimit        2000
MaxClients         2000
MaxRequestsPerChild   0

At approximately line 72 of Jmeter.bat, there are several entries the manage the JVM for running Jmeter.

set HEAP=-Xms512m -Xmx512m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m
set SURVIVOR=-XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=50%
set TENURING=-XX:MaxTenuringThreshold=2
set RMIGC=-Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000
set PERM=-XX:PermSize=64m -XX:MaxPermSize=64m

I decided to start with 1,000 concurrent requests for 5 minutes just to see how the test would fair.

With the above settings I started getting OOM errors almost immediately so I decided to increase the HEAP and NEW memory to eliminate the issue and wanted to add more GC settings to increase the JVM’s ability to clean up:

set HEAP=-Xms1024m -Xmx1024m -Xss128k
set NEW=-XX:NewSize=256m -XX:MaxNewSize=256m
set SURVIVOR=-XX:SurvivorRatio=14 -XX:TargetSurvivorRatio=50%
set "TENURING=-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:+DisableExplicitGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:MaxTenuringThreshold=4"
set "EVACUATION=-XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseCompressedStrings -XX:+OptimizeStringConcat"
set RMIGC=-Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000
set PERM=-XX:PermSize=64m -XX:MaxPermSize=64m

This did resolve the JMeter OOM issues, but now started getting Apache errors. During the ramp-up phase, I started getting connection refused errors:

Response code: Non HTTP response code: org.apache.http.conn.HttpHostConnectException
Response message: Non HTTP response message: Connection to http://pasundtastgprt2:8001 refused

I started looking at the Apache server and noticed that the number of httpd threads was at 1,000 and it appeared that JMeter was running out of memory because the requests where starting to back up.

This is why we load test right!

So I decided to run a worker MQM and recompiled Apache to support the new MPM

ServerLimit           80
StartServers          25
MaxClients          2000
MinSpareThreads       75
MaxSpareThreads      125
ThreadsPerChild        5
MaxRequestsPerChild    0

I started testing this configuration and while monitoring the server running 1,000 concurrent requests and the server looked like Apache was handling 1,000 requests just fine. I was running a simple command to output the sockets and httpd processes on the server during the load test:

while true
do
echo -----`date '+%r'` -----:
netstat -ant | awk '{print $6}' | sort | uniq -c | sort -n
echo httpd processes: [`ps aux | grep httpd | wc -l`]
echo .
sleep 30
done

Then when I was monitoring the load test, I was concerned about seeing 82 httpd processes running which was the ServerLimit I had set.

-----08:02:37 AM -----:
      1 established)
      1 Foreign
      4 CLOSE_WAIT
     17 LISTEN
     32 FIN_WAIT2
     41 ESTABLISHED
     69 FIN_WAIT1
    630 SYN_RECV
  45386 TIME_WAIT
[82] httpd processes
.

I now increased the load to my target of 2,000 concurrent requests and restarted the JMeter test and was able to get to around 1,800 concurrent request and started getting connection refused errors again.

I suspected that my Servers where maxed out and was not able to create anymore threads for those servers where having:

80 server * 5 threads each server == 400 requests processed concurrently

So I increased the number of threads to 25

80 server * 25 threads each server == 2,000 requests processed concurrently

To end up with this worker setting:

ServerLimit           80
StartServers          25
MaxClients          2000
MinSpareThreads       75
MaxSpareThreads      125
ThreadsPerChild       25
MaxRequestsPerChild    0

I was then able to turn the load up to 2,000 concurrent requests.

-----08:53:27 AM -----:
      1 established)
      1 FIN_WAIT2
      1 Foreign
      4 CLOSE_WAIT
     12 CLOSING
     17 LISTEN
    129 ESTABLISHED
    621 FIN_WAIT1
   1203 SYN_RECV
  55556 TIME_WAIT
[53] httpd processes

At this point we are only using 53 Servers and 2,000 clients. The tests sustained zero errors for 5 minutes during the test.

As a test I increased the ThreadsPerChild to 40 and run the load test against 3,000 concurrent requests.

I was able to get to around 2,800 concurrent requests then I started getting connection refused errors:

Error Count: 1
Response code: Non HTTP response code: org.apache.http.conn.HttpHostConnectException
Response message: Non HTTP response message: Connection to http://pasundtastgprt2:8001 refused

and I also started getting JMeter errors:

Response code: Non HTTP response code: java.net.BindException
Response message: Non HTTP response message: Address already in use: connect

So in the furure I would like to see how much further I can push the server and I think I can get to 3,000 concurrent and most likely far more than that on my current installation.

 

From http://www.baselogic.com/blog/development/adding-memory-jmeter/

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}