load test drupal site using jmeter and amazon aws

56
Load Test Drupal Site Using Apache JMeter & Amazon AWS By Vladimir Ilic @burgerboydaddy

Upload: vladimir-ilic

Post on 09-May-2015

6.239 views

Category:

Technology


0 download

DESCRIPTION

Presentation on Pacific Northwest Drupal Summit, Vancouver 2013 about load testing Drupal sites using Apache JMeter and Amazon AWS.

TRANSCRIPT

Page 1: Load Test Drupal Site Using JMeter and Amazon AWS

Load Test Drupal SiteUsing Apache JMeter & Amazon AWS

By Vladimir Ilic@burgerboydaddy

Page 2: Load Test Drupal Site Using JMeter and Amazon AWS

About me

• twitter: @burgerboydaddy

• http://burgerboydaddy.com

Page 3: Load Test Drupal Site Using JMeter and Amazon AWS

Quote

• “The designer is concerned with what happens when 1 user presses a button and the architect is concerned with what happens when 10,000 users press a button.”

• Sun Certified Enterprise Architect for J2EE Technology Study Guide. Page 6. Mark Cade, Simon Roberts. 2007 JavaOneSM Conference | Session TS-9235 | 2

Page 4: Load Test Drupal Site Using JMeter and Amazon AWS

4

Test Types

• Performance• Load• Stress• Scalability• Endurance• Functional

Page 5: Load Test Drupal Site Using JMeter and Amazon AWS

Performance Testing

• Performance testing determines or validates the speed of the application (X per T).

• Used for finding bottlenecks and establish baseline for the system.

• In other words it’s solo purpose is to determine the response and effectiveness of a system.

Page 6: Load Test Drupal Site Using JMeter and Amazon AWS

Load Testing

• Load testing identifies the maximum operating capacity of an application as well as any bottlenecks that might interfere with its operating capacity.

(or, when does it blow up?)

Page 7: Load Test Drupal Site Using JMeter and Amazon AWS

Stress Testing

• Stress testing is focused on determining an application’s robustness, availability, and reliability under extreme conditions– Heavy loads– High concurrency– Limited computational resources

• An attempt to break the system by overwhelming its resources

Page 8: Load Test Drupal Site Using JMeter and Amazon AWS

Scalability• Scalability testing determines or validates

whether adding another Y resource (database, memory, disk, CPU, etc) increases speed of X proportionally

Endurance Testing

This type of testing is used to check that the system can withstand the load for a long or large number of transactions.

Page 9: Load Test Drupal Site Using JMeter and Amazon AWS

Preparation for a Test

• Mission• Network• Hardware• Software• Metrics

Page 10: Load Test Drupal Site Using JMeter and Amazon AWS

Mission

• What is the testing intended to achieve? • What are basic assumptions like:– What is our anticipated average number of users

(normal load)? – What is our anticipated peak number of users?

• When is a good time to load-test our application (i.e. off-hours or weekends), bearing in mind that this may very well crash one or more of our servers?

Page 11: Load Test Drupal Site Using JMeter and Amazon AWS

Environment Prep - Network

• Performance testing is usually network intensive operation and can affect others in the organization

• Testing should be done on a separated / segregated network

• Amazon AWS – virtually unlimited in/out speed

Page 12: Load Test Drupal Site Using JMeter and Amazon AWS

Environment Prep – Hardware

• Is your machine ready to receive full load?• Are multiple machine available (for distributed

testing)?• Do you have enough resources• Again – Amazon to the rescue – AWS gives you

as many test machines as you need.

Page 13: Load Test Drupal Site Using JMeter and Amazon AWS

Metrics

• Performance testing is all about numbers and metrics

• Determine which metrics you are concerned about and how to get them.

• Some simple tests / benchmarks can be done using Apache Bench “ab” command:

•Suppose we want to see how fast our site can handle 100 requests, with a maximum of 10 requests running concurrently:

• ab -n 100 -c 10 http://example.dev/

Page 14: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter – Software of Choice• Open source desktop / server application• Designed for functional/load/performance/stress testing • Extensible… write your own test • Simulate heavy load (application, server and network)• Gives instant visual feedback • Distributed testing • Various protocols - HTTP, FTP, JDBC, JMS, LDAP, SOAP • Multi-platform • Full multithreading framework • Caching and offline analysis/replaying of test results.• JMeter is not a web browser!

