Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverless Applications

Serverless Applications

Introduction to serverless architecture on AWS

Marko Baric

December 02, 2016
Tweet

Other Decks in Programming

Transcript

  1. WHY? As a dev team, we should focus on delivering

    code, not maintaining the infrastructure to run that code. Programmers bring value when they write code.
  2. PROBLEMS WITH MANAGING YOU OWN SERVERS • Team needs to

    have skills to manage IT infrastructure • What server size? • Which OS version? • When do we patch OS? • How do we patch OS?  downtime! • Tuning server performance • How much remaining capacity do we have? • Handling server failures • Servers are highly underutilized • Pay even if you’re not running any workload – pay for time, not for the actual work
  3. KEY BENEFITS OF SERVERLESS APPROACH Zero administration No provisioning Focus

    on business value Allows rapid innovation Seamless scaling
  4. Monolithic ◦ Hard to make changes ◦ Tight coupling between

    components ◦ Hard to understand interdependencies ◦ Partial deployments impossible ◦ Either all works or nothing works ◦ Shared data store ◦ Shared codebase – teams are overlapping WHY MICROSERVICES? Microservices ◦ Separation of responsibilites between components – easier to understand ◦ Individually deployable pieces ◦ Easier to test functionalities in isolation ◦ No sharing of code ◦ No sharing of data ◦ Graceful degradation of service
  5. What if we could just focus on solving the business

    problems and let someone else run the code and do all heavy lifting for us...
  6. CLOUD MAKES IT POSSIBLE! Data store Caching Networking Content delivery

    Compute Security Monitoring and logging Messaging and queues Streaming
  7. AWS API GATEWAY • Public API as a service •

    Handles authorization, access control, monitoring, API version management • Highly scalable, highly resilient service • Scales dynamically to handle ANY load • Seamless integration with AWS services (like Lambda or Kinesis) or any custom HTTP endpoint • Caching out of the box • Charging per million API calls ($3.50 per million API calls) + traffic out
  8. AWS LAMBDA • Function As A Service • Event-driven serverless

    compute service • Triggered by: API gateway call, SNS notification, Kinesis stream, S3 object upload, CloudWatch alarm, Amazon Echo.... • Pay only for running time (in 100ms increments) • Never pay for idle! • Don’t worry about overprovisioning or underprovisioning • Automatically scales to handle ANY load • Supports Node.JS, Python, Java and C# from today!! • Your code is secured – encrypted at rest • Monitoring out of the box
  9. AWS LAMBDA LIMITATIONS • Functions must complete execution in 300

    sec • Allocated memory from 128 MB up to 1.5 GB (in 64 MB increment) • Available CPU power proportional to allocated memory • 500 MB of non-persistent disk space • Function size (with dependencies) less than 50 MB • Execution is stateless, but beware – containers are reused! • Latency on first request
  10. EXAMPLE #1 (Serverless backend) Back end logic Back end data

    Web clients Mobile clients Services HTTP / REST
  11. EXAMPLE #1 (Serverless backend) Web clients Mobile clients Services AWS

    API Gateway AWS Lambda AWS DynamoDB AWS CloudFront
  12. EXAMPLE #1 (Serverless backend) Web clients Mobile clients Services AWS

    API Gateway AWS Lambda AWS DynamoDB AWS CloudFront AWS S3
  13. EXAMPLE #1 (Serverless backend) Web clients Mobile clients Services AWS

    API Gateway AWS Lambda AWS DynamoDB AWS CloudFront AWS S3 AWS S3 AWS SNS
  14. EXAMPLE #1 (Serverless backend) Services AWS API Gateway AWS Lambda

    AWS DynamoDB AWS CloudFront AWS S3 AWS S3 AWS SNS
  15. EXAMPLE #2 (Hybrid backend) Web clients Mobile clients Services AWS

    API Gateway AWS Lambda AWS DynamoDB AWS CloudFront AWS EC2 AWS EC2
  16. EXAMPLE #3 (Serverless stream processing) Mobile clients AWS Kinesis Streams

    AWS DynamoDB AWS S3 AWS EMR AWS Lambda AWS Redshift
  17. WHO IS SERVERLESS FOR? • Do you need high performance

    at ANY scale? • Can you afford unpredictable running costs? • Do you need to individually deploy ony pieces of your application? • Do you need to be able to experiment and iterate quickly with parts of your application? • Are you building microservices?
  18. “ If you can’t build a modular monolith, what makes

    you think microservices is the answer?
  19. WHAT’S THE CURRENT STATE? • Technology not mature enough •

    No well-proven patterns to follow, everyone is still experimenting • No mature frameworks to help us build and deploy • Still only few players in the game (AWS Lambda, Azure Functions, Google Cloud Functions, IBM OpenWisk, Webtask.io....) • Harder to develop and test locally • Do you really need this architecture? • In some cases it’s cheaper to run a fleet of EC2s
  20. IT’S NOT ALWAYS CHEAPER Lambda 10 x m3.large Pricing model

    First million executions free, each additional million $0.20 $95 / month for each instace Our monthly cost $2,162 $950 Our yearly cost $25,944 $11,400 • 100 exeucutions / sec • Each execution lasts 1 sec • Each execution is allocated 512 MB of memory $14,500 difference per year!