Today I was searching for a tool to test the perfomance of two different webservers I have running. One is a cheap VPS running the OpenLiteSpeed webserver and hosting a wordpress instance. The other is my "homelab" which is running a docker instance of the Ghost blogging platform.
I wanted to know how both of these servers were handling big amounts of concurrent users/requests. But how do you get 10.000 (virtual) users on your webpage?
There are some online service providing these kind benchmarks for your website (e.g. flood.io). But since this is just my personal blog I didnt want to ceate any accounts or pay any money for this. This is just an personal experiment.
The software I am using for this is "ab - Apache Benchmark".
ab
is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.
Installing Apache Benchmark
You can install ab on most Ubuntu/Debian versions like this:
sudo apt-get update
sudo apt-get install apache2-utils
On CentOSv6/7 Apache benchmark is part of the "httpd-tools"-package. You can check this with the following command:
sudo yum provides /usr/bin/ab
And install it like this...
sudo yum updapte
sudo yum install httpd-tools
Using Apache Benchmark
After successfull installation Apache Benchmark is called by "ab". There is a long man-page describing all the possibilities with this command. The general format looks like this.
ab [options] URL
Interesting Options (not all)
-c Numeber of concurrent requests (Default 1)
-e Write to CSV file
-f Specifiy protocol
-n Number of total requests
Word of caution: Using this tool on public websites could lead to a potential IP block because of DDOS attack detection. (I personally had problems using my VPS for this.)
Here we go! I run this command from a seperate vps, to test this blog which is running on a different VPS. I just supply ab with the number of total requests (-n 1000) and the number of concurrent requests (-c 100).
fred@server:~$ ab -n 1000 -c 100 http://blog.odenthal.cc/
While this command runs it is a good idea to have some monitoring tools open on the target machine. A simple one would be htop. Even better would something like netdata. With netdata you can monitor all the different statistics which a relevant in this kind of test. (eg. CPU, Load, Network,...)
Results:
Apache Benchmark presents you the results in any easy to read table like this.
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking blog.odenthal.cc (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software:
Server Hostname: blog.odenthal.cc
Server Port: 80
Document Path: /
Document Length: 59 bytes
Concurrency Level: 1000
Time taken for tests: 15.953 seconds
Complete requests: 10000
Failed requests: 7
(Connect: 0, Receive: 0, Length: 7, Exceptions: 0)
Non-2xx responses: 9993
Total transferred: 2448285 bytes
HTML transferred: 589587 bytes
Requests per second: 626.83 [#/sec] (mean)
Time per request: 1595.320 [ms] (mean)
Time per request: 1.595 [ms] (mean, across all concurrent requests)
Transfer rate: 149.87 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 221 603.6 101 10256
Processing: 27 240 531.4 102 12961
Waiting: 1 175 404.1 101 10719
Total: 68 461 854.8 206 13089
Percentage of the requests served within a certain time (ms)
50% 206
66% 217
75% 223
80% 297
90% 911
95% 1634
98% 3381
99% 4867
100% 13089 (longest request)
Performance figures for 1000 concurrent requests (100000 total) on my 4-core J3455-ITX board.
- the 1minute load average jumped to max 1.95
- The CPU utilization was around 55 %
- memory consumption didnt change much
- network traffic was at around 10 mbit/s
Other tools for benchmarking your website, which are worth checking out are:
- Tsung (multi protocol)
- gobench (intersting above 20.000 concurrent users)
- Apache JMeter (Java GUI)
- SIEGE