Apache Ab Benchmark

Posted on  by admin

ApacheBench (ab) is a single-threaded command line computer program for measuring the performance of HTTPweb servers.[1] Originally designed to test the Apache HTTP Server, it is generic enough to test any web server.

The ab tool comes bundled with the standard Apache source distribution, and like the Apache web server itself, is free, open source software and distributed under the terms of the Apache License.

The rather heavy use of strstr(3) shows up top in profile, which might indicate a performance problem; i.e., you would measure the ab performance rather than the server's. Apache HTTP Server 2013-01-09 AB(1).

Apache Bench 是 Apache 服务器的一个web压力测试工具,简称ab(是的,你没有听错,我当初也以为是Angelababy来着)。 ab也是一个命令行工具,对发起负载的本机要求很低,根据ab命令可以创建很多的并发访问线程,模拟多个访问者同时对某一个URL地址进行访问,因此. ApacheBench (ab) is a very handy webserver benchmarking tool which can be run from command line. It is extremely simple to use. A quick outcome can be obtained in just one minute. It does not require too much much familiarity with load and performance testing concepts. ApacheBench standalone - an Apache HTTP Server benchmark tool, known as 'ab' - ShiFengAway/ab.

Example usage[edit]

This will execute 100 HTTP GET requests, processing up to 10 requests concurrently, to the specified URL, in this example, 'http://en.wikipedia.org/wiki/Main_Page'.[2]

Concurrency versus threads[edit]

Note that ApacheBench will only use one operating system thread regardless of the concurrency level (specified by the -c parameter). In some cases, especially when benchmarking high-capacity servers, a single instance of ApacheBench can itself be a bottleneck. When using ApacheBench on hardware with multiple processor cores, additional instances of ApacheBench may be used in parallel to more fully saturate the target URL.

Detecting ApacheBench[edit]

The ApacheBench User Agent string is ApacheBench/MAJOR.MINOR where MAJOR and MINOR represent the major and minor version numbers of the program.[3] It is usually not correctly categorised by web server log analysers such as Webalizer or AWStats, so running ApacheBench with a great number of requests may skew the results of the reports generated by these programs.

See also[edit]

References[edit]

  1. ^'ab - Apache HTTP server benchmarking tool'. Apache. Retrieved 9 October 2014.CS1 maint: discouraged parameter (link)
  2. ^'Using Apache Bench for Simple Load Testing'. Pete Freitag's ColdFusion, Java and Web Development Blog. Retrieved 9 October 2014.CS1 maint: discouraged parameter (link)
  3. ^'Useragent detail: AB (Apache Bench)'. User-Agent-String-Info. Retrieved 9 October 2014.CS1 maint: discouraged parameter (link)

External links[edit]


Apache
Retrieved from 'https://en.wikipedia.org/w/index.php?title=ApacheBench&oldid=957645671'

Tutorial

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.

The ApacheBench tool (ab) can load test servers by sending an arbitrary number of concurrent requests. Although ab was designed for testing Apache installations, it can be used to benchmark any HTTP server.

In this tutorial, we will see how a Ruby interpreter with different servers performs under load. The tutorial steps assume a fresh Ubuntu 13.10 x32 image. The results were obtained from a 512 MB droplet.

Installation

Refresh the package database.

Install the apache2-utils package to get access to ApacheBench.

Limited Privilege User

Benchmark

Next, create the user that will manage Ruby. It’s not a good idea to run some of the commands in the next section as root.

Ab Apache Benchmark Ssl

What this command accomplishes:

  • useradd - create a new user

  • -m - create the home directory

  • -d /home/test - set the user’s home directory to /home/test

  • -s /bin/bash - make the user’s default shell bash (Ubuntu uses dash by default)

  • -g sudo - add user to the sudo group (for running commands with sudo)

  • test - the name of the new user

Set the password for the new user.

Switch to the new user.

RVM

The Ruby Version Manager makes it easy to work with different Ruby environments. It takes care of the process of installing specific Ruby versions and isolating gemsets. It is currently installed by running a bash script from their website.

In order to use the rvm command, you need to first run the rvm script.

If you want, you can put it in your .bashrc so that rvm is available any time you login as the user.

You can verify that the rvm script is being used by checking the head of type. It should be a function and not hashed.

Next, install Ruby 2.0.0. RVM will ask for the user’s password because it needs to install an assortment of dependencies before it can make Ruby. Since RVM builds Ruby from source, this step may take a while.

Apache

Ab Apache Benchmark Download

Switch to the new Ruby. This might happen by default after the installation, but checking doesn’t hurt.

Testing

Now that Ruby is installed, you can create a simple site and see how many requests it can handle.

Install Sinatra. It’s a microframework/DSL for creating Ruby web applications. The –no-* flags skip the documentation.

Create the sample sinatra app which just echoes “hello world”.

Run the server.

With the server finally up, you can start load testing. A call to ab looks like this:

Benchmark

Open another terminal and ssh into the server again. Run a test with ApacheBench. I used 1000 requests with a concurrency of 100. Don’t forget the final ’/’ for the path.

My results converged around 300 requests/second. WEBrick is not known for its speed. Go ahead and interrupt the server with Ctrl-c.

Install Thin

Thin is a popular ruby web server that uses Mongrel for parsing and EventMachine for non-blocking IO. Install Thin and run the server again. Sinatra should load Thin automatically and let you know (“…with backup from Thin”).

Now, try the load test again. It should be a bit faster this time.

At least in this case, it looks like Thin makes for a notably faster server than WEBrick at over 700 requests/second (You can try raising the total requests, but it didn’t get much higher for me).

Note: I was able to get 1000 requests/second on an Arch Linux droplet.

Conclusion

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.

Other performance tools you might be interested in:

<div class=“author”>Submitted by: <a href=“http://robertqualls.com”>Robert Qualls</a></div>