← All notes

AWS - Lambda - API Gateway - Batch - Lightsail

EC2:

  • Virtual Servers in the Cloud
  • Limited by RAM and CPU
  • Continuously running
  • Scaling means intervention to add / remove servers

Amazon Lambda:

  • Virtual functions - no servers to manage!
  • Limited by time - short executions
  • Run on-demand
  • Scaling is automated!

Benefits of AWS Lambda

  • Easy Pricing:
    • Pay per request and compute time
    • Free tier of 1.000.000 AWS Lambda requests and 400.000 GBs of compute time
  • Integrated with the whole AWS suite of services
  • Event-Driven: functions get invoked by AWS when needed
  • Integrated with many programming languages
  • Easy monitoring through AWS CloudWatch
  • Easy to get more resources per functions (up to 10GB of RAM!)
  • Increasing RAM will also improve CPU and network!

AWS Lambda language support

  • Node.js

  • Python

  • Java

  • C#

  • Ruby

  • Custom Runtime API (community supported, example Rust or Golang)

  • Lambda Container Image

    • The container image must implement the Lambda Runtime API
    • ECS / Fargate is preferred for running arbitrary Docker image

AWS Lambda Pricing

  • Pay per calls:
    • First 1.000.000 requests are free
    • $0.20 per 1million requests thereafter ($0.0000002 per request)
  • Pay per duration (in increment of 1ms)
    • 400.000 GB-seconds of compute time per month if Free
    • == 400.00 seconds if functions is 1GB RAM
    • == 3.200.00 seconds if functions is 128MB RAM
    • After that $1.00 for 600.000 GB-seconds
  • It is usually very cheap to run AWS Lambda so it's very popular

API Gateway

Example: building a serverless API

Client <- Rest API -> API Gateway <- Proxy Requests -> Lambda <- CRUD -> DynamoDB

  • Fully managed service for developers to easily create, publish, maintain, monitor, and secure APIs
  • Serverless and scalable
  • Supports RESTful APIs and WebSocket APIs
  • Support for security, users authentication, API throttling, API keys, monitoring...

AWS Batch

  • Fully managed batch processing at any scale
  • Efficiently run 100.000s of computing batch jobs on AWS
  • A "batch" job is a job with a start and an end ( opposed to continuous)
  • Batch will dynamically launch EC2 instances or Spot Instances
  • AWS Batch provisions the right amount of compute / memory
  • You submit or schedule batch jobs and AWS Batch does the rest!
  • Batch jobs are defined as Docker Images an run on ECS
  • Helpful for cost optimizations and focusing less on the infrastructure

Batch vs Lambda

  • Lambda:
    • Time limit
    • Limited runtimes
    • Limited temporary disk space
    • Serverless
  • Batch:
    • No time limit
    • Any runtime as long as it's packaged as a Docker Image
    • Rely on EBS / instance store for disk space
    • Relies on EC2 ( can be managed by AWS)

Lightsail

  • Virtual servers, storage, databases, and networking
  • Low & predictable pricing
  • Simpler alternative to using EC2, RDS, ELB, EBS , Route 53...
  • Great for people with little cloud experience!
  • Can setup notifications and monitoring of your LightSail resources
  • Use cases:
    • Simple web applications (has templates for LAMP, Nginx, MEAN, Node.js)
    • Websites (templates for WordPress, Magento, Plesk, Joomla)
    • Dev / Test environment
  • Has high availability but no auto-scaling, limited AWS integrations.