responding in a timely manner
play

Responding in a timely manner Martin Thompson - @mjpt777 Hard - PowerPoint PPT Presentation

Responding in a timely manner Martin Thompson - @mjpt777 Hard Real-time Soft Real-time Squidgy Real-time The Unaware 1. How to Test and Measure 2. A little bit of Theory 3. A little bit of Practice 4. Common Pitfalls 5. Useful Algorithms and


  1. Responding in a timely manner Martin Thompson - @mjpt777

  2. Hard Real-time

  3. Soft Real-time

  4. Squidgy Real-time

  5. The Unaware

  6. 1. How to Test and Measure 2. A little bit of Theory 3. A little bit of Practice 4. Common Pitfalls 5. Useful Algorithms and Techniques

  7. Test & Measure

  8. System Under Test

  9. Distributed Load Generation Agents System Under Test

  10. Distributed Load Generation Agents System Under Test

  11. Distributed Load Generation Agents System Under Test

  12. Distributed Load Observer Generation Agents System Under Test

  13. Setup a continuous Pro Tip: performance testing environment

  14. Pro Tip: Record Everything

  15. Latency Histograms

  16. Latency Histograms Mode

  17. Latency Histograms Mode Median

  18. Latency Histograms Mode Mean Median

  19. System: 1000 TPS, mean RT 50µs

  20. System: 1000 TPS, mean RT 50µs What is the mean if you add in a 25ms GC pause per second?

  21. System: 1000 TPS, mean RT 50µs What is the mean if you add in a 25ms GC pause per second? ~300µs

  22. Forget averages, it’s all about percentiles

  23. Coordinated Omission Source: Gil Tene (Azul Systems)

  24. Pro Tip: Don’t deceive yourself

  25. Theory

  26. Queuing Theory 12.0 10.0 8.0 Response Time 6.0 4.0 2.0 0.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 Utilisation

  27. Queuing Theory Kendall Notation M/D/1

  28. Queuing Theory r = s(2 – ρ ) / 2(1 – ρ ) r = mean response time s = service time ρ = utilisation

  29. Queuing Theory r = s(2 – ρ ) / 2(1 – ρ ) r = mean response time s = service time ρ = utilisation Note: ρ = λ * (1 / s)

  30. Queuing Theory 12.0 10.0 8.0 Response Time 6.0 4.0 2.0 0.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 Utilisation

  31. Ensure that you have Pro Tip: sufficient capacity

  32. Queuing Theory Little’s Law: L = λ * W L = mean queue length λ = mean arrival rate W = mean time in system

  33. Bound queues to meet Pro Tip: response time SLAs

  34. Can we go parallel to speedup?

  35. Amdahl’s Law time Sequential Process A B

  36. Amdahl’s Law time Sequential Process A B Parallel Process A A B A A A

  37. Amdahl’s Law time Sequential Process A B Parallel Process A A B A A A Parallel Process B A B B B B

  38. Amdahl's Law

  39. Universal Scalability Law C(N) = N / (1 + α (N – 1) + (( β * N) * (N – 1))) C = capacity or throughput N = number of processors α = contention penalty β = coherence penalty

  40. Universal Scalability Law 20 18 16 14 12 Speedup 10 8 6 4 2 0 1 2 4 8 16 32 64 128 256 512 1024 Processors Amdahl USL

  41. What about the service time?

  42. Order of Algorithms

  43. Practice

  44. Pitfalls

  45. Modern Processors SMIs? P & C States??? Hyperthreading?

  46. Non-Uniform Memory Architecture (NUMA) ... ... Registers/Buffers C 1 C n C 1 C n <1ns ... ... L1 L1 L1 L1 ~4 cycles ~1ns ... ... L2 L2 L2 L2 ~12 cycles ~3ns P & C ~40 cycles ~15ns States??? L3 L3 ~60 cycles ~20ns (dirty hit) PCI-e 3 PCI-e 3 MC QPI QPI MC QPI ~40ns DRAM DRAM DRAM DRAM 40X 40X ~65ns IO IO DRAM DRAM DRAM DRAM * Assumption: 3GHz Processor

  47. Virtual Memory Management Page Flushing & IO Scheduling Transparent Huge Pages Swap??? vm.min_free_kbytes

  48. Safepoints in the JVM Garbage Collection, De-optimisation, Biased Locking, Stack traces, etc.

  49. Virtualization System Calls

  50. Notification public class SomethingUseful { // Lots of useful stuff public void handOffSomeWork() { // prepare for handoff synchronized (this) { someObject.notify(); } } }

  51. Notification public class SomethingUseful { // Lots of useful stuff public void handOffSomeWork() { // prepare for handoff synchronized (this) { someObject.notify(); } } }

  52. Law of Leaky Abstractions “All non -trivial abstractions, to some extent, are leaky.” - Joel Spolsky

  53. Law of Leaky Abstractions “The detail of underlying complexity cannot be ignored.”

  54. Mechanical Sympathy

  55. Responding in the presence of failure

  56. Algorithms & Techniques

  57. Clean Room Experiments • sufficient CPUs • intel_idle.max_cstate=0 • cpufreq • isocpus • numctl, cgroups, affinity • “Washed” SSDs • network buffer sizing • jHiccup • tune your stack! • Mechanical Sympathy

  58. Profiling

  59. Incorporate telemetry Pro Tip: and histograms

  60. Smart Batching Latency Typical Possible Load

  61. Smart Batching Producers

  62. Smart Batching << Amortise Expensive Costs >> Batcher Producers

  63. Amortise the Pro Tip: Expensive Costs

  64. Applying Backpressure Gateway Services Threads Network Network Stack Stack Customers Transaction Service Threads Network Stack IO Storage

  65. Non-Blocking Design “Get out of your own way!” • Don’t hog any resource • Always try to make progress • Enables Smart Batching

  66. Beware of Pro Tip: hogging resources in synchronous designs

  67. Lock-Free Concurrent Algorithms • Agree protocols of interaction • Don’t get a 3 rd party involved, i.e. the OS • Keep to user-space • Beat the “notify()” problem

  68. Observable State Machines

  69. Observable state Pro Tip: machines make monitoring easy

  70. Cluster for Response and Resilience Sequencer Service A Service A

  71. Cluster for Response and Resilience Sequencer Service A Service A

  72. Cluster for Response and Resilience Sequencer Service A Service A Service N

  73. Data Structures and O(?) Models Is there a world beyond maps and lists?

  74. In closing…

  75. The Internet of Things (IoT) “There will be X connected devices by 2020...” Where X is 20 to 75 Billion

  76. If you cannot control arrival rates...

  77. ...you have to think hard about improving service times!

  78. ...and/or you have to think hard about removing all contention!

  79. Questions? Blog: http://mechanical-sympathy.blogspot.com/ Twitter: @mjpt777 “ It does not matter how intelligent you are, if you guess and that guess cannot be backed up by experimental evidence – then it is still a guess.” - Richard Feynman

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend