• No results found

Performance Testing Crash Course

N/A
N/A
Protected

Academic year: 2021

Share "Performance Testing Crash Course"

Copied!
119
0
0

Loading.... (view fulltext now)

Full text

(1)

Performance  Testing  Crash  Course

Dustin  Whittle  

(2)

The performance of your application affects

your business more than you might think. Top

engineering organizations think of performance

not as a nice-to-have, but as a crucial feature of

their product. Those organizations understand

that performance has a direct impact on user

experience and, ultimately, their bottom line.

Unfortunately, most engineering teams do not

regularly test the performance and scalability of

their infrastructure. Join this session to find out

about the latest performance testing tools and

why your team should add performance testing

to your agile development process.

(3)

Dustin Whittle

dustinwhittle.com  

@dustinwhittle  

San  Francisco,  California,  USA  

Technologist,  Traveler,  Pilot,  Skier,  Diver,  Sailor,  

Golfer

(4)

What I have worked on

Developer  Evangelist  @  

Consultant  &  Trainer  @  

Developer  Evangelist  @

(5)
(6)

Microsoft found that Bing searches

that were 2 seconds slower resulted

in a 4.3% drop in revenue per user

(7)

When Mozilla shaved 2.2 seconds

off their landing page, Firefox

(8)

Making Barack Obama’s

website 60% faster increased

donation conversions by 14%

(9)

Amazon and Walmart

increase revenue 1% for

(10)
(11)

Performance directly

impacts the bottom line

(12)
(13)

HealthCare.gov

(14)

Treat performance as a feature!

(15)

AN  EXAMPLE  SPRING  APP  

 TO  TEST  PERFORMANCE

(16)
(17)
(18)

GIT  CLONE  

HTTPS://GITHUB.COM/

CLOUDFOUNDRY-­‐SAMPLES/HELLO-­‐

SPRING-­‐CLOUD

(19)
(20)
(21)
(22)

CF  PUSH

(23)
(24)

Tools of the trade for

performance testing

(25)

Understand your

(26)

Static

vs

Hello World

vs

Application

26

(27)
(28)

ab -c 1 -t 10 -k

http://acmedemoapp.com/

(29)

Benchmarking acmedemoapp.com (be patient) Finished 187 requests

Server Software: Nginx/1.6

Server Hostname: acmedemoapp.com Server Port: 80

Document Path: /

Document Length: 5217 bytes Concurrency Level: 1

Time taken for tests: 10.039 seconds Complete requests: 187

Failed requests: 0

Keep-Alive requests: 187

Total transferred: 1021768 bytes HTML transferred: 975579 bytes

