Micro Benchmarking Your ASP.Net Pages Using Apache Bench
Join the DZone community and get the full member experience.
Join For Free
image: martin heigan
tooling tooling everywhere…
if you’re developing asp.net websites and web services you’ve probably turned to a few different options to performance test your pages and web services.
you may be lucky and happen to own a copy of visual studio ultimate and have had a play with the performance and stress testing tooling that comes along with it.
in the non-microsoft tooling world i’ve used a few tools such as load ui and soap ui for a number of projects successfully. there are many many commercial products that do similar jobs.
but a lot of these tools sometimes actually don’t make it really clear how to get answers to some simple questions that both we and our clients often want to know.
simple questions like:
“how many users can my application take at once?”
or other gems that you might like to know;
“how long does my page take to execute? how long does it take when 100 visitors are using it at the same time?”
info for nothing, and the tests for free…
when you install apache you get a whole heap of tools along with it. we normally think of apache as a linux/unix web server, but there is a windows version that contains all the same power.
one of the included tools that comes with apache is the performance testing tool apache bench .
apache bench is a really powerful and simple command line tool for performance testing and gathering metrics on how your application pages respond under load. it does this with very little cpu usage and a very small memory footprint, allowing you to run it on hardware that has lower spec than a lot of the commercial tools around. this makes it great if you want to use old machines on your network to run testing concurrently form different network addresses.
apache bench allows you to simulate a defined number of requests at a time for a set amount of total requests and view results on how your pages respond.
this allows us to do the following:
- test a page with 10 users at a time for 1,000 requests
- test a page with 50 users at a time for 10,000 requests
- test a page with 100 users at a time for 100,000 requests
- etc.
- etc.
do the above for 1 minutes, 5 minutes…
and get response times; failure rates; requests a second; transfer rates for each level of user load.
actually get data that can help you estimate how your application will function once it goes live.
for free.
warning
this is not a “this is how you should perform tests on your website to become invincible”. there are plenty of blog posts and articles out there to get you strategies an approaches on how to do this. this post is however a guide to doing basic micro-benchmarking on individual pages during development to test performance in ways that you won’t be able to do on your dev machine without other software.performance testing and website load generators such as apache bench can be dangerous things in shared hosting environments and without your webhosts knowledge, so please take precautions before testing on other peoples sites or hardware.
performance testing - thinking it through
as web applications use networking bandwidth, you need to take this into account when deciding how you are going to be doing your testing.
are you testing just your application? or are you testing your application and your server’s internet bandwidth? (and your test machine’s bandwidth…)
if you want to know how your application responds independent of the internet, you should test from a machine that is on the same internal network as your webserver to ensure that your internet pipe is not the bottleneck in testing. this will give you upper bounds on your application, but will not give you the full picture for launch day.
if you want to also test the internet link that your server is serving through (i.e. the real-world), run your tests from machines outside your server’s internal network – somewhere on the internet.
maybe an amazon ec2 instance? (if so use the linux apache binaries – linux instances of ec2 are cheaper…)
i do suggest you do this with your isp’s knowledge and only when you are running dedicated servers – otherwise you may become a willing participant in a dos attack against your web host, and also take the other sites on your box down at the same time from the performance hit.
making it all happen
download the xampp zip file .
in the bin folder of the zip file extract the file ab.exe into a location on the machine you will be running your tests from so that you can easily get to it.
for the point of this demo i've placed mine in “ c:\testing\ ”.
on the machine you will be testing from open a command prompt window and move into the above created directory (enter “ cd c:\testing\ ”).
now we will start by issuing 1,000 requests from 5 concurrent clients at the same time.
the –n is the number of requests to process (we want this to be a high enough number that the tests run for a minimum amount of time (a minute or 30 seconds should give you an idea on numbers)
the –c is the amount of concurrent requests to run. this is the equivalent of a number of people hitting your site at the same time.
Published at DZone with permission of Douglas Rathbone, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Writing a Vector Database in a Week in Rust
-
Unlocking the Power of AIOps: Enhancing DevOps With Intelligent Automation for Optimized IT Operations
-
Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
-
The SPACE Framework for Developer Productivity
Comments