i'm trying to figure out how to use ApacheBench and benchmark my website. I installed the default site project (it's ASP.NET MVC but please don't put stop reading if u're not a .NET person).
I didn't change anything. Add new project. Set confuration to RELEASE. Run without Debug. (so it's in LIVE mode). Yes, this is with the built in webserver, not the production grade IIS or Apache or whatever.
So here's the results :-
C:\Temp>ab -n 1000 -c 1 http://localhost:50035/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: ASP.NET
Server Hostname: localhost
Server Port: 50035
Document Path: /
Document Length: 1204 bytes
Concurrency Level: 1
Time taken for tests: 2.371 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 1504000 bytes
HTML transferred: 1204000 bytes
Requests per second: 421.73 [#/sec] (mean)
Time per request: 2.371 [ms] (mean)
Time per request: 2.371 [ms] (mean, across all concurrent requests)
Transfer rate: 619.41 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.1 0 16
Processing: 0 2 5.5 0 16
Waiting: 0 2 5.1 0 16
Total: 0 2 5.6 0 16
Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 16
95% 16
98% 16
99% 16
100% 16 (longest request)
C:\Temp>
Now, i'm not sure exactly what I should be looking at.
Firstly, I after the number of requests a second. So if we have a requirement to handle 300 reqs/sec, then is this saying it handles and average of 421 req's a sec?
Secondly, what is the reason for adding more concurrent? As in, if i have 1000 hits on 1 concurrent, how does that differ to 500 on 2 concurrent? Is it to test if there's any code that blocks other requests?
Lastly, is there anything important I've missed from the results which I should take note of?
Thanks :)
what is the reason for adding more
concurrent? As in, if i have 1000 hits
on 1 concurrent, how does that differ
to 500 on 2 concurrent? Is it to test
if there's any code that blocks other
requests?
It's a bit about that, yes : your application is probably doing things where concurrency can bring troubles.
A couple of examples :
a page is trying to access a file -- locking it in the process ; it means if another page has to access the same file, it'll have to wait until the first page has finished working with it.
quite the same for database access : if one page is writing to a database, there is some kind of locking mecanisms (be it table-based, or row-based, or whatever, depending on your DBMS)
Testing with a concurrency of one is OK... As long as your website will never have more than one user at the same time ; which is quite not realistic, I hope for you.
You have to think about how many users will be on site at the same time, when it's in production -- and adjust the concurrency ; just remember that 5 users at the same time on your site doesn't mean you have to test with a concurrency of 5 with ab :
real users will wait a couple of seconds between each request (time to read the page, click on a link, ...)
ab doesn't wait at all : each time a page is loaded (ie, a request is finished), it launches another request !
Also, two other things :
ab only tests for one page -- real users will navigate on the whole website, which could cause concurrency problems you would not have while testing only one page
ab only loads one page : it doesn't request external resources (think CSS, images, JS, ...) ; which means you'll have lots of other requests, even if not realy costly, when your site is in production.
As a sidenote : you might want to take a look at other tools, which can do far more complete tests, like siege, Jmeter, or OpenSTA : ab is really nice when you want to measure if something you did is optimizing your page or not ; but if you want to simulate "real" usage of your site, those are far more adapted.
Yes, if you want to know how many requests per second your site is able to serve, look at the "Requests per second" line.
In your case it's really quite simple since you ran ab with concurrency of 1. Each request, on average took only 2.371ms. 421 of those, one after the other, take 1 second.
You really should play with the concurrency a little bit, to accurately gauge the capacity of your site.
Up to a certain degree of concurrency you'd expect the throughput to increase, as multiple requests get handled in parallel by IIS.
E.g. if your server has multiple CPUs/cores. Also if a page relies on external IO (middle tier service, or DB calls) the cpu can work on one request, while another is waiting for IO to complete.
At a certain point requests/sec will level off, with increasing concurrency, and you'll see latency increase. Increase concurrency even more and you'll see your throughput (req/sec) decrease, as the server has to devote more resources to juggling all these concurrent requests.
All that said, the majority of your requests return in about 2ms. That's pretty darn fast, so I am guessing there is not much going on in terms of DB or middle tier calls, and your system is probably maxed out on cpu when the test is running (or something is wrong, and failing really fast. Are you sure ab gets the response page you intend it to? I.e. is the page you think you are testing 1204 bytes large?).
Which brings up another point: ab itself consumes cpu too, especially once you up the concurrency. So you want to run ab on another machine.
Also, should your site make external calls to middle tier services or DBs, you want to adjust your machine.config to optimize the number of threads IIS allocates:http://support.microsoft.com/default.aspx?scid=kb;en-us;821268
And just a little trivia: the time taken statistics is done in increments of ~16ms, as that appears to be the granularity of the timer used. I.e. 80% of your responses did not take 0ms, they took some time <16ms.
Related
I am working with 1 master, 50 slaves. Number of threads: 20
I have 1 thread and there are 3 samples in it. I'm starting the tests, but as a result of the test, I see that you are going 500-700 requests.
1000 requests from each should go. But it doesn't go.
You have 20*50=1000 threads in total.
You can reach 1000 requests per second only if response time is 1 second sharp.
If response time will be 0.5 seconds - you will get 2000 requests per second
If response time will be 2 seconds - you will get 500 requests per second.
If you need to simulate X requests per second you need to add more threads (or alternatively go for Concurrency Thread Group and Throughput Shaping Timer combination)
But remember that the application under test must be able to respond fast enough because if it doesn't - any JMeter tweaks won't make any difference.
By the way, 1000 requests can be simulated from a modern mid-range laptop without any issues (unless your requests are "very heavy"), just make sure to follow JMeter Best Practices
I've configured my jmeter as can be seen in the screen shot below-
However, when I examine the logs I can see that we only got to a rate of 37 requests per second as can be seen in the logs:
2021-10-18 03:20:30,005 INFO o.a.j.r.Summariser: summary = 3510096 in 26:26:03 = 36.9/s Avg: 67 Min: 16 Max: 69589 Err: 61 (0.00%)
Am I missing something? How can I increase the rate?
What rate is "expected"?
1 user will generate 1 hit per second only if application response time will be 1000 milliseconds.
If response time will be 2000 milliseconds you will have 0.5 requests per second
If response time will be 500 milliseconds you will have 2 requests per second.
There could be 2 explanations for the throughput lower than expected:
JMeter cannot send requests fast enough the reasons are in:
The number of virtual users is too low, just increase the number of threads in the Thread Group
JMeter cannot send requests fast enough because it's overloaded. Make sure to follow JMeter Best Practice and if it's still the case consider going for Distributed Testing
Your application cannot respond fast enough. In your case I can see response times as high as 69589 milliseconds so most probably that is the reason, you need to ensure that the application has enough headroom to operate in terms of CPU, RAM, etc. using an APM tool, check its logs, check its configuration, perform code profiling, etc.
I am doing API load testing by sending 250 requests at once.
1. Configuration
Naturally, server takes longer to respond when a lot of users requests it simultaneously, this is what it says here.. As per http://jmeter-plugins.org/wiki/ResponseTimesVsThreads/. However when testing this is what I found..
2. Test
The plot above starts from right to left and as the number of active threads decrease, the response time increases.
Is active threads same as number of user requests, if so why this is happening on a consistent basis?
Update-1
Ran another test and increased the ramp-up period this time
No of threads: 200
Ramp-Up Period: 200 secs
Loop Count: 200
There are at least 2 possible explanations:
you don't have a problem, and your improvement in response times comes from caching effect related to your data being in cache after some time. Only you can validate as we don't know if you are using a large enough dataset and how long is your test lasting
you have a problem, your server is rejecting connections under load, so you have very rapid failed responses that have a very good response time. To know if it's your problem, check the response code over time or transactions over time as long as error percentage
I am analyzing a web application and want to predict the maximum users that application can support. Now i have the below numbers out of my load test execution
1. Response Time
2. Throughput
3. CPU
I have the application use case SLA
Response Time - 4 Secs
CPU - 65%
When i execute load test of 10 concurrent users (without Think Time) for a particular use case the average response time reaches 3.5 Seconds and CPU touches 50%. Next I execute load test of 20 concurrent users and response time reaches 6 seconds and CPU 70% thus surpassing the SLA.
The application server configuration is 4 core 7 GB RAM.
Going by the data does this suggests that the web application can support only 10 user at a time? Is there any formula or procedure which can suggest what is the maximum users the application can support.
TIA
"Concurrent users" is not a meaningful measurement, unless you also model "think time" and a couple of other things.
Think about the case of people reading books on a Kindle. An average reader will turn the page every 60 seconds, sending a little ping to a central server. If the system can support 10,000 of those pings per second, how many "concurrent users" is that? About 10,000 * 60, or 600,000. Now imagine that people read faster, turning pages every 30 seconds. The same system will only be able to support half as many "concurrent users". Now imagine a game like Halo online. Each user will be emitting multiple transactions / requests per second. In other words, user behavior matters a lot, and you can't control it. You can only model it.
So, for your application, you have to make a reasonable guess at the "think time" between requests, and add that to your benchmark. Only then will you start to approach a reasonable simulation. Other things to think about are session time, variability, time of day, etc.
Chapter 4 of the "Mature Optimization Handbook" discusses a lot of these issues: http://carlos.bueno.org/optimization/mature-optimization.pdf
I am going to set up some load testing test with jmeter.
However, I can't find on the net what is a good bench mark.
How good is good?
My site hit is about 80,000/day on average.
After mining out some data from access log for 1 month, I manage to find out:
Average low traffic is about 1 requests / sec
Average Medium traffic of 30 requests / sec
Average High traffic of 60 requests / sec
I came out with the following plans to test 8 kind of pages and it's ideal respective average response time on a single page load :
Page 1 - 409ms
Page 2 - 730ms
Page 3 - 1412ms
Page 4 - 1811ms
Page 5 - 853
Page 6 - 657ms
Page 7 - 10ms
Page 8 - 180ms
Simulate average traffic scenario - 10 requests / second test
Simulated Users: 10 threads
Ramp Period: 1 sec
Duration: 30 min
Simulate medium traffic scenario - 30 requests / second test
Simulated Users: 30 threads
Ramp Period: 1 sec
Duration: 30 min
Simulate super high traffic scenario - 100 requests / second test
Simulated Users: 100 threads
Ramp Period: 1 sec
Duration: 30 min
Simulate an attack scenario - 350 requests / sec (based on MYSQL max connection of 500)
Simulated Users: 100 threads
Ramp Period: 1 sec
Duration: 10 min
While running these test, I plan to monitor the following:
CPU Load average: (Webserver)
CPU Load average: (DB Server)
RAM Load average:
RAM Load average: (DB Server)
Average Response time:
To see how much it's its memory and cpu utilisation and if there's a need to increase RAM, CPU etc... Also I capped MySQL Max connection at 500.
In all testing, I expect response time should be ideally below a capped benchmark of 10secs.
How does this sound? I've no SLA to follow, this is just based on research on current web traffic and coming out with the plan. The thing is I don't know how what is the threshold of the server. I believe with the hardware below it should already exceed what's needed for hosting our pages.
Webserver is running: 8GB RAM, 4 Core ( 1 server, another cold backup server No load balancer )
MySQL Server is running: 4GB RAM , 2 Core.
We are planning to move to cloud so ideally need to find out what kind of instance best fit our scenario through this load testing as well.
Would really appreciate any good advice here..
Read about SLA
I recommend you to determine your requirements of web-site performance. But by default you can use "standard" response time limit about 10sec.
Next, find user activity profile during day, week, month. Then you could choose base values of load for each profile.
Find most frequent and most "heavy" user actions. Create test scenario with this actions (remember about percent ratio of actions, don't use all actions with one frequency).
Limit load by throughput timer (set needed value of hits per minute). Number of threads in thread group select experimentally (for http load not needed many of them).
Add plugins for jmeter from google-code. Use graphs "number of threads in second", "response time" and standard listener "summary report". Don't use standard graphs with high load, it's too slow. You can also save data to file from each listener (I strongly recommend this, and select csv format). Graphs show average points, so if you want precision pictures then build graphs manually in excel or calc. Grab performance metrics from server (CPU, memory, i/o, DB, net interface).
Set ramp up period about 20-60 minutes and test about 1-2 hours. If all right, then test with 200% load profile or more to find the best performance. Also set test about 1-2 days. So you'll see server stability.