Appearance
Heavy Load Testing
Introduction
Load testing is a good idea before any deployment. It’s nice to quickly establish a best-case scenario for a project before running more detailed tests down the road.
Apache Bench (ab) is a common tool for measuring the performance of HTTP servers in a Linux environment. t works by generating a flood of requests to a given URL and returns some easily digestible performance related metrics to the screen.
ab (and other similar tools) can help to answer the following questions:
- Which implementation of action is faster?
- What is my application’s average response time at a large number of simultaneous users or connections?
- What is the maximum number of requests-per-second that my application can handle?
- At what point will my application break?
Installation
On Debian-like linux:
bash
apt-get install apache2-utilsTesting
We used 1000 requests with a concurrency of 100:
bash
ab -n 1000 -c 100 http://localhost:8000/notifier/pixelIt will then generate output as follows:
text
Server Software: nginx/1.13.3
Server Hostname: localhost:8000
Server Port: 80
Document Path: /notifier/pixel
Document Length: 43 bytes
Concurrency Level: 100
Time taken for tests: 425.669 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 626044 bytes
HTML transferred: 43000 bytes
Requests per second: 2.35 [#/sec] (mean)
Time per request: 42566.931 [ms] (mean)
Time per request: 425.669 [ms] (mean, across all concurrent requests)
Transfer rate: 1.44 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 2
Processing: 1749 40616 7815.9 42238 49851
Waiting: 1749 40616 7815.9 42238 49850
Total: 1751 40616 7815.7 42238 49851
Percentage of the requests served within a certain time (ms)
50% 42238
66% 42689
75% 43164
80% 43687
90% 45834
95% 48327
98% 48847
99% 49164
100% 49851 (longest request)Note that result from your env will be different with results from develop or product servers.
Authentication
You can also use Apache Bench to benchmark a website where the authentication is based on session. All you need is to get a cookie value before the test.
bash
ab -n 40 -c 20 -C laravel_session=COOKIE_VALUE http://localhost:8000/adminTo pass basic HTTP authentication, you need to use -A attribute:
bash
ab -n 1000 -c 100 -A login:pass https://staging.ixdf.devConclusion
Obviously, these results do not reflect realistic server performance. HTTP is just one piece of the puzzle. A slow templating engine and/or database will drag these numbers down significantly. Still, it gives you a quick ballpark figure for comparison.