I 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
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

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
     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
    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 hoe 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.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting. http://www.baselogic.com/blog/resume

View all posts
  • Krishna

    Hi Mick:
    Thanks for the details on Apache optimization. I have the same issue happening except that we are seeing it in Production and not in any of the Perf Environments.

    The Exception says:
    org.apache.http.conn.HttpHostConnectException: Connection to https://www.test.com refused
    The web Apache configuration that we have is
    <IfModule worker.c>
    StartServers 10
    ServerLimit 20
    MaxClients 500
    MinSpareThreads 250
    MaxSpareThreads 500
    ThreadsPerChild 25
    MaxRequestsPerChild 0

    when I check the httpd worker threads in the server, it always shows me 27 threads. It never goes above this limit. But we do have a different application with the same Apache configuration that spawn more worker threads than this. When I was checking it spawn upto 34 threads. Why is this difference. Please let me know by changing any of the settings above will resolve this issue. We see close to 400 logged in users for this site at any given time.
    Your help is much appreciated in this regard.

    • I cannot access https://www.test.com which makes me think HTTP is exposed and can take traffic, but HTTPS cannot and is not taking traffic. You might need to look at the virtual host to see if port 443 is open on your server.

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense