john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Load Testing with Apache Benchmark AB

[TOC]

Load Testing is a general term that usually falls into the categories of:

  • Stress testing (at what threshold does a system break)
  • Latency Testing (how quickly does the system respond) - sometimes also called Perf Testing
  • Benchmark Testing (how quickly system performs using a standard such that it can be compared to other such tests)
  • Load/Performance Testing (how much work a system can do and how does the system perform under load - usually revealing bottlenecks)

hack load testing with bash and curl

watch -n1 'curl --silent http://example.com > /dev/null'

every second curl a site

for i in {1..5}; do curl --silent http://example.com > /dev/null & done

startup curl in 5 backgrounded processes

Apache Benchmark AB Installation

ab , also known as "apache benchmark", is a simple tool for benchmarking apache webserver.

This is a simple starting point for saturating a specific URL but it will not retrieve all of the assets of a page (i.e. css, javascript, etc.)

/etc/apt/sources.list

In case you don't have an ubuntu box with stock upstream repositories ;)

deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse



apt-get update
apt-get install apache2-utils
ab -h
ab -V

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>

actually running ab

ab -l -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://www.example.com/

https://httpd.apache.org/docs/2.4/programs/ab.html

-c 1 would set it to a single concurrent user repeatedly requesting the site if you remove the -H header about gzip you'll force the server to do unnecessary work

JMeter

http://jmeter.apache.org/

While JMeter is a fine full featured open source tool for load testing it has a steep learning curve and requires the JVM.


  • « php function get ip address

Published

Jul 21, 2016

Category

linux

~304 words

Tags

  • ab 1
  • apache 13
  • linux 249
  • load testing 1