Betting on Performance
a note on hypothesis-driven performance testing
James Lewis : @boicy
Betting on Performance a note on hypothesis-driven performance - - PowerPoint PPT Presentation
Betting on Performance a note on hypothesis-driven performance testing James Lewis : @boicy 2 How do we usually make decisions about architecture, design and performance? based on experience based on gut feel and often times up front 3 Can we
a note on hypothesis-driven performance testing
James Lewis : @boicy
How do we usually make decisions about architecture, design and performance?
based on experience based on gut feel and often times up front
Can we make design decisions more systematically?
and what would that look like?
History
The lawful good product owners of the publishing house had long lived in awe and fear of their publishing systems. In awe, for they had made a tremendous amount of Gold, but in fear of the time taken to change them, their slowness and their fragility. A messenger was sent to fetch help from a distant land famed for it’s mighty wizards. You have taken up the challenge…
link to close link hello close
1.
You must save the product owners by rebuilding their website. You start off the project. In the course of discussions you discover that your goals are three fold:
An Enterprise Architect approaches and addresses you. You may use:
Summon Walking Skeleton
turn to 4 Analysis Paralysis turn to 3
If you have none of these you will have to draw your sword and fight (turn to 178)
link to close link hello close
1.
You must save the product owners by rebuilding their website. You start off the project. In the course of discussions you discover that your goals are three fold:
An Enterprise Architect approaches and addresses you. You may use:
Summon Walking Skeleton
turn to 4 Analysis Paralysis turn to 3
If you have none of these you will have to draw your sword and fight (turn to 178)
link to close link hello close
3.
You cast Analysis Paralysis at the Enterprise Architect. “Foolish young adventurer” says the architect, “we follow the evolutionary school of architecture and we shall have none of the lawful-evil ways of waterfall”. The last thing you see before everything goes dark is the architect incanting in a strange voice. You have died. Turn to page 1.
link to close link hello close
1.
You must save the product owners by rebuilding their website. You start off the project. In the course of discussions you discover that your goals are three fold:
An Enterprise Architect approaches and addresses you. You may use:
Summon Walking Skeleton
turn to 4 Analysis Paralysis turn to 3
If you have none of these you will have to draw your sword and fight (turn to 178)
link to close link hello close
4.
Your walking skeleton coalesces in a cloud of noxious gasses and solidifies as a java dropwizard application. You reach into your backpack and deploy the content store. Your walking skeleton reaches out it’s skeletal arms and grabs armfuls of raw xml. Would you like to:
S3
Transform the xml inside the skeleton turn to 6 Use a magic box turn to 5
link to close link hello close
monolithic MVC
transformations and rendering happen in process distributed system Transform content within the walking skeleton create another service to transform content
Option Option Option $ $ $ Evolutionary Architecture allows us to place small bets and then re- evaluate our decisions based on outcomes Option Option Option $ $$$$$$$$$ $ Up front design “bets the house”. It collapses the options by presupposing the answer (and that there is an answer)
5.
You throw the magic box in between the walking skeleton and the content store. A villager approaches and exclaims: “this beautiful content I see in front
time to get here” You must somehow make the content arrive faster. If you have a http cache in your inventory, you may use it now.
S3
Cache in between S3 and content turn to 10
content
Cache in between skeleton and content turn to 33
link to close link hello close
ESI / Templating
Computationally expensive service
XML in S3 Xslt
21
0.8 seconds for first byte 1.5 seconds for page load
Page Load (sec) 10 20 30 40 Initial observations 1 35
0.8 seconds for first byte 1.5 seconds for page load
ESI / Templating
Computationally expensive service
XML in S3 Xslt
We’ve detected performance problems
ESI / Templating
Computationally expensive service
XML in S3 Xslt
ESI / Templating
Computationally expensive service
XML in S3 Xslt
Page Load (secs)
Cache misses predominate
Page Load (secs)
Cache hits predominate
There are only two hard things in Computer Science: cache invalidation and naming things.
Bonus Joke
There are only two hard things in messaging:
a note on hypothesis-driven performance testing
a note on hypothesis-driven performance testing
a note on hypothesis-driven performance testing
“In general, we look for a new law by the following process: First we guess it; then we compute the consequences of the guess to see what would be implied if this law that we guessed is right; then we compare the result of the computation to nature, with experiment or experience, compare it directly with
it is wrong. In that simple statement is the key to science. It does not make any difference how beautiful your guess is, it does not make any difference how smart you are, who made the guess, or what his name is — if it disagrees with experiment, it is wrong”
Compute implications Compare with Nature Draw conclusion Observe nature Make a guess
Compute implications Compare with Nature Draw conclusion Observe nature Make a guess
Observe metrics Measure results Was I right? Make a small change Guess
Compute implications Compare with Nature Draw conclusion Observe nature Make a guess
Lightweight probes Ability to quickly deploy small changes Observable systems A brain
practices that enable small bets* *not exhaustive
Instrumentation Telemetry Visualisation Alerting Predictive alerting
Our code and hardware describes what it’s doing We have a way of gathering the data from our services We can meaningfully visualise our systems behaviour We can take action based on this information We can predict in advance when something may go wrong
credit: Dan North
Service Service request latency downstream dependencies OS metrics health request tracing
42
Codahale Metrics Dropwizard Tenacity Circuit Breakers Breaker Box Yammer
Safely and sustainably reduce lead time to value
Compute implications Compare with Nature Draw conclusion Observe nature Make a guess
ApacheBench
ab -n 100 -c 10 “http://sciencesite.com/articles/9dfa1ae0-6ba5-4f2f-…”
Siege Vegeta
echo "GET http://sciencesite.com/“ | vegeta attack -duration=60s -rate=10
Cloud native infrastructure as code
Compute implications Compare with Nature Draw conclusion Observe nature Make a guess
Lightweight probes Ability to quickly deploy small changes Good monitoring A brain
Page Load (sec) 10 20 30 40 Initial observations 1 35
0.8 seconds for first byte 1.5 seconds for page load
Option: Add CPU Option: Cache S3 content Option: Cache Service content
Compute implications Compare with Nature Draw conclusion Observe nature Make a guess XSLT can be expensive - maybe we are CPU bound Increasing the # of CPU’s could help
Page load (sec) 10 20 30 40 After adding more CPU’s 1 2 35 6
Second Guess: Moving compute to the data
Page load (sec) 10 20 30 40 Move closer to the data 1 2 3 35 6 4
Third Guess: Transformations are slow and could be optimised
Page load (sec) 10 20 30 40 Tune xslt transforms 1 2 3 4 35 6 4 3.5
Final Guess: And, cache
ESI / Templating
Computationally expensive service
XML in S3 Xslt
Page load (sec) 10 20 30 40 After adding a cache 1 2 3 4 5 35 6 4 3.5 0.2
Do we add a cache? create another service to transform content
saves the fetch from S3 saves the xslt transform time saves the fetch from S3 Cache in front of content service Cache in front of S3
150.
Content trickles into the store. You keep up by listening for the new content and casting “wget” on the cache to keep it refreshed. New types of content appears - content the villagers have never seen
is unable to combat. Every time the structure of the content changes, the cache must be
grows until it is the size of the Great Wahui of Berathorob. It is no longer possible to refresh it. Latency increases.
link to close link hello close
You have died. Turn to page 1.
Cache in front of S3 Cache in front of content service
10.
The cache causes the content load times to drop from 300ms to 150ms. The villager says “this wonderful content is now arriving more swiftly than even the knight-messengers of the Empress”. The villagers are happy but all too soon, all is not well for the content has a long tail. You must work out how to refresh the content when it changes. You can either:
Refresh the content when it appears from the ether turn to 150 Trust that it will be fast enough on first view turn to 22
link to close link hello close
4.
Your walking skeleton coalesces in a cloud of noxious gasses and solidifies as a java dropwizard application. You reach into your backpack and deploy the S3 content store. Your walking skeleton reaches out it’s skeletal arms and grabs armfuls of raw xml. Would you like to:
Transform the xml inside the skeleton turn to 6 Use a magic box turn to 5
Real Options, Small Bets
rapidly change all the things
Cloud Native, CD for infra
run experiments
performance testing doesn’t have to be heavy weight
instrumentation, telemetry, visualisation
Evolutionary Architecture keeps our options open Continuous Delivery, lean product engineering and Infrastructure as Code reduce the amount of money we need to place a bet (so we can place more) Lightweight performance testing early allows us to make guesses and test
James Lewis : @boicy
https://www.thoughtworks.com/radar
Oh Hi!