title | description | category | keywords | |
---|---|---|---|---|
Load and Performance Testing |
Learn how to monitor internal execution performance of your Pantheon Drupal or WordPress site. |
|
going live, testing, performance, new relic, varnish |
We highly recommend load testing a site both prior and post launch to ensure your site is optimally configured.
You should:
- Enable New Relic to monitor internal execution performance without needing any additional modules or tools.
- Have access to a command-line environment, preferably with administrative privileges.
There are two things to test for:
- Performance: the response time for an individual request
- Scalability: the ability to deliver with optimal response time to a larger number of concurrent requests
High-performance is the ability to deliver a page in under a second; scalability is the ability to deliver that page in under a second for many requests. It's important to understand the difference between these two dimensions and that there are trade-offs between performance and scalability.
To verify that the Varnish cache is working, the curl
command can be run with the -I
flag to gather and display header information. Header information can also be obtained via Firebug or Inspect in the browser. The results should be something like this:
curl -I http://live-yoursite.pantheon.io
HTTP/1.1 200 OK
Server: nginx/1.0.10
Date: Fri, 17 Aug 2012 23:47:36 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
cache-control: public, max-age=300
last-modified: Fri, 17 Aug 2012 23:44:40 +0000
expires: Sun, 11 Mar 1984 12:00:00 GMT
etag: "1345247080"
X-Varnish: 1082592805 1082586928
Age: 176
Via: 1.1 varnish
X-Pantheon-Edge-Server: 108.166.96.132
Vary: Accept-Encoding, Cookie
The "Age" field should be greater than 0. If the max age is not greater than 0, please review Drupal's Performance and Caching Settings and Varnish Caching for High Performance documentation.
Passing the curl command with time
before it, as well as sending a NO_CACHE
cookie, which prevents Varnish from caching the response, will test the actual response of the application containers backend:
time curl -I -H "Cookie: NO_CACHE=1;" http://live-yoursite.pantheon.io
The command returns the following results. Note the appended timestamp at the bottom. The "real" time is the one to pay attention to:
time curl -I -H "Cookie: NO_CACHE=1;" http://live-yoursite.pantheon.io
HTTP/1.1 200 OK
Server: nginx/1.0.10
Date: Fri, 17 Aug 2012 23:57:39 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
cache-control: public, max-age=300
last-modified: Fri, 17 Aug 2012 23:57:38 +0000
expires: Sun, 11 Mar 1984 12:00:00 GMT
etag: "1345247858"
Accept-Ranges: bytes
X-Varnish: 1082615375
Age: 0
Via: 1.1 varnish
X-Pantheon-Edge-Server: 108.166.96.132
Vary: Accept-Encoding, Cookie
real 0m0.874s
user 0m0.036s
sys 0m0.004s
Test specific-pages of a site by passing a specific URL, as well as the experience of a logged-in user by passing a PHP-Session ID.
To get the PHP-Session ID, log in to your site and check the browsers cookie setting and value. The Session ID can be passed in the following way:
time curl -I -H "Cookie: SESSe6c673379860780ffbc45bdd6d9c1ab4=dKanNfIMe_0CnOMF7v1Qb5SpDN7UDvyQE8um-1Rpkcg;;" http://live-yoursite.pantheon.io
If you're not satisfied with the response time, focus should be shifted to optimizing the performance of the site.
In order to test scale and throughput, we use AB, a simple tool made available by the Apache Project.
Run the following command:
ab -n 100 -c 5 http://live-yoursite.pantheon.io/
Varnish should now be properly configured, and what you've tested should generate good response times and a high requests per second.
As with curl
, you can run ab
with the following parameters: -C NO_CACHE=1
parameter to stop Varnish from caching the response. ab
returns the following output:
ab -n 100 -c 5 -C NO_CACHE=1 http://live-yoursite.pantheon.io/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking http://live-yoursite.pantheon.io (be patient).....done
Server Software: 10.176.69.43
Server Hostname: http://live-yoursite.pantheon.io
Server Port: 80
Document Path: /
Document Length: 30649 bytes
Concurrency Level: 5
Time taken for tests: 12.854 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 3118447 bytes
HTML transferred: 3064900 bytes
Requests per second: 7.78 [#/sec] (mean)
Time per request: 642.705 [ms] (mean)
Time per request: 128.541 [ms] (mean, across all concurrent requests)
Transfer rate: 236.92 [Kbytes/sec] received
Connection Times (ms)
min mean[+#sd] median max
Connect: 60 81 32.5 73 258
Processing: 411 554 150.2 496 1213
Waiting: 82 131 100.5 109 794
Total: 471 635 162.9 574 1280
Percentage of the requests served within a certain time (ms)
50% 574
66% 614
75% 646
80% 696
90% 899
95% 1010
98% 1170
99% 1280
100% 1280 (longest request)
The output provides insight into the requests per second, the most critical element in regards to the scalability of a site. Pay attention to the 90/95% response time as well, as this gives an idea of how the site is actually performing. Check that the number of failed requests is 0; if it's not, this should be investigated.
Response times vary from site to site depending on the size of your modules stack, database queries, etc. Generally, anything under 1 second is considered excellent, but this is up to you.
Emulating a logged in user's experience with ab
is a key metric, as it provides the number of pages per second your site can generate on Pantheon. This number may determine whether or not you need to add additional application containers.
There are a number of other tools to consider when you are planning your load testing strategy. This can vary by the need for detail, nature of your site, or requirements for quality analysis.
Testing Tool | Documentation | Acquisition |
---|---|---|
Apache AB | Documentation | Download |
J-Meter | Documentation | Download |
The Grinder | Documentation | Download |
Blitz.io | Documentation | Pricing |