IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... ·...
Transcript of IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... ·...
![Page 1: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/1.jpg)
IT’S ALL A NUMBERS GAME
THE DIRTY LITTLE SECRET OF SCALABLE SYSTEMS
Martin Thomson
@mjpt777
http://mechanical-sympathy.blogspot.com/
![Page 2: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/2.jpg)
![Page 3: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/3.jpg)
![Page 4: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/4.jpg)
![Page 5: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/5.jpg)
What does it mean to be Scalable?
Total Cost
Volume
OK? Bad?
Good?
![Page 6: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/6.jpg)
It’s all about cost per Transaction
Transaction Cost = Total Costs / Transaction Volume
• Fixed Costs
> Upfront effort and infrastructure
> Need to amortize
> Capital vs. Operational spend
> How well do you know demand?
• Variable Costs
> Can they be on demand?
> Bulk discounts
> Guaranteeing available resources
![Page 7: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/7.jpg)
How Many TPS Does An Additional Node Provide?
![Page 8: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/8.jpg)
“Just throw hardware at the problem”
![Page 9: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/9.jpg)
Guidelines for scalable systems
1. Domain Model at the Core
2. Performance Test & Profile
3. Understand Algorithm Behaviour
4. Eliminate Contention
5. Manage the Queues
6. Separate Reading and Writing
7. Know Your Platform/Infrastructure
8. Be Commercial
![Page 10: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/10.jpg)
1. Domain Model at the Core
• Pure model without any infrastructure
• Aggregates for clear entry points
• Minimal public interface
• Clean simple code!
• Layer around the core
“Hexagonal Architecture”
- Alistair Cockburn
![Page 11: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/11.jpg)
2. Performance Test & Profile
• Component Performance Tests
• System Performance Tests
• Production Monitoring
• Common performance test mistakes
• Theory of Constraints
• Drives the economics of a development
“Premature optimization is the root of all evil” – Donald Knuth / Tony Hoare
> This is very different from knowing your capabilities, so test and profile early and often…
![Page 12: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/12.jpg)
3. Understand Algorithm Behaviour
• Test cases with a set of size of 1 – Really!
• Need to model realistic scenarios
• Model based on production
• Cache Oblivious Algorithms
• Unbounded queries are very bad
> Deal in manageable chunks
![Page 13: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/13.jpg)
4. Eliminate Contention
• Contention needs managed
> Management overhead often greater than actual work – e.g. locks
• Micro, Macro – all the same
> Lessons from the Disruptor
> Services and Databases
> “Load Balancers”
• Employ the “Single Writer Principle”
• Shared Nothing Architectures
• Design to allow sharding for writes
![Page 14: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/14.jpg)
5. Manage the Queues
• Little’s Law
• Queues are everywhere!
> Make them explicit
> Keep them bounded
> Apply back pressure
• Queues manage contention but are also a source of contention
• Monitor queue lengths
• The Curse of Logging Libraries
![Page 15: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/15.jpg)
6. Separate Reading and Writing
• One of the best ways to relieve contention
> Normally reads greatly outnumber writes
• Event Sourcing and CQRS
• Append Only Persistence
> Even for traditional RDBMSs
• Caching
> Reference Data
> Fact based Data
> Perfect != Right
![Page 16: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/16.jpg)
7. Know Your Platform/Infrastructure
• Mechanical Sympathy
> What are the platform capabilities?
> Operations Per Second
> Bandwidth
> Latency
• Load test until breaking point
> Do systems degrade gracefully?
> Do systems crash?
> Order of an algorithm?
> Failure and Replicas
![Page 17: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/17.jpg)
8. Be Commercial
• Understand the Business
> It is way more fun and rewarding
> Build a business using your great software
• Never say, “No”
> “Yes, and here are the consequences…”
• Build relationships
> Go for a coffee with others in the business
> Eat together
> Great Teams can be formed without formal structure
> Have fun!
![Page 18: IT’S ALL A NUMBERS GAMEgotocon.com › dl › goto-aar-2012 › slides › MartinThompson... · 2. Performance Test & Profile •Component Performance Tests •System Performance](https://reader034.fdocuments.us/reader034/viewer/2022042407/5f2101dcd78b8034c4455b1f/html5/thumbnails/18.jpg)
Questions?
Blog: http://mechanical-sympathy.blogspot.com/
Twitter: @mjpt777