Page 15: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter vs. Real WorldReal World JMeter World

One User Browser request HTTP Request Sampler

One HTML page display with JavaScript Execution

View Tree Listener with basic HTML display.

No JavaScript execution

Multiple Users Requesting Pages Simultaneously

Thread Group Configured for Number of Users, uses the same HTTP Request Sampler to

simulate multiple users

No EquivalentDifficult to do

Measuring performance like min, max, and average (avg) time for processing using

Summary Report Listener

Page 16: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter - TerminologyJMeter Term Meaning

Test Plan - You keep your test plan under me- Only one per one JMeter window- Save it for a future use

Thread Group - Represent one set of action – one scenario- You add actions that single user will do- JMeter will use them to simulate multiple users

HTTP Request Sampler - Record the request to web server- Also receive the response from Web server- Provide all data received for analysis

View Tree Listener - Show the test data in details for each item - For HTTP Request it show’s Request, Response and Status of Transaction

Summary Report Listener - Show aggregated values for all users- Useful when multiple users are simulated- Provide performance information

Page 17: Load Test Drupal Site Using JMeter and Amazon AWS

17

JMeter Testing Tools• Test Plan • Thread Group • Controllers:

– Samplers & – Logical Controllers

• Listeners • Timers • Assertions • Configuration Elements • Pre-Processor Elements • Post-Processor Elements

Page 18: Load Test Drupal Site Using JMeter and Amazon AWS

• Pre-Processor Elements• A Pre-Processor executes some action prior to a Sampler Request

being made.• If a Pre-Processor is attached to a Sampler element, then it will

execute just prior to that sampler element running.• A Pre-Processor is most often used to modify the settings of a

Sample Request just before it runs, or to update variables that aren't extracted from response text.

• Post-Processor Elements• A Post-Processor executes some action after a Sampler Request has

been made.• If a Post-Processor is attached to a Sampler element, then it will

execute just after that sampler element runs.• A Post-Processor is most often used to process the response data,

often to extract values from it. See the scoping rules for more details on when Post-Processors are executed.

Page 19: Load Test Drupal Site Using JMeter and Amazon AWS

Execution order

1. Configuration elements2. Pre-Processors3. Timers4. Sampler5. Post-Processors (unless SampleResult is null)6. Assertions (unless SampleResult is null)7. Listeners (unless SampleResult is null)

• Timers, Assertions, Pre- and Post-Processors are only processed if there is a sampler to which they apply.

• Logic Controllers and Samplers are processed in the order in which they appear in the tree.

• Other test elements are processed according to the scope in which they are found, and the type of test element

Page 20: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter – Basic Elements

Page 21: Load Test Drupal Site Using JMeter and Amazon AWS

21

JMeter – Basic Elements• “number of threads” - In other words, this variable is the number of users

executing a “real life” use case on your system.• This number is not the number of concurrent / parallel users executing a “real

life” use case on your system:

• the concurrency of the users depends on both the duration of your scenario and the ramp up time configured on the thread group.

• The “ramp up time” in a thread group is the actual time taken by JMeter to spawn all the threads.

• A rough estimation of the throughput (number of requests per second) during the ramp up period of your test plan is: number of threads / ramp up time (in seconds).

Page 22: Load Test Drupal Site Using JMeter and Amazon AWS

Tips & Tricks• You should try to have a constant throughput during a run:

It is often very difficult to “control” the throughput particularly during the ramp up period

• If your objective is to simulate a “peak”:You should have a “high” number of threads and a “low” ramp up time and number of loops

• If your objective is to simulate a “long run”:You should have a “medium” number of threads, a “higher” ramp up time and a “high” number of loops

• Note: The terms “high”, “higher”, “medium” and “low” are voluntary qualitative in the 2 bullets above as they depend on the system you are testing.

Page 23: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter – HTTP Request Defaults

Page 24: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter – Adding HTTP Requests• The “HTTP Request Default” elements does not tell

JMeter to send an HTTP request. It simply defines the default values that the HTTP Request elements use.

• In our test plan we need to add at least one “HTTP Request Sampler”.

• JMeter sends requests in the order that they appear in the tree.

• Add HTTP Request to the JMeter Users element (Add->Sampler->HTTP Request).

Page 25: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter – HTTP Request

Page 26: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter - Listener

• The final element you need to add is a Listener.• This element is responsible for storing all of the

results of your HTTP requests in a file and presenting a visual model of the data.

• Select the JMeter Users element and add a Graph Result Listener and Summary Report Listener. (Add->Listener->Graph Results).

Page 27: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter - Listener

Page 28: Load Test Drupal Site Using JMeter and Amazon AWS

Distributed Testing Using JMeter

Page 29: Load Test Drupal Site Using JMeter and Amazon AWS

29

The Cloud and Load Testing

• One of the things the Cloud is useful for is load testing; very large amounts of hardware can be used to generate load at minimal cost.

• Added benefit, if your application you are testing is external to your corporate network, your tests will be run from a realistic location which prevents any problems with artificial bottlenecks occurring on your LAN.

• This type of testing, using externally located hosts, is increasingly common and JMeter is a superb open-source solution for facilitating this.

Page 30: Load Test Drupal Site Using JMeter and Amazon AWS

Easy Amazon AWS & JMeter

• Thanks to Oliver from http503.com and his automated JMeter on EC2 script

http://www.http503.com/2012/run-JMeter-on-amazon-ec2-cloud

• Run with up to 20 concurrent EC2 instances (default max number)

• Run when you want it and how you want it!

Page 31: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter – http503.com script• It does things like:– Using Amazon’s API to launch instances– Installing JAVA & JMeter– Copying test files to each server– Adjusting thread counts to ensure the load is evenly

distributed over each host– Editing the jmx for file paths to external data files– Displaying real-time aggregated results from the test as it

is running– Downloading and collating all jtl files– Terminating instances.

Page 32: Load Test Drupal Site Using JMeter and Amazon AWS

32

JMeter-EC2• Prerequisites

– Test plan to be run has a Generate Summary Results listener.– Your JMeter test plan has a duration or loop count value set.

• Prerequisites specific to using Amazon:– That you have an Amazon AWS account. – You have Amazon’s API tools installed on your machine.

• Note: you can control execution from your local machine, but you will need to open few ports for data return. Difficult if you are behind corporate firewall/proxy. – Solution: Run controller on Amazon AWS (another EC2 instance)

Page 33: Load Test Drupal Site Using JMeter and Amazon AWS

33

Installation Process

• Go to the:

http://www.http503.com/2012/run-jmeter-on-amazon-ec2-cloud/#example

• Small tips– Create security group with port 22 open to the world (or

your IP address).– Also allow all machines inside security group to access

each other.

Page 34: Load Test Drupal Site Using JMeter and Amazon AWS

34

JMeter-EC2

• Setup your machine image key, and your secret key pair.– Call it:

project="myblogtestplan" count="3" owner="Vlad” ./jmeter-ec2.sh

Page 35: Load Test Drupal Site Using JMeter and Amazon AWS

DEMO TIME

Page 36: Load Test Drupal Site Using JMeter and Amazon AWS

36

Results Analysis

• Running a test plan is only 50% of the performance testing task.

• The most challenging part of the performance testing process is the analysis of test results and the identification of bottlenecks.

• Think of the load testing reports as the evidentiary support to prove your innocence to a crime in court.

Page 37: Load Test Drupal Site Using JMeter and Amazon AWS

Just a moment please…• Before going any further, we should spend some time

on the measurable outcomes of a stress test. There are mainly 2 interesting measures that you can record when you run a stress test on a web application:

• The throughput: is the number of requests per unit of time (seconds, minutes, hours) that are sent to your server during the test.

• The response time: is the elapsed time from the moment when a given request is sent to the server until the moment when the last bit of information has returned to the client

Page 38: Load Test Drupal Site Using JMeter and Amazon AWS

... moment please …

• The throughput is the real load processed by your server during a run but it does not tell you anything about the performance of your server during this same run.

• This is the reason why you need both measures in order to get a real idea about your server’s performance during a run. The response time tells you how fast your server is handling a given load.

Page 39: Load Test Drupal Site Using JMeter and Amazon AWS

Results Analysis – Interpreting Results

• What do we want to find inside our reports?• Kind of Reports

– Summary Report*– Graph Results– View Results in Tree– View Results in Table

• Extra report types– Response Times vs Threads**– Transaction Throughput vs Threads**

• * - must have report listener!• ** - Thread == user (in JMeter world)

Page 40: Load Test Drupal Site Using JMeter and Amazon AWS

40

Response Times vs Threads

• This graph shows how Response Time changes with amount of parallel threads.

• Naturally, server takes longer to respond when a lot of users requests it simultaneously. This graph visualizes such dependencies.

Page 41: Load Test Drupal Site Using JMeter and Amazon AWS

41

Transaction Throughput vs Threads

• This listener is very similar to Response Times vs Threads, except it shows total server's transaction throughput for active test threads.

• The formula for total server transaction throughput is <active threads> * 1 second / <1 thread response time>

• So basically, it shows the statistical maximum possible number of transactions based on number of users accessing the application.

Page 42: Load Test Drupal Site Using JMeter and Amazon AWS

90% line of response time

Page 43: Load Test Drupal Site Using JMeter and Amazon AWS

Learn to Read Graph

• Load speed• Throughput• Deviation• Hits

Page 44: Load Test Drupal Site Using JMeter and Amazon AWS

Results Graph - Average Load Time

• Page load speeds in milliseconds.

• Lower is better• On a stable system, it

should go flat

Page 45: Load Test Drupal Site Using JMeter and Amazon AWS

Results Graph - Deviation

• The deviation (variability) of the load speed in milliseconds.

• Lower is better• On a stable system, it

should go flat

Page 46: Load Test Drupal Site Using JMeter and Amazon AWS

Results Graph - Throughput

• Throughput in pages per second.

• Higher is better• On a stable system, it

should go flat

Page 47: Load Test Drupal Site Using JMeter and Amazon AWS

• The black dots are individual sample times

Page 48: Load Test Drupal Site Using JMeter and Amazon AWS

Good sign

• When the values on the graph begin to flatten out, it shows that the system has become stable at that load.– Speed flattening– Throughput flattening– Deviation dropping– No exceptions ;-)

Page 49: Load Test Drupal Site Using JMeter and Amazon AWS

Connect Results With Logs

• Learn to relate problems on the server to its effect on the graph.

• Big spikes indicate that you have a problems

• You may see the effects of:– Exceptions– Garbage collection

Page 50: Load Test Drupal Site Using JMeter and Amazon AWS

JMeter & New Relic

Page 51: Load Test Drupal Site Using JMeter and Amazon AWS

Tips & Tricks• A clear name for each performance test • non-GUI mode is more stable than GUI mode • Do not use listeners if not needed • Ramp-up is needed for heavy load • Assertion is needed to simulate a virtual user • Unstable tests: think of data while an user run its scenario• If one user can not login, its later steps should not be counted • Backup after every important step you made to your script easily by

cloning the jmx file• Speedup JMeter script modifying with text editors which support

regex

Page 52: Load Test Drupal Site Using JMeter and Amazon AWS

Simulate User Behavior in JMeter

• Only Once Controllers• Cache Management• Cookie Management• Header Management• Think Times

Page 53: Load Test Drupal Site Using JMeter and Amazon AWS

Gaussian Random Timer

• This timer pauses each thread request for a random amount of time, with most of the time intervals occurring near a particular value.

• The total delay is the sum of the Gaussian distributed value (with mean 0.0 and standard deviation 1.0) times the deviation value you specify, and the offset value.

Page 54: Load Test Drupal Site Using JMeter and Amazon AWS

References• Apache JMeter

http://jmeter.apache.org/• jmeter-ec2 | Run JMeter on Amazon’s ec2 Cloud

http://www.http503.com/2012/run-jmeter-on-amazon-ec2-cloud• Some thoughts on stress testing web applications with JMeter

http://nico.vahlas.eu/2010/03/17/some-thoughts-on-stress-testing-web-applications-with-jmeter-part-1/• JMeter tips

http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-jmeter.html• Response Times: The 3 Important Limits

http://www.nngroup.com/articles/response-times-3-important-limits/• Apache JMeter Custom Plugins

http://jmeter-plugins.org• JMeter Wiki

http://wiki.apache.org/jmeter/JMeterLinks• Amazon AWS EC2 Command Line Toolkit

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SettingUp_CommandLine.html• Bayo Ernie - Performance Testing With JMeter 2.9 [Kindle Edition]

Page 55: Load Test Drupal Site Using JMeter and Amazon AWS

Thanks for your time

Page 56: Load Test Drupal Site Using JMeter and Amazon AWS

Q & A