Requests per second: 18.63 [#/sec] (mean) Time per request: 53.687 [ms] (mean)

(30)

ab -c 10 -t 10 -k

http://acmedemoapp.com/

(31)

Benchmarking acmedemoapp.com (be patient) Finished 659 requests

Server Software: Nginx/1.6

Server Hostname: acmedemoapp.com Server Port: 80

Document Path: /

Document Length: 5217 bytes Concurrency Level: 10

Time taken for tests: 10.015 seconds Complete requests: 659

Failed requests: 0

Keep-Alive requests: 659

Total transferred: 3600776 bytes HTML transferred: 3438003 bytes

Requests per second: 65.80 [#/sec] (mean) Time per request: 151.970 [ms] (mean)

(32)

Siege

(33)
(34)

34

** SIEGE 3.0.6

** Preparing 10 concurrent users for battle. The server is now under siege...

Lifting the server siege... done. Transactions: 623 hits Availability: 100.00 %

Elapsed time: 9.57 secs Data transferred: 3.10 MB Response time: 0.15 secs

Transaction rate: 65.10 trans/sec Throughput: 0.32 MB/sec Concurrency: 9.91 Successful transactions: 623 Failed transactions: 0 Longest transaction: 0.30 Shortest transaction: 0.10

(35)

Crawl the entire app to

discover all urls

(36)

sproxy -o ./urls.txt

(37)

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

(38)

38

wget -r -l 0 -t 1 --spider -w 1

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

(39)

http://acmedemoapp.com/

http://acmedemoapp.com/about

http://acmedemoapp.com/cart

http://acmedemoapp.com/currency/change/EUR

http://acmedemoapp.com/currency/change/GBP

http://acmedemoapp.com/currency/change/USD

http://acmedemoapp.com/login

http://acmedemoapp.com/register

http://acmedemoapp.com/t/brand/bookmania

http://acmedemoapp.com/t/category/books

http://acmedemoapp.com/t/category/mugs

http://acmedemoapp.com/t/category/stickers

http://acmedemoapp.com/terms-of-service

(40)

Benchmark traffic across all

unique urls with siege

(41)
(42)

42

** SIEGE 3.0.6

** Preparing 10 concurrent users for battle. The server is now under siege...

Lifting the server siege... done. Transactions: 623 hits Availability: 100.00 %

Elapsed time: 9.57 secs Data transferred: 3.10 MB Response time: 0.15 secs

Transaction rate: 65.10 trans/sec Throughput: 0.32 MB/sec Concurrency: 9.91 Successful transactions: 623 Failed transactions: 0 Longest transaction: 0.30 Shortest transaction: 0.10

(43)
(44)
(45)
(46)

Multi-Mechanize is an open

source framework for

performance and load testing

(47)
(48)

multimech-newproject demo

(49)

import requests

class Transaction(object): def run(self):

r = requests.get(‘http://acmedemoapp.com/) r.raw.read()

(50)

50 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://acmedemoapp.com/) resp.read()

latency = time.time() - start_timer

self.custom_timers['homepage'] = latency start_timer = time.time()

resp = br.open(‘http://acmedemoapp.com/cart') resp.read()

latency = time.time() - start_timer self.custom_timers['cart'] = latency assert (resp.code == 200)

(51)

[global]

run_time = 10 rampup = 5

(52)

multimech-run demo

(53)
(54)

What about when you need more

than one machine?

(55)
(56)

Bees with Machine Guns

(57)

A utility for arming (creating)

many bees (micro EC2

instances)

to attack (load test)

(58)

pip install beeswithmachineguns

(59)

# ~/.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

(60)

bees up -s 2

-g default -z us-west-2b -i ami-bc05898c

-k

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

(61)

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.

(62)

bees report

(63)

Read 2 bees from the roster.

Bee i-3828400c: running @ 54.212.22.176 Bee i-3928400d: running @ 50.112.6.191

(64)

bees attack -n 1000 -c 50 -u

http://acmedemoapp.com/

(65)

Read 2 bees from the roster. Connecting to the hive.

Assembling bees.

Each of 2 bees will fire 500 rounds, 25 at a time. Stinging URL so it will be cached for the attack. Organizing the swarm.

Offensive complete.

Complete requests: 1000

Requests per second: 306.540000 [#/sec] (mean) Time per request: 163.112000 [ms] (mean)

50% response time: 151.000000 [ms] (mean) 90% response time: 192.000000 [ms] (mean) Mission Assessment: Target crushed bee offensive.

(66)

bees attack -n 100000 -c 1000 -u

http://acmedemoapp.com/

(67)

Read 2 bees from the roster. Connecting to the hive.

Assembling bees.

Each of 2 bees will fire 50000 rounds, 500 at a time. Stinging URL so it will be cached for the attack.

Organizing the swarm. …

Offensive complete.

Complete requests: 100000

Requests per second: 502.420000 [#/sec] (mean) Time per request: 360.114000 [ms] (mean)

50% response time: 451.000000 [ms] (mean) 90% response time: 402.000000 [ms] (mean) Mission Assessment: Target crushed bee offensive.

(68)

68

Read 2 bees from the roster. Connecting to the hive.

Assembling bees.

Each of 2 bees will fire 50000 rounds, 500 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 0 lost sight of the target (connection timed out). Bee 1 lost sight of the target (connection timed out). Offensive complete.

Target timed out without fully responding to 2 bees.

No bees completed the mission. Apparently your bees are peace-loving hippies.

(69)
(70)

70

Read 2 bees from the roster. Connecting to the hive.

Calling off the swarm. Stood down 2 bees.

(71)

locust.io

(72)

 PIP  INSTALL  LOCUSTIO

(73)
(74)
(75)

LOCUST  —HOST=  

(76)
(77)
(78)

There  are  many  load  testing  tools..

Gatling.io  

Wrk  

Vegeta  

Tsung  

78

(79)
(80)

In modern web

applications more latency

comes from the

client-side than the server-client-side.

(81)
(82)

Google PageSpeed Insights

(83)
(84)
(85)
(86)

gem install wbench

(87)
(88)
(89)

Automate

client-side performance

testing with Grunt

(90)

Use Bower (for dependencies),

Grunt/Gulp (for automation),

and Yeoman (for bootstrapping)

(checkout jhipster too)

(91)

How many people understand exactly

how fast their site runs in production?

(92)

Track performance in

development and production

(93)

Instrument everything = code, databases, caches, queues, third party services, and infrastructure.

(94)

Statsd + Graphite + Grafana

(95)
(96)

Track performance of end users

(97)
(98)

webpagetest.org

(99)
(100)
(101)
(102)

SiteSpeed.io

(103)
(104)
(105)
(106)
(107)
(108)
(109)

Load testing services

from the cloud

(110)
(111)
(112)
(113)

Test for failures

NetFlix  Simian  Army  +  Chaos  Monkey

What  happens  if  you  lose  a  caching  layer?  

What  happens  if  dependencies  slow  down?

(114)

Best Practices

Treat  performance  as  a  feature  

Capacity  plan  and  load  test  the  server-­‐side  

Optimize  and  performance  test  the  client-­‐side  

Understand  your  starting  point  

Instrument  everything  

Monitor  performance  in  development  and  production  

Measure  the  difference  of  every  change  

Automate  performance  testing  in  your  build  and  

deployment  process  

Understand  how  failures  impact  performance

(115)

Integrate automated

performance testing into

continuous integration for

server-side and client-side

(116)

Understand the

performance implications

of every deployment and

package upgrade

(117)

Monitor end user

experience from end

to end in production

(118)

Questions?

(119)

Find these slides on SpeakerDeck https://speakerdeck.com/dustinwhittle

References

Related documents

Here, we report that poly(vinyl alcohol) (PVA) can form complexes with BPA through reversible boronate esters in aqueous solution, and the complex termed PVA-BPA can be

for the Fresnes library. Another experimental version is being tested. It contains data from other libraries in addition to Fresnes, displays extended

You can open the same combination of {db name}, {table name}, {index name} multiple times, possibly with different {columns list}. You can't manually

Therefore a simple tally of these House members who might have been expected to be sympathetic with a reform proposal favorable to LGUs (e.g., increasing the LGUs’ share in

If 8000 kg/hr of an Acetic acid (C) – Water (A) solution containing 30% acid, is to be counter currently extracted with Isopropyl Ether (B) to reduce the acid concentration to 2% in

nursing, pressure injury, pressure ulcer, patient safety, patient harm, policy analysis,

This study aimed at investi- gating the relations among the psychological factors alexithymia, self-reflection, insight, depression, anxiety; demographic variables; and aspects of