The sections of this tutorial are as follows:
ApacheBench, also known as 'ab', is a command line program bundled with the Apache Web Server that measures the performance of web servers by making HTTP requests to a user-specified URL. ApacheBench displays statistical information, such as the number of requests served per second and the amount of time taken to serve those requests, that is useful for evaluating (benchmarking) and tuning the performance of a webserver. ApacheBench does a decent job of simulating different types and levels of load on a sever.
Many Drupal websites make use of Drupal's core caching functionality, which typically improves performance for anonymous users (users who are not-logged in) by a factor of 10 times, measured in requests served per second. The cache system achieves this performance improvement by storing the results of certain database queries in designated cache tables, allowing Drupal to avoid repeating expensive or frequently run database queries. Drupal does not cache page content for authenticated users because Drupal's permissions system (and node_access restrictions) can show different content depending on a user's role and because some elements of the page are user-specific. Since authenticated users are typically served non-cached pages, requests served to them are more resource intensive and therefore take longer to conduct than requests served to anonymous users.
By default, ApacheBench requests pages as one or multiple concurrent anonymous users. Benchmarks of performance for anonymous users can be useful for a website that most users will access anonymously, but these data do not accurately describe the performance of websites that serve a significant percentage of their total pages served to authenticated users (as most community sites tend to do). By providing the Drupal session cookie information, ApacheBench can perform benchmarking tests as an authenticated Drupal user.
Note: These instructions are for the Mozilla Firefox browser.
1)Log into your Drupal installation using the account that you'd like ApacheBench to use when conducting its tests.
2)Open the Firefox preferences menu and browse to the 'Privacy' Tab
3)Click the 'Show Cookies' button
4)Browse the list of sites to find the site that you have just logged into.
5)Highlight the cookie associated with your site that has a 'Cookie Name' value beginning with 'SESS'. There should be only one of these cookies. If you have two cookies with names beginning with 'SESS' for the same Drupal website, you should clear both of these cookies (which will log you out of your Drupal site) and log back in to ensure that you are specifying the correct cookie in ApacheBench.
6)You'll see that your site's SESS cookie has both 'Name' and 'Content' values. You're going to copy each of these values individually and pass them inside of a command line parameter to ab. Note: Do not log out of your Drupal site before testing with ab, as doing so will invalidate the cookie information you have just copied!
The 'C' parameter is used with ApacheBench to specify a cookie. This parameter is case sensitive, and should not be confused with 'c' (lowercase) which specifies the number of concurrent requests ApacheBench will make. You'll describe your site's cookie using the following format:
-C 'NAME=CONTENT'
There is no space between the equals sign. Below is a completed example specifying that 400 requests will be made (-n 400) with 10 simultaneous requests (-c 10):
ab -n 400 -c 10 -C 'SESS5a2cb35dfce80bc682796cc451440ac0=d45b85c5be4c651ea2ad520947082e04' http://example.com/
It's important to verify that Drupal recognizes and accepts the cookie that corresponds to your session. Once, while performing a set of ab authenticated Drupal user benchmarks, I adjusted a Drupal cache setting that increased the number of requests served per second for authenticated users from 5 to 60. I thought, “Wow! I've made an enormous improvement!” What I had actually done was switched from Drupal core session handling to Memcahe's session handling, which caused Drupal to not recognize my cookie. Drupal was actually serving anonymous pages, which accounted for the dramatic “performance improvement.” To avoid misunderstandings like this one, we'll use ApacheBench's verbose mode to confirm that Drupal is serving authenticated pages.
In our theme directory, we'll add a PHP snippet to page.tpl.php below the HEAD tag, that will print, inside an HTML comment tag, the username and uid (user id) of the user currently viewing the page.
<?php global $user; print 'This is user: '. $user->name .' : UID:'. $user->uid; ?>
Then, we'll run ApacheBench with a verbosity level of 4 (parameter -v4), allowing us to view the HTTP response code and html that the server is sending to ab.
Viewing the content of pages served to ab is also useful in determining the nature of failed responses and investigating suspiciously high numbers of requests served per second. Apache identifies certain types of failed requests by serving them with an unsuccessful (non-200) HTTP response code. (For more about HTTP response codes\status codes, see the W3's "Status Code Definitions" .) ApacheBench recognizes HTTP response codes and reports the number of responses that are marked as successful and unsuccessful by Apache. A reportedly high number of requests successfully served per second can indicate good server performance, but it's important to distinguish pages served with a 200 response code from those that are truly served successfully. In some situations, Apache is unaware of serious problems that occur in other parts of the server stack and will serve pages with an HTTP response code of 200 (successful) despite the fact these pages contain only a PHP fatal error. In these cases, Apache is “successfully” serving the PHP fatal error message.
Drupal correctly specifies non-200 HTTP response codes when it is unable to connect to the database. Viewing the content of the benchmarked page allows the person performing the testing to view the specific error message that the site is displaying. This is useful in identifying that the problem is, for example, that the MySQL max_user_connections value has been reached, as opposed to other database connection errors, such as an Access Denied error.
It's worth noting that while ab provides useful information about a server's performance, that it does not predict exactly how a server will perform under load from actual users.
Questions? Comments? Corrections? I'm happy to hear from you.
Hey Ezra, good tutorial and
Hey Ezra, good tutorial and grats on the Planet inclusion.
This is a fantastic website
This is a fantastic website and I can not recommend you guys enough. Full of useful resource and great layout very easy on the eyes. Please do keep up this great work. gallstones
Good Job
I have bookmarked it in my google bookmarks.
___________________
Justin Bieber
Nice article
I am quite excited with all the article content of your site. It would be my pleasure to gather some more strategies from your web-site and come up to offer people what I have benefited from you.
Unrelated to the article...
Sorry to comment only to say something unrelated to the article, but I wanted to offer up a tip and feel free to delete this comment afterwards. ; )
It would be helpful if you included a synopsis of the article and used a <!--break--> tag when making posts through Drupal Planet so we can quickly scan the intro and then come to the article if it's something that we need/interests us. Just helps for digesting a lot of info and keeps the page trim.
Per Ryan's Suggestion
Per Ryan's suggestion I've changed my Planet feed to output teasers for everyone's convenience. Thanks!
Really nice and useful
Really nice and useful tutorial.
I always used ab as Anonymous User, newer tested performance for Authenticated Users.
Thanks.
A different approach
Instead of the manual steps, I wrote a script to automate the generation and even the running of the ab commands.
Using ApacheBench for benchmarking logged users - an automated approach
Wow, thanks. I never know
Wow, thanks. I never know that ab can handle cookies. But I always do ab without cookies, because more 90% of users are unregistered.
Thanks so much for this! I
Thanks so much for this! I am in the process of setting up a server here at home, and this is precisely what I needed to find! Thanks!
software
Thank you for another essential article.Where else could anyone get that kind of information in such a complete way of writing?
I have a presentation incoming week, and I am on the lookout for such information.
buy iPad
interested with commnts
Hi Jon, im interested with your presentations. can i see it too, i'm willing take a fake doctors note for it.
Cheers
Karmaloop Coupons - Karmaloop Rep Code and Promo Codes for Karma
When we do every thing.We r go to out side.Then you look this side. karmaloop rep code
Great blog and very good written also.
Great blog and very good written also.it helps clear up some questions I had. thank you. success.
name necklace
Could I use Drupal to improve my site?
I am a noob that does not know much about building sites. I have a website that I am developing for a friend and I am currently using WP. I was thinking that Drupal would give me more options and allow me to build a better site. If anyone can take a look and make some suggestions that would be awesome. The site is: http://learningtoplay-guitar.net
see what I mean
See I can't even post a normal link. Sorry, here goes another attempt. The site is learning to play guitar
It is very useful for me. Thank you so much for sharing.
It is very useful for me. Thank you so much for sharing. Keep your great post.
sydney layers
thank you! Awesome!
Thank you so much for writing this. I`ve learned what I was looking for.
Thanks again!
email direct marketing tool
Targeted Direct Email Marketing
sähkön hinta
It is very useful for me.
It is very useful for me. Thank you so much for sharing. Keep your great post.
carpets sheffield
For Marketing
This blog really satisfied me much because of containing rich information about Drupal Users and Website. Before reading the article I had a little conception about this subject. That’s why I can’t but thank the article writer for the pompous article and also the owner of this site.
evenimentul
Finally I found it!!!
Finally I found it!!! Great!
candice olson lighting
Nice article
Here I found your blog to be very worthwhile. I am quite excited with all the article content of your site. It would be my pleasure to gather some more strategies from your web-site and come up to offer people what I have benefited from you. Great business : Business For Sale
Great post, thanks for share
It would be my pleasure to gather some more strategies from your web-site and come up to offer people what I have benefited from you. Great business : Business For Sale | Website For Sale | Business Opportunity | Work From Home
I am quite vitalized with all
I am quite vitalized with all the content of your web page. It would be my fulfillment to gather some more methods from your web-site and come up to offer people what I have obtained from you. phlebotomy
Hey i fully agree with you on
Hey i fully agree with you on this. There are lots of great information in this website. Thanks a lot!
Liposuction Los Angeles
This is a good information
This is a good information about the benchmarking authentication. Thanks Liposuction Los Angeles
excellent work
Excellent work in this project.Good work and all link are very good and helpfull all of you.
This ApacheBench will be a
This ApacheBench will be a useful tools for Drupal users and moderator, should buy and install it.
nice blog
I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.
Halibut Charters
Post new comment