Stress-test your PHP App with ApacheBench

Posted by Unknown on Tuesday, June 24, 2014

This article was sponsored by New Relic. Thank you for supporting the sponsors that make SitePoint possible!


There’s no telling when your app might attract a throng of visitors at once - maybe it’s a Hacker News post that’s submitted at a specific second on a specific time of day (as posts there tend to work), maybe it was a particularly well placed Reddit post, and maybe it’s actually good and people noticed it, spreading it virally. Regardless of the reason, massive influxes of visitors are a double-edged sword: they get you what you always wanted - a chance to prove your worth to a large chunk of the internet’s population - but also often bring with them what you always feared: absolute downtime.


There are several ways to try and prevent this - among the most prevalent is deploying your application on a service like Amazon, Google App Engine or Heroku which have the ability to not only scale out and in rapidly at your command, but also support automatic scaling, if you’re not afraid of DDoS attacks also scaling your bills while you’re asleep. These platforms usually offer plugins that can optimize your application while it’s up, so you can fine tune it as you go along, but why not try and predict issues while still developing locally and save yourself time, money and effort in the long run?


Apache Benchmark


ApacheBench (also known as “ab”, the command you run it with) is a tool designed to nuke an endpoint with requests and load-test web servers. It supports a wide array of parameters and options you can tweak to simulate different loads, like number of requests, number of concurrent requests, extra headers, falsified cookies, and more.


ab is often included with every Apache installation, but if not, you can easily install it by running sudo apt-get install apache2-utils. The current version of Laravel Homestead doesn’t have it, so if you’re following along please install it into that VM when you vagrant up and connect through SSH.


Continue reading %Stress-test your PHP App with ApacheBench%




more

{ 0 comments... » Stress-test your PHP App with ApacheBench read them below or add one }

Post a Comment

Popular Posts