YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Performance Testing Crash Course

PERFORMANCE TESTING CRASH COURSE

Page 2: Performance Testing Crash Course

Dustin Whittle

• dustinwhittle.com

• @dustinwhittle

• San Francisco, California, USA

• Technologist, Traveler, Pilot, Skier, Diver, Sailor, Golfer

Page 3: Performance Testing Crash Course

What I have worked on

• Developer Evangelist @

• Consultant & Trainer @

• Developer Evangelist @

Page 4: Performance Testing Crash Course

Why does performance matter?

Page 5: Performance Testing Crash Course

Microsoft found that Bing searches that were 2 seconds

slower resulted in a 4.3% drop in revenue per user

Page 6: Performance Testing Crash Course

When Mozilla shaved 2.2 seconds off their landing page, Firefox downloads increased

15.4%

Page 7: Performance Testing Crash Course

Making Barack Obama’s website 60% faster increased donation conversions by 14%

Page 8: Performance Testing Crash Course

Amazon and Walmart increase revenue 1% for

every 100ms of improvement

Page 9: Performance Testing Crash Course
Page 10: Performance Testing Crash Course

Performance directly impacts the bottom

line

Page 11: Performance Testing Crash Course
Page 12: Performance Testing Crash Course
Page 13: Performance Testing Crash Course

HealthCare.gov

Page 14: Performance Testing Crash Course

Tools of the trade for performance testing

Page 15: Performance Testing Crash Course

Understand your baseline performance

Page 16: Performance Testing Crash Course

Static !

vs !

Hello World !

vs !

Applications

Page 17: Performance Testing Crash Course

Apache Bench

Page 18: Performance Testing Crash Course

ab -c 10 -t 10 -k http://dustinwhittle.com/

Page 19: Performance Testing Crash Course

Benchmarking dustinwhittle.com (be patient)Finished 286 requests!!Server Software: nginxServer Hostname: dustinwhittle.comServer Port: 80!Document Path: /Document Length: 6642 bytes!Concurrency Level: 10Time taken for tests: 10.042 secondsComplete requests: 286Failed requests: 0Write errors: 0Keep-Alive requests: 0Total transferred: 2080364 bytesHTML transferred: 1899612 bytesRequests per second: 28.48 [#/sec] (mean)Time per request: 351.133 [ms] (mean)Time per request: 35.113 [ms] (mean, across all concurrent requests)Transfer rate: 202.30 [Kbytes/sec] received!

Page 20: Performance Testing Crash Course

Siege

Page 21: Performance Testing Crash Course

siege -c 10 -b -t 10S http://dustinwhittle.com/

Page 22: Performance Testing Crash Course

** SIEGE 2.72** Preparing 10 concurrent users for battle.The server is now under siege...Lifting the server siege... done.!Transactions: 263 hitsAvailability: 100.00 %Elapsed time: 9.36 secsData transferred: 0.35 MBResponse time: 0.35 secsTransaction rate: 28.10 trans/secThroughput: 0.04 MB/secConcurrency: 9.82Successful transactions: 263Failed transactions: 0Longest transaction: 0.54Shortest transaction: 0.19

Page 23: Performance Testing Crash Course

Crawl the entire app to discover all urls

Page 24: Performance Testing Crash Course

sproxy -o ./urls.txt

Page 25: Performance Testing Crash Course

SPROXY v1.02 listening on port 9001 ...appending HTTP requests to: ./urls.txt ...default connection timeout: 120 seconds

Page 26: Performance Testing Crash Course

wget -r -o verbose.txt -l 0 -t 1 --spider -w 1 -e robots=on

-e "http_proxy = http://127.0.0.1:9001" "http://dustinwhittle.com/"

sort -u -o urls.txt urls.txt

Page 27: Performance Testing Crash Course

Benchmark traffic across all unique urls

with siege

Page 28: Performance Testing Crash Course

siege -v -c 50 -i -t 3M -f urls.txt -d 10

Page 29: Performance Testing Crash Course

Apache JMeter

Page 30: Performance Testing Crash Course
Page 31: Performance Testing Crash Course
Page 32: Performance Testing Crash Course

Multi-Mechanize is an open source framework for

performance and load testing

Page 33: Performance Testing Crash Course

pip install multi-mechanize

Page 34: Performance Testing Crash Course

multimech-newproject demo

Page 35: Performance Testing Crash Course

import requests !class Transaction(object): def run(self): r = requests.get('http://dustinwhittle.com/') r.raw.read()

Page 36: Performance Testing Crash Course

import mechanize import time !class Transaction(object): def run(self): br = mechanize.Browser() br.set_handle_robots(False) ! start_timer = time.time() resp = br.open('http://www.dustinwhittle.com/') resp.read() latency = time.time() - start_timer self.custom_timers['homepage'] = latency ! start_timer = time.time() resp = br.open('http://www.dustinwhittle.com/blog') resp.read() latency = time.time() - start_timer self.custom_timers['blog'] = latency ! assert (resp.code == 200)

Page 37: Performance Testing Crash Course

[global] run_time = 10 rampup = 5 results_ts_interval = 1 progress_bar = on console_logging = off xml_report = on !![user_group-1] threads = 1 script = demo.py

Page 38: Performance Testing Crash Course

multimech-run demo

Page 39: Performance Testing Crash Course
Page 40: Performance Testing Crash Course

What about when you need more than one

machine?

Page 41: Performance Testing Crash Course

Who lives in the cloud?

Page 42: Performance Testing Crash Course

Bees with Machine Guns

Page 43: Performance Testing Crash Course

A utility for arming (creating) many bees (micro EC2 instances)

to attack (load test) targets (web applications)

Page 44: Performance Testing Crash Course

pip install beeswithmachineguns

Page 45: Performance Testing Crash Course

# ~/.boto !![Credentials] !aws_access_key_id=xxx aws_secret_access_key=xxx !![Boto] !ec2_region_name = us-west-2 ec2_region_endpoint = ec2.us-west-2.amazonaws.com

Page 46: Performance Testing Crash Course

bees up -s 2 -g default -z us-west-2b -i ami-bc05898c -k appdynamics-

dustinwhittle-aws-us-west-2 -l ec2-user

Page 47: Performance Testing Crash Course

Connecting to the hive.Attempting to call up 2 bees.Waiting for bees to load their machine guns.......Bee i-3828400c is ready for the attack.Bee i-3928400d is ready for the attack.The swarm has assembled 2 bees.

Page 48: Performance Testing Crash Course

bees report

Page 49: Performance Testing Crash Course

Read 2 bees from the roster.Bee i-3828400c: running @ 54.212.22.176Bee i-3928400d: running @ 50.112.6.191

Page 50: Performance Testing Crash Course

bees attack -n 1000 -c 50 -u http://dustinwhittle.com/

Page 51: Performance Testing Crash Course

Read 2 bees from the roster.Connecting to the hive.Assembling bees.Each of 2 bees will fire 50000 rounds, 125 at a time.Stinging URL so it will be cached for the attack.Organizing the swarm.Bee 0 is joining the swarm.Bee 1 is joining the swarm.Bee 0 is firing his machine gun. Bang bang!Bee 1 is firing his machine gun. Bang bang!Bee 1 is out of ammo.Bee 0 is out of ammo.Offensive complete. Complete requests: 100000 Requests per second:1067.110000 [#/sec] (mean) Time per request: 278.348000 [ms] (mean) 50% response time: 47.500000 [ms] (mean) 90% response time: 114.000000 [ms] (mean)Mission Assessment: Target crushed bee offensive.The swarm is awaiting new orders.

Page 52: Performance Testing Crash Course

bees down

Page 53: Performance Testing Crash Course

What about the client side?

Page 54: Performance Testing Crash Course

In modern web applications more latency comes from the

client-side than the server-side.

Page 55: Performance Testing Crash Course

Google PageSpeed

Page 56: Performance Testing Crash Course

Google PageSpeed Insights

Page 57: Performance Testing Crash Course
Page 58: Performance Testing Crash Course
Page 59: Performance Testing Crash Course

Google PageSpeed API

Page 60: Performance Testing Crash Course

curl "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?

url=http://dustinwhittle.com/&key=xxx"

Page 61: Performance Testing Crash Course

WBench

Page 62: Performance Testing Crash Course

gem install wbench

Page 63: Performance Testing Crash Course

wbench http://dustinwhittle.com/

Page 64: Performance Testing Crash Course
Page 65: Performance Testing Crash Course

Automate client-side performance testing

with Grunt

Page 66: Performance Testing Crash Course

Use Bower (for dependencies), Grunt (for automation),

and Yeoman (for bootstrapping)

Page 67: Performance Testing Crash Course
Page 68: Performance Testing Crash Course
Page 69: Performance Testing Crash Course

How many people understand exactly how fast their site runs in production?

Page 70: Performance Testing Crash Course

Track performance in development and

production

Page 71: Performance Testing Crash Course

Instrument everything = code, databases,

caches, queues, third party services, and

infrastructure.

Page 72: Performance Testing Crash Course

Chef / Sensu

Page 73: Performance Testing Crash Course

http://sensuapp.org/

Page 74: Performance Testing Crash Course

Statsd + Graphite + Grafana

Page 75: Performance Testing Crash Course
Page 76: Performance Testing Crash Course

Episodes / Boomerang

Page 77: Performance Testing Crash Course
Page 78: Performance Testing Crash Course
Page 79: Performance Testing Crash Course
Page 80: Performance Testing Crash Course

webpagetest.org

Page 81: Performance Testing Crash Course
Page 82: Performance Testing Crash Course
Page 83: Performance Testing Crash Course
Page 84: Performance Testing Crash Course

SiteSpeed.io

Page 85: Performance Testing Crash Course
Page 86: Performance Testing Crash Course
Page 87: Performance Testing Crash Course
Page 88: Performance Testing Crash Course
Page 89: Performance Testing Crash Course
Page 90: Performance Testing Crash Course
Page 91: Performance Testing Crash Course
Page 92: Performance Testing Crash Course
Page 93: Performance Testing Crash Course

Load testing services from the cloud

Page 94: Performance Testing Crash Course
Page 95: Performance Testing Crash Course
Page 96: Performance Testing Crash Course
Page 97: Performance Testing Crash Course

Test for failures

• NetFlix Simian Army + Chaos Monkey

• What happens if you lose a caching layer?

• What happens if dependencies slow down?

Page 98: Performance Testing Crash Course

Best Practices

• Capacity plan and load test the server-side

• Optimize and performance test the client-side

• Understand your starting point

• Instrument everything

• Measure the difference of every change

• Automate performance testing in your build and deployment process

• Understand how failures impact performance

Page 99: Performance Testing Crash Course

Integrate automated performance testing into

continuous integration for server-side and client-side

Page 100: Performance Testing Crash Course

Understand the performance implications of every

deployment and package upgrade

Page 101: Performance Testing Crash Course

Monitor end user experience from end to end in production

Page 102: Performance Testing Crash Course

Questions?

Page 103: Performance Testing Crash Course

Find these slides on SpeakerDeck !

https://speakerdeck.com/dustinwhittle


Related Documents