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.

Serverless a superpower for frontend developers

We'll look at some common mistakes JavaScript Developers make when they move to serverless and debunk misconceptions about Lambda performance and cold starts. We will also offer tips for optimizing your functions, and how best to test and deploy them using CI/CD best practices.

  • Be the first to comment

  • Be the first to like this

Serverless a superpower for frontend developers

  1. 1. serverless: by Yan Cui @theburningmonk
  2. 2. @theburningmonk theburningmonk.com
  3. 3. @theburningmonk theburningmonk.com hey guys, vote on this post and I’ll announce a winner at 10PM tonight
  4. 4. @theburningmonk theburningmonk.com 10PM traffic
  5. 5. @theburningmonk theburningmonk.com 10PM traffic 70-100x
  6. 6. @theburningmonk theburningmonk.com system couldn’t fast enough
  7. 7. @theburningmonk theburningmonk.com updates required 30 mins downtime
  8. 8. @theburningmonk theburningmonk.com features took months to deliver
  9. 9. @theburningmonk theburningmonk.com Dan North “lead time to someone saying thank you is the only reputation metric that matters.”
  10. 10. @theburningmonk theburningmonk.com 6 months, 6 devs
  11. 11. @theburningmonk theburningmonk.com 95% cost saving compared to existing EC2-based solution
  12. 12. @theburningmonk theburningmonk.com velocity went from months to days
  13. 13. @theburningmonk theburningmonk.com https://www.youtube.com/watch?v=evsz__BDprs
  14. 14. @theburningmonk theburningmonk.com https://www.youtube.com/watch?v=evsz__BDprs AppSync DynamoDB Lambda
  15. 15. Yan Cui http://theburningmonk.com @theburningmonk AWS user for 10 years
  16. 16. Yan Cui http://theburningmonk.com @theburningmonk http://bit.ly/yubl-serverless
  17. 17. Yan Cui http://theburningmonk.com @theburningmonk Developer Advocate @
  18. 18. Yan Cui http://theburningmonk.com @theburningmonk Independent Consultant advisetraining delivery
  19. 19. theburningmonk.com/courses
  20. 20. theburningmonk.com/courses
  21. 21. realworldserverless.com
  22. 22. @theburningmonk theburningmonk.com 2010
  23. 23. @theburningmonk theburningmonk.com
  24. 24. @theburningmonk theburningmonk.com
  25. 25. @theburningmonk theburningmonk.com users are distributed around the world systems have to be available 24/7
  26. 26. @theburningmonk theburningmonk.com millions of unique daily-active users
  27. 27. SCALABILITY
  28. 28. SCALABILITY RESILIENCE
  29. 29. SCALABILITY RESILIENCE SECURITY
  30. 30. SCALABILITY RESILIENCE SECURITY SPEED
  31. 31. @theburningmonk theburningmonk.com
  32. 32. @theburningmonk theburningmonk.com networking set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups
  33. 33. @theburningmonk theburningmonk.com networking VMs apply patches install dependencies create base AMI set up auto-scaling set up multi-AZ set up load balancer configure IAM roles set up logging agent set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups
  34. 34. @theburningmonk theburningmonk.com networking VMs apply patches install dependencies create base AMI set up auto-scaling set up multi-AZ set up load balancer configure IAM roles set up logging agent application set up web server configure middlewares set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups
  35. 35. @theburningmonk theburningmonk.com networking VMs apply patches install dependencies create base AMI set up auto-scaling set up multi-AZ set up load balancer configure IAM roles set up logging agent application set up web server configure middlewares write 1st line of business logic set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups
  36. 36. @theburningmonk theburningmonk.com networking VMs apply patches install dependencies create base AMI set up auto-scaling set up multi-AZ set up load balancer configure IAM roles set up logging agent application set up web server configure middlewares write 1st line of business logic set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups the only thing the customer cares about!
  37. 37. @theburningmonk theburningmonk.com
  38. 38. @theburningmonk theburningmonk.com networking VMs apply patches install dependencies create base AMI set up auto-scaling set up multi-AZ set up load balancer configure IAM roles set up logging agent application set up web server configure middlewares write 1st line of business logic set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups
  39. 39. @theburningmonk theburningmonk.com networking VMs apply patches install dependencies create base AMI set up auto-scaling set up load balancer configure IAM roles set up logging agent application set up web server configure middlewares write 1st line of business logic set up VPC set up public subnet set up private subnet set up Internet Gateway set up NAT Gateway configure Route Tables configure Network ACL configure Security Groups mooooo..
  40. 40. @theburningmonk theburningmonk.com but, nonetheless… they’re important for setting you up to succeed
  41. 41. @theburningmonk theburningmonk.com spinning up a web-server a production-ready environment!===
  42. 42. @theburningmonk theburningmonk.com “we ain’t gonna need it”
  43. 43. @theburningmonk theburningmonk.com “we ain’t gonna need it” translation: “we will never be successful”
  44. 44. @theburningmonk theburningmonk.com traffic holy crap, we’ve got traction!
  45. 45. @theburningmonk theburningmonk.com traffic oh no… our server died!
  46. 46. @theburningmonk theburningmonk.com prepare for success
  47. 47. @theburningmonk theburningmonk.com isn’t the savior?
  48. 48. @theburningmonk theburningmonk.com 0 Theory “it works on my machine!” “production ready!”days
  49. 49. @theburningmonk theburningmonk.com
  50. 50. @theburningmonk theburningmonk.com
  51. 51. @theburningmonk theburningmonk.com
  52. 52. @theburningmonk theburningmonk.com 0 Theory “it works on my machine!” “production ready!” 0 Reality “it works on my machine!” “production ready!” days days
  53. 53. @theburningmonk theburningmonk.com
  54. 54. @theburningmonk theburningmonk.com mooooo..
  55. 55. @theburningmonk theburningmonk.com scale
  56. 56. @theburningmonk theburningmonk.com scale complexity
  57. 57. @theburningmonk theburningmonk.com but our cognitive capacity hasn’t increased…
  58. 58. @theburningmonk theburningmonk.com leverage: do more with less
  59. 59. @theburningmonk theburningmonk.com EC2 EC2
  60. 60. @theburningmonk theburningmonk.com EC2 EC2 we’re still managing infrastructure
  61. 61. @theburningmonk theburningmonk.com https://bit.ly/2Im61VK “Unless you’re an infrastructure company, infrastructure is basically overhead.” Matt Klein
  62. 62. @theburningmonk theburningmonk.com infrastructure you
  63. 63. @theburningmonk theburningmonk.com Serverless means… don’t pay for it if no-one uses it don’t need to worry about scaling don’t need to provision and manage servers
  64. 64. @theburningmonk theburningmonk.com “Serverless”
  65. 65. @theburningmonk theburningmonk.com
  66. 66. @theburningmonk theburningmonk.com Gojko Adzic It is serverless the same way WiFi is wireless. http://bit.ly/2yQgwwb
  67. 67. @theburningmonk theburningmonk.com “Function-as-a-Service” AWS Lambda Azure Functions Google Cloud Functions Auth0 Webtask Spotinst Functions Kubeless IBM Cloud Functions
  68. 68. AWS Lambda
  69. 69. AWS Lambda API Gateway IOT SNS Kinesis CloudWatch
  70. 70. @theburningmonk theburningmonk.com Why serverless?
  71. 71. @theburningmonk theburningmonk.com more Scalable
  72. 72. @theburningmonk theburningmonk.com 100% SERVERLESS IN PRODUCTION
  73. 73. @theburningmonk theburningmonk.com
  74. 74. @theburningmonk theburningmonk.com 80 MILLION MONTHLY USERS
  75. 75. @theburningmonk theburningmonk.com
  76. 76. @theburningmonk theburningmonk.com Cheaper (don’t pay for idle servers)
  77. 77. @theburningmonk theburningmonk.com Resilience (built-in redundancy and multi-AZ)
  78. 78. @theburningmonk theburningmonk.com Secure
  79. 79. @theburningmonk theburningmonk.com idea production amazing VELOCITY from idea to product
  80. 80. @theburningmonk theburningmonk.com idea production choose language + framework master language + framework figure out deployment configure AMI configure ELB configure autoscaling capacity planning over-provision for launch are we doing microservices? configure CI/CD
  81. 81. @theburningmonk theburningmonk.com idea production choose language + framework master language + framework figure out deployment configure AMI configure ELB configure autoscaling capacity planning over-provision for launch are we doing microservices? configure CI/CD
  82. 82. @theburningmonk theburningmonk.com truly “fullstack” developers are rare, and expensive
  83. 83. @theburningmonk theburningmonk.com AWS Scalability Resilience Security DevOps Distributed Systems JavaScript CSS HTML SPA Framework Responsive Design Debugging
  84. 84. @theburningmonk theburningmonk.com AWS Scalability Resilience Security DevOps Distributed Systems JavaScript CSS HTML SPA Framework Responsive Design Debugging
  85. 85. @theburningmonk theburningmonk.com AWS Scalability Resilience Security DevOps Distributed Systems JavaScript CSS HTML SPA Framework Responsive Design Debugging
  86. 86. @theburningmonk theburningmonk.com AWS Scalability Resilience Security DevOps Distributed Systems JavaScript CSS HTML SPA Framework Responsive Design Debugging
  87. 87. @theburningmonk theburningmonk.com what you need to know to build a production-ready backend on AWS EC2 / Containers Serverless
  88. 88. @theburningmonk theburningmonk.com what you need to know to build a production-ready backend on AWS EC2 / Containers Serverless
  89. 89. @theburningmonk theburningmonk.com what you need to know to build a production-ready backend on AWS EC2 / Containers Serverless
  90. 90. @theburningmonk theburningmonk.com frontend focused teams can delay the point when they need a backend specialist
  91. 91. @theburningmonk theburningmonk.com backend engineers can get so much more done with less effort and stress
  92. 92. @theburningmonk theburningmonk.com https://www.youtube.com/watch?v=evsz__BDprs
  93. 93. @theburningmonk theburningmonk.com what you need to know to build a production-ready backend on AWS EC2 / Containers Serverless AWS basics, DynamoDB, Lambda, SNS, etc.
  94. 94. @theburningmonk theburningmonk.com AppSync DynamoDB Lambda ElasticSearch
  95. 95. @theburningmonk theburningmonk.com focus your time and energy on improving the UX
  96. 96. @theburningmonk theburningmonk.com the backend should “just work”
  97. 97. @theburningmonk theburningmonk.com the backend should “just work” it shouldn’t be THAT hard, and it doesn’t have to
  98. 98. @theburningmonk theburningmonk.com
  99. 99. @theburningmonk theburningmonk.com don’t use callbacks, use async-await
  100. 100. @theburningmonk theburningmonk.com avoid mixing callbacks with Promises
  101. 101. @theburningmonk theburningmonk.com too sequential
  102. 102. @theburningmonk theburningmonk.com missing Promise.all
  103. 103. @theburningmonk theburningmonk.com async-await in forEach
  104. 104. @theburningmonk theburningmonk.com not useing AWS SDK’s .promise()
  105. 105. cold starts
  106. 106. @theburningmonk theburningmonk.com INITIALISE CONTAINER INITIALISE RUNTIME INITIALISE HANDLER YOUR CODE EXECUTES
  107. 107. @theburningmonk theburningmonk.com INITIALISE CONTAINER INITIALISE RUNTIME INITIALISE HANDLER YOUR CODE EXECUTES COLD START
  108. 108. @theburningmonk theburningmonk.com “cold starts only happen to the first request”
  109. 109. @theburningmonk theburningmonk.com function invocationconcurrent execution i.e. a container
  110. 110. @theburningmonk theburningmonk.com function invocationconcurrent execution i.e. a container class instance method call
  111. 111. @theburningmonk theburningmonk.com Lambda scales the number of concurrent executions based on traffic
  112. 112. @theburningmonk theburningmonk.com existing “containers” are reused where possible
  113. 113. @theburningmonk theburningmonk.com time invocation
  114. 114. @theburningmonk theburningmonk.com time invocation invocation
  115. 115. @theburningmonk theburningmonk.com time invocation invocation
  116. 116. @theburningmonk theburningmonk.com time invocation invocation invocation invocation
  117. 117. @theburningmonk theburningmonk.com time invocation invocation invocation invocation invocation invocation
  118. 118. @theburningmonk theburningmonk.com time invocation invocation invocation invocation invocation invocation
  119. 119. @theburningmonk theburningmonk.com time invocation invocation invocation invocation invocation invocation invocation
  120. 120. @theburningmonk theburningmonk.com time invocation invocation invocation invocation invocation invocation invocation invocation
  121. 121. @theburningmonk theburningmonk.com time invocation invocation invocation invocation invocation invocation invocation invocation
  122. 122. @theburningmonk theburningmonk.com time invocation invocation invocation invocation invocation invocation invocation invocation
  123. 123. @theburningmonk theburningmonk.com
  124. 124. @theburningmonk theburningmonk.com
  125. 125. @theburningmonk theburningmonk.com
  126. 126. @theburningmonk theburningmonk.com
  127. 127. @theburningmonk theburningmonk.com FREQUENCY DURATION
  128. 128. @theburningmonk theburningmonk.com FREQUENCY DURATION dictated by user traffic, out of your control
  129. 129. @theburningmonk theburningmonk.com FREQUENCY DURATION optimize this!
  130. 130. @theburningmonk theburningmonk.com if you need good cold start performance DON’T run express.js in a Lambda
  131. 131. @theburningmonk theburningmonk.com “Lambda is not a suitable solution for me because of cold starts”
  132. 132. @theburningmonk theburningmonk.com “what is your latency requirement?”
  133. 133. @theburningmonk theburningmonk.com cold starts that don’t add to user-facing latency is generally not worth worrying about
  134. 134. @theburningmonk theburningmonk.com sporadic spikes latency existed before Lambda
  135. 135. @theburningmonk theburningmonk.com GC pauses…
  136. 136. @theburningmonk theburningmonk.com overloaded servers…
  137. 137. @theburningmonk theburningmonk.com slow downstream, databases, etc.
  138. 138. @theburningmonk theburningmonk.com networking issues…
  139. 139. @theburningmonk theburningmonk.com cold starts is generally not an issue if you have a steady traffic pattern
  140. 140. @theburningmonk theburningmonk.com time req/s
  141. 141. @theburningmonk theburningmonk.com time req/s El Classico
  142. 142. @theburningmonk theburningmonk.com time req/s lunch dinner
  143. 143. @theburningmonk theburningmonk.com minimise the duration of cold starts so they fall within acceptable latency range
  144. 144. @theburningmonk theburningmonk.com require specific clients instead of the full AWS SDK
  145. 145. @theburningmonk theburningmonk.com use webpack to bundle functions during deployment
  146. 146. @theburningmonk theburningmonk.com
  147. 147. @theburningmonk theburningmonk.com then, consider using Provisioned Concurrency as a fallback
  148. 148. @theburningmonk theburningmonk.com time req/s lunch dinner Provisioned Concurrency
  149. 149. @theburningmonk theburningmonk.com time req/s lunch dinner Provisioned Concurrency On-Demand Concurrency
  150. 150. @theburningmonk theburningmonk.com there are no silver bullets
  151. 151. @theburningmonk theburningmonk.com Provisioned Concurrency is a powerful tool IFF you have a cold start problem DON’T use it by default
  152. 152. theburningmonk.com/hire-me AdviseTraining Delivery “Fundamentally, Yan has improved our team by increasing our ability to derive value from AWS and Lambda in particular.” Nick Blair Tech Lead
  153. 153. homeschool.dev/class/production-ready-serverless 15% OFF WITH “YANPRS15”
  154. 154. @theburningmonk theburningmonk.com github.com/theburningmonk 159

    Be the first to comment

We'll look at some common mistakes JavaScript Developers make when they move to serverless and debunk misconceptions about Lambda performance and cold starts. We will also offer tips for optimizing your functions, and how best to test and deploy them using CI/CD best practices.

Views

Total views

526

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

1

Shares

0

Comments

0

Likes

0

×