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.
Getting Started with
Serverless Architectures
Email: {anything}@jedberg.net
Twitter: @jedberg
Web: www.jedberg.net
Faceboo...
λ
Test and prod are different
Prod is in need of constant
updates
Slow iteration and deployment
Polyglot unfriendly
Deploy i...
Prod is immutable
Rapid iteration and deployment
Multi-tenancy
Polyglot friendly
Deploy in minutes, live for weeks
Virtual...
Test and prod are the same
Prod is immutable
Rapid(er) iteration and deployment
High multi-tenancy
Polyglot friendly
Deplo...
Smallest unit of compute
Super scalable
Rapid iteration
Extreme multi-tenancy
Very polyglot friendly
Easier to collaborate...
A whole lot of choices
Amazon’s EcosystemHodgepodge of services
A whole lot of choices
Amazon’s Serverless
Ecosystem
Lambda
SNS
DynamoDB
SQS
S3
Kenisis
Continuous
scaling
No servers to
manage
Never pay for
idle – No cold
servers (only
happy
accountants)
Benefits of AWS Lamb...
What is serverless anyway?
• There are still servers, you just
don’t manage them anymore
• It also means you don’t access
...
What is Serverless Computing?
• VMs
• Machine as the unit of scale
• Abstracts the hardware
• Containers
• Application as ...
How do I choose?
• VMs
• “I want to configure machines,
storage, networking, and my OS”
• Containers
• “I want to run serv...
Serverless computing is
all about speeding up
development by allowing
rapid iteration and
removing management
overhead
A brief journey through history
80’s Mainframe Cycle
• Cost $1MM to $100MM
• 1 to 5 years to execute
• Usually had to bet the whole
company
• Cost of fail...
90‘s Client/Server Cycle
• Cost $100K to $10MM
• 3 to 6 months to execute
• Usually had to bet a product or
division
• Cos...
00‘s Agile Cycle
• Cost $10K to $1MM
• 3 to 6 weeks to execute
• Bet a product feature
• Cost of failure -- product manage...
Product Manager
Developer
QA
Ops
BI / Analytics
Cost and size
of risk
decreased
Rate of
change
increased
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
Multiple services
Internal Microservices Platform
Monolithic
Success follows a standard
pattern
Distributed Computing and a
Distributed Workforce
• The two go hand in
hand when you have
a good distributed
systems cultu...
• Services are built by different
teams who work together to
figure out what each service
will provide.
• The service owne...
The Microservices Architecture
Microservices Tools
Web Servers
Code Libraries
Frameworks
Config Management
API Management
Deployment, CI/CDContainers
etc...
Amazon’s Microservices
Tools
What do all the parts of
microservices have in common?
Servers
Capacity planning
Right-sizing
Autoscaling
Load and performance
Patches
Tuning
Configuration
Utilization
Access co...
Serverless
Right-sizing
Autoscaling
Load and performance
Patches
Tuning
Configuration
Utilization
Access control
Packages ...
What is Lambda?
Serverless, event-driven compute service
Lambda == microservice without managing servers
What does Lambda do for you?
• Scales server capacity
automatically
• API to trigger execution
• Ensures function is execu...
Monitoring
• Everything is in Cloudwatch or Cloudwatch logs
Pricing
• Choose your RAM
from 128MB to
1500MB
• CPU and Network
scaled based on
RAM
Cost Comparison
Cost Comparison
There’s about 2.5M seconds in a month, so 3M requests is about 1.2 per second
The T2.Small is $18.98 a mon...
Lambda allows for a
tight feedback loop
• We turned around
both these
requests in less
than a day
How does work?λ
Author your code
• AWS SDK built in
• Access to /tmp,
processes,
threads, etc
λ
• NodeJS, Python
• Java and any JVM
langua...
Choose an event source
• S3
• Kinesis
• SNS
• DynamoDB
• CloudWatch
λ
• Config Rules
• Amazon Echo
• API Gateway
• Lambda
...
Choose a Network
• Default
• All functions have
internet access
• No access to your
other VPCs
• Still in a VPC
λ
• Custom...
Deploy your code
• Use the GUI or
• Upload to S3 or
Lambda directly
λ
Write the function
Create the IAM role
Add extra permissions for a push model
Zip the function and dependencies
Test the f...
Write the function
Create the IAM role
Add extra permissions for a push model
Zip the function and dependencies
Test the f...
Word Generator
• Generate some number of English
looking words using an ngram
database
• Allow a prefix to be specified
Demo
ECS
Architecture
Lambda
Lambda DynamoDB
SNS
Kinesis
Slack
router.py
Call out to other Lambda
functions
Add their results as attachments
to the message
router.py
Demo
From conception to prod
in 5 minutes
Red/Black,
Blue/Green,
Mauve/Chartreuse
Codebase
Structure
Frontend vs Backend
Repos
Lambda lets you manage your
code and infrastructure in the
same place (as long as you use
Kappa or something like it).
Example use cases
Live video stream processing
Cloudfront S3
Ingest
Lambda Functions
HQ Copy
480p
Transcode
360p
Transcode
Audio Only
Transc...
Serverless Website
S3
Static
Content
Dynamic
Content
API Gateway Lambda DynamoDB
Use Cases
• Application Backend
• Data Processing
• Command and Control
• Any functional or event
based system
Tips and Tricks
• Limit your function size (JVM
startup time especially)
• Remember execution is async
• Don’t assume func...
Tips and Tricks
• Remember the 500MB in /tmp
• Use function aliases
• Use the included logger
Tips and Tricks
• Set up alarms on all Lambda
Cloudwatch metrics
• Avoid throttling by using SNS
between any service, such...
Avoiding Infinte Loops
• With a distributed
team, this is an easy
mistake to make
• To avoid it, pass a call
stack and che...
Store your data properly
• No local instance
access
• Store everything in
S3, DynamoDB, or
Elasticache
DynamoDB S3
• zip up with
dependencies
• roles and permissions
• dev vs prod
• aliases
Difficulties we’ve solved
Problems we still have
• efficient dependency usage
• local dev environments
• making sure we have the same
dependencies
•...
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
ReleaseTestBuild
Next Steps
• efficient dependency usage
• local dev environments
• making sure we have the same
dependencies
• knowing when someone e...
• efficient dependency usage
• local dev environments
• making sure we have the same
dependencies
• knowing when someone e...
Testing
• You can’t test the
network, but a good
application test should
obviate the need to do so.
• Not really a solved
...
Questions?
Email: {anything}@jedberg.net
Twitter: @jedberg
Web: www.jedberg.net
Facebook: facebook.com/jedberg
Linkedin:
w...
Thank You!
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Upcoming SlideShare
Loading in …5
×

Getting Started with Serverless Architectures



Serverless architectures let you build and deploy applications and services with infrastructure resources that require zero administration. In the past, you had to provision and scale servers to run your application code, install and operate distributed databases, and build and run custom software to handle API requests. Now, AWS provides a stack of scalable, fully-managed services that eliminates these operational complexities.

In this session, you will learn about the benefits of serverless architectures and the basics of the serverless stack AWS provides. We will also walk through how you can use serverless architectures for everything from data processing to mobile and web backends.

AWS DevDay San Francisco, June 21, 2016.
Presenter: Jeremy Edberg, Co-Founder, CloudNative, & AWS Community Hero

Getting Started with Serverless Architectures

  1. 1. Getting Started with Serverless Architectures Email: {anything}@jedberg.net Twitter: @jedberg Web: www.jedberg.net Facebook: facebook.com/jedberg Linkedin: www.linkedin.com/in/jedberg Jeremy Edberg CoFounder https://www.cloudnative.io
  2. 2. λ
  3. 3. Test and prod are different Prod is in need of constant updates Slow iteration and deployment Polyglot unfriendly Deploy in weeks, live for years Physical Servers
  4. 4. Prod is immutable Rapid iteration and deployment Multi-tenancy Polyglot friendly Deploy in minutes, live for weeks Virtual Machines
  5. 5. Test and prod are the same Prod is immutable Rapid(er) iteration and deployment High multi-tenancy Polyglot friendly Deploy in seconds, live for hours Containers
  6. 6. Smallest unit of compute Super scalable Rapid iteration Extreme multi-tenancy Very polyglot friendly Easier to collaborate Deploy independently, live for seconds Serverless
  7. 7. A whole lot of choices Amazon’s EcosystemHodgepodge of services
  8. 8. A whole lot of choices
  9. 9. Amazon’s Serverless Ecosystem Lambda SNS DynamoDB SQS S3 Kenisis
  10. 10. Continuous scaling No servers to manage Never pay for idle – No cold servers (only happy accountants) Benefits of AWS Lambda
  11. 11. What is serverless anyway? • There are still servers, you just don’t manage them anymore • It also means you don’t access them anymore • So you don’t need to (or get to) optimize them.
  12. 12. What is Serverless Computing? • VMs • Machine as the unit of scale • Abstracts the hardware • Containers • Application as the unit of scale • Abstracts the OS • Serverless • Functions as the unit of scale • Abstracts the language runtime EC2 ECS Lambda
  13. 13. How do I choose? • VMs • “I want to configure machines, storage, networking, and my OS” • Containers • “I want to run servers, configure applications, and control scaling” • Serverless • “Run my code when it’s needed” EC2 ECS Lambda
  14. 14. Serverless computing is all about speeding up development by allowing rapid iteration and removing management overhead
  15. 15. A brief journey through history
  16. 16. 80’s Mainframe Cycle • Cost $1MM to $100MM • 1 to 5 years to execute • Usually had to bet the whole company • Cost of failure -- Bankruptcy
  17. 17. 90‘s Client/Server Cycle • Cost $100K to $10MM • 3 to 6 months to execute • Usually had to bet a product or division • Cost of failure -- Revenue hit, CXX job
  18. 18. 00‘s Agile Cycle • Cost $10K to $1MM • 3 to 6 weeks to execute • Bet a product feature • Cost of failure -- product manager reputation
  19. 19. Product Manager Developer QA Ops BI / Analytics
  20. 20. Cost and size of risk decreased Rate of change increased
  21. 21. ReleaseTestBuild
  22. 22. ReleaseTestBuild ReleaseTestBuild ReleaseTestBuild ReleaseTestBuild ReleaseTestBuild
  23. 23. Multiple services Internal Microservices Platform Monolithic Success follows a standard pattern
  24. 24. Distributed Computing and a Distributed Workforce • The two go hand in hand when you have a good distributed systems culture • Microservices and Micro Teams
  25. 25. • Services are built by different teams who work together to figure out what each service will provide. • The service owner publishes an API that anyone can use and returns proper response codes Highly aligned, loosely coupled
  26. 26. The Microservices Architecture
  27. 27. Microservices Tools Web Servers Code Libraries Frameworks Config Management API Management Deployment, CI/CDContainers etc. etc. etc.
  28. 28. Amazon’s Microservices Tools
  29. 29. What do all the parts of microservices have in common?
  30. 30. Servers Capacity planning Right-sizing Autoscaling Load and performance Patches Tuning Configuration Utilization Access control Packages and AMIs
  31. 31. Serverless Right-sizing Autoscaling Load and performance Patches Tuning Configuration Utilization Access control Packages and AMIs Fully managed Continuous Scaling Function is the deployment unit Capacity planning
  32. 32. What is Lambda? Serverless, event-driven compute service Lambda == microservice without managing servers
  33. 33. What does Lambda do for you? • Scales server capacity automatically • API to trigger execution • Ensures function is executed in parallel and at scale • Logging, monitoring, etc • Easy pricing
  34. 34. Monitoring • Everything is in Cloudwatch or Cloudwatch logs
  35. 35. Pricing • Choose your RAM from 128MB to 1500MB • CPU and Network scaled based on RAM
  36. 36. Cost Comparison
  37. 37. Cost Comparison There’s about 2.5M seconds in a month, so 3M requests is about 1.2 per second The T2.Small is $18.98 a month, more than Lambda already
  38. 38. Lambda allows for a tight feedback loop • We turned around both these requests in less than a day
  39. 39. How does work?λ
  40. 40. Author your code • AWS SDK built in • Access to /tmp, processes, threads, etc λ • NodeJS, Python • Java and any JVM language • Use any library you want
  41. 41. Choose an event source • S3 • Kinesis • SNS • DynamoDB • CloudWatch λ • Config Rules • Amazon Echo • API Gateway • Lambda functions • More coming
  42. 42. Choose a Network • Default • All functions have internet access • No access to your other VPCs • Still in a VPC λ • Customer VPC • Private communication within your VPC • Same configuration as your other VPCs (ENI, route table, security groups, NAT)
  43. 43. Deploy your code • Use the GUI or • Upload to S3 or Lambda directly λ
  44. 44. Write the function Create the IAM role Add extra permissions for a push model Zip the function and dependencies Test the function with mock data Add an event source to the function View the output of the live function
  45. 45. Write the function Create the IAM role Add extra permissions for a push model Zip the function and dependencies Test the function with mock data Add an event source to the function View the output of the live function https://cloudnative.io/oss/
  46. 46. Word Generator • Generate some number of English looking words using an ngram database • Allow a prefix to be specified
  47. 47. Demo
  48. 48. ECS Architecture Lambda Lambda DynamoDB SNS Kinesis Slack router.py
  49. 49. Call out to other Lambda functions Add their results as attachments to the message router.py
  50. 50. Demo
  51. 51. From conception to prod in 5 minutes
  52. 52. Red/Black, Blue/Green, Mauve/Chartreuse
  53. 53. Codebase Structure
  54. 54. Frontend vs Backend Repos
  55. 55. Lambda lets you manage your code and infrastructure in the same place (as long as you use Kappa or something like it).
  56. 56. Example use cases
  57. 57. Live video stream processing Cloudfront S3 Ingest Lambda Functions HQ Copy 480p Transcode 360p Transcode Audio Only Transcode Thumbnails S3 Playbac k Cloudfront Streaming
  58. 58. Serverless Website S3 Static Content Dynamic Content API Gateway Lambda DynamoDB
  59. 59. Use Cases • Application Backend • Data Processing • Command and Control • Any functional or event based system
  60. 60. Tips and Tricks • Limit your function size (JVM startup time especially) • Remember execution is async • Don’t assume function container reuse but take advantage of it
  61. 61. Tips and Tricks • Remember the 500MB in /tmp • Use function aliases • Use the included logger
  62. 62. Tips and Tricks • Set up alarms on all Lambda Cloudwatch metrics • Avoid throttling by using SNS between any service, such as S3 • Beware of infinite loops by having functions call each other.
  63. 63. Avoiding Infinte Loops • With a distributed team, this is an easy mistake to make • To avoid it, pass a call stack and check for self in the stack
  64. 64. Store your data properly • No local instance access • Store everything in S3, DynamoDB, or Elasticache DynamoDB S3
  65. 65. • zip up with dependencies • roles and permissions • dev vs prod • aliases Difficulties we’ve solved
  66. 66. Problems we still have • efficient dependency usage • local dev environments • making sure we have the same dependencies • knowing when someone else is deploying the same function
  67. 67. ReleaseTestBuild ReleaseTestBuild ReleaseTestBuild ReleaseTestBuild ReleaseTestBuild
  68. 68. Next Steps
  69. 69. • efficient dependency usage • local dev environments • making sure we have the same dependencies • knowing when someone else is deploying the same function Problems we still have
  70. 70. • efficient dependency usage • local dev environments • making sure we have the same dependencies • knowing when someone else is deploying the same function Problems we still have
  71. 71. Testing • You can’t test the network, but a good application test should obviate the need to do so. • Not really a solved problem. Can do local testing. • Can also send json to the function and compare the results.
  72. 72. Questions? Email: {anything}@jedberg.net Twitter: @jedberg Web: www.jedberg.net Facebook: facebook.com/jedberg Linkedin: www.linkedin.com/in/jedberg Company: cloudnative.io
  73. 73. Thank You!

×