Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Applying principles of chaos engineering to serverless

1,268 views

Published on

Chaos engineering is a discipline that focuses on improving system resilience through experiments that expose the inherent chaos and failure modes in our system, in a controlled fashion, before these failure modes manifest themselves like a wildfire in production and impact our users.

Netflix is undoubtedly the leader in this field, but much of the publicised tools and articles focus on killing EC2 instances, and the efforts in the serverless community has been largely limited to moving those tools into AWS Lambda functions.

But how can we apply the same principles of chaos to a serverless architecture built around AWS Lambda functions?

These serverless architectures have more inherent chaos and complexity than their serverful counterparts, and, we have less control over their runtime behaviour. In short, there are far more unknown unknowns with these systems.

Can we adapt existing practices to expose the inherent chaos in these systems? What are the limitations and new challenges that we need to consider?

Join us in this talk as Yan Cui shares his thought experiments, and actual experiments, in his pursuit to understand how we can apply the principles of chaos to a serverless architecture. A word of warning though, you’re guaranteed to walk away with more questions than answers!

Published in: Technology
  • Be the first to comment

Applying principles of chaos engineering to serverless

  1. 1. APPLYING PRINCIPLES to SERVERLESSt a b chaos engineering of A E S of
  2. 2. Yan Cui http://theburningmonk.com @theburningmonk
  3. 3. history of Smallpox est. 400K deaths per year in 18th Century Europe. earliest evidence of disease in 3rd Century BC Egyptian Mummy
  4. 4. history of Smallpox est. 400K deaths per year in 18th Century Europe. earliest evidence of disease in 3rd Century BC Egyptian Mummy 1798 first vaccine developed Edward Jenner
  5. 5. 1798 first vaccine developed 1980 history of Smallpox Edward Jenner WHO certified global eradication est. 400K deaths per year in 18th Century Europe. earliest evidence of disease in 3rd Century BC Egyptian Mummy
  6. 6. Vaccination is the most effective method of preventing infectious diseases
  7. 7. stimulates the immune system to recognize and destroy the disease before contracting the disease for real
  8. 8. Chaos Engineering controlled experiments to help us learn about our system’s behaviour and build confidence in its ability to withstand turbulent conditions
  9. 9. it’s about building confidence, NOT breaking things
  10. 10. I’m gonna inject you with a deadly disease now
  11. 11. http://principlesofchaos.org
  12. 12. STEP 1. define “Steady State” aka. what does normal, working condition looks like?
  13. 13. this is not a steady state
  14. 14. STEP 2. hypothesize steady state will continue in both control group & the experiment group ie. you should have a reasonable degree of confidence the system would handle the failure before you proceed with the experiment
  15. 15. explore unknown unknowns away from production
  16. 16. treat production with the care it deserves
  17. 17. the goal is NOT, to actually hurt production
  18. 18. If you know the system would break, and you did it anyway… then it’s NOT a chaos experiment. It’s called being IRRESPONSIBLE.
  19. 19. STEP 3. inject realistic failures e.g. server crash, network error, HD malfunction, etc.
  20. 20. https://github.com/Netflix/SimianArmy
  21. 21. https://github.com/Netflix/SimianArmy http://oreil.ly/2tZU1Sn
  22. 22. STEP 4. disprove hypothesis i.e. look for difference with steady state
  23. 23. if a WEANESS is uncovered, improve it before the behaviour manifests in the system at large
  24. 24. Chaos Engineering controlled experiments to help us learn about our system’s behaviour and build confidence in its ability to withstand turbulent conditions
  25. 25. Chaos Engineering controlled experiments to help us learn about our system’s behaviour and build confidence in its ability to withstand turbulent conditions
  26. 26. communication
  27. 27. ensure everyone knows what you’re doing
  28. 28. ensure everyone knows what you’re doing NO surprises!
  29. 29. communication Timing
  30. 30. run experiments during office hours
  31. 31. avoid important dates
  32. 32. communication Timing contain Blast radius
  33. 33. smallest change that allows you to detect a signal that steady state is disrupted
  34. 34. rollback at the first sign of TROUBLE!
  35. 35. communication Timing contain Blast radius
  36. 36. Don’t try to run before you know how to walk.
  37. 37. by Russ Miles @russmiles source https://medium.com/russmiles/chaos-engineering-for-the-business-17b723f26361
  38. 38. chaos monkey kills an EC2 instance latency monkey induces artificial delay in APIs chaos gorilla kills an AWS Availability Zone chaos kong kills an entire AWS region
  39. 39. there is no server…
  40. 40. there is no server… that you can kill
  41. 41. there are more inherent chaos and complexity in a Serverless architecture
  42. 42. smaller units of deployment and A LOT more of them!
  43. 43. more difficult to harden around boundaries serverful serverless
  44. 44. ? SNS Kinesis CloudWatch Events CloudWatch LogsIoT DynamoDB S3 SES
  45. 45. ? SNS Kinesis CloudWatch Events CloudWatch LogsIoT DynamoDB S3 SES more intermediary services, and greater variety too
  46. 46. ? SNS Kinesis CloudWatch Events CloudWatch LogsIoT DynamoDB S3 SES more intermediary services, and greater variety too each with its own set of failure modes
  47. 47. serverful serverless more configurations, more opportunities for misconfiguration
  48. 48. more unknown failure modes in infrastructure that we don’t control
  49. 49. often there’s little we can do when an outage occurs in the platform
  50. 50. improperly tuned timeouts
  51. 51. missing error handling
  52. 52. missing fallback when downstream is unavailable
  53. 53. LATENCY INJECTION
  54. 54. STEP 1. define “Steady State” aka. what does normal, working condition looks like?
  55. 55. what metrics do you monitor?
  56. 56. 9X-percentile latency error count yield (% of requests completed) harvest (completeness of results)
  57. 57. STEP 2. hypothesize steady state will continue in both control group & the experiment group ie. you should have a reasonable degree of confidence the system would handle the failure before you proceed with the experiment
  58. 58. API Gateway
  59. 59. consider the effect of cold-starts & API Gateway overhead
  60. 60. use short timeout for API calls
  61. 61. the goal of a timeout strategy is to give HTTP requests the best chance to succeed, provided that doing so does not cause the calling function itself to err
  62. 62. fixed timeout are tricky to get right…
  63. 63. fixed timeout are tricky to get right… too short and you don’t give requests the best chance to succeed
  64. 64. fixed timeout are tricky to get right… too long and you run the risk of letting the request timeout the calling function
  65. 65. and it gets worse when you make multiple API calls in one function…
  66. 66. set the request timeout based on the amount of invocation time left
  67. 67. log the timeout incident with as much context as possible e.g. timeout value, correlation IDs, request object, …
  68. 68. report custom metrics
  69. 69. be mindful when you sacrifice precision for availability, user experience is the king
  70. 70. STEP 3. inject realistic failures e.g. server crash, network error, HD malfunction, etc.
  71. 71. where to inject latency?
  72. 72. hypothesis: function has appropriate timeout on its HTTP communications and can degrade gracefully when these requests time out
  73. 73. should also be applied to 3rd parties services we depend on, e.g. DynamoDB
  74. 74. what’s the blast radius?
  75. 75. http client public-api-a http client public-api-b internal-api
  76. 76. hypothesis: all functions have appropriate timeout on their HTTP communications to this internal API, and can degrade gracefully when requests are timed out
  77. 77. large blast radius, risky..
  78. 78. could be effective when used away from production environment, to weed out weaknesses quickly
  79. 79. not priming developers to build more resilient systems
  80. 80. development
  81. 81. development production
  82. 82. Priming (psychology): Priming is a technique whereby exposure to one stimulus influences a response to a subsequent stimulus, without conscious guidance or intention. It is a technique in psychology used to train a person's memory both in positive and negative ways.
  83. 83. make dev environments better resemble the turbulent conditions you should realistically expect your system to survive in production
  84. 84. hypothesis: the client app has appropriate timeout on their HTTP communication with the server, and can degrade gracefully when requests are timed out
  85. 85. STEP 4. disprove hypothesis i.e. look for difference with steady state
  86. 86. how to inject latency?
  87. 87. static weaver (e.g. AspectJ, PostSharp), or dynamic proxies
  88. 88. https://theburningmonk.com/2015/04/design-for-latency-issues/
  89. 89. manually crafted wrapper library
  90. 90. configured in SSM Parameter Store
  91. 91. no injected latency
  92. 92. with injected latency
  93. 93. factory wrapper function (think bluebird’s promisifyAll function)
  94. 94. ERROR INJECTION
  95. 95. failures are INEVITABLE
  96. 96. the only way to truly know your system’s resilience against failures is to test it through controlled experiments
  97. 97. vaccinate your serverless architecture against failures
  98. 98. Yan Cui http://theburningmonk.com @theburningmonk
  99. 99. @theburningmonk theburningmonk.com github.com/theburningmonk

×