Founders and Coders &&

AWS Lambda

 

Serverless Architecture

 

Serverless !== No Server

What it actually means:

Stateless

Event Driven

Microservices

In the Cloud

 

  • Infrastructure
  • Scaling
  • Capacity and underutilisation
  • Complex deployment
  • Monitoring and logging set up

Use a microservices architecture

Monolith

Microservices

Implementations

  • AWS Lambda
  • IBM OpenWhisk
  • Google Cloud Functions
  • Iron.io
  • Firebase

A little lambda

var starwars = require('starwars');

exports.handler = function (event, context, callback) {
  if (event.isJedi) {
    return callback(null, starwars());
  } else {
    return callback("Sorry you can't get a quote");
  }
};

Input Object

Environment

callback(err, res)

"Do. Or do not. There is no try"

AWS Lambda

  • Node.js v4.3.2/Java/Python/Go?
  • Stateless
  • Pay per execution (100ms)
  • Execution Time limit: 5min
  • 100 parallel executions by default
  • HTTP or request/response invocation
  • 1m free requests/month for 1 year
  • Versioning and Aliasing

github.com/dwyl/learn-aws-lambda

HELLO WORLD

AWS API Gateway

  • Public HTTP Endpoints
  • Map to Lambda functions
  • Pay per call
  • 1m free calls/month for 1 year
  • Versioning
  • Security, rate limiting, throttling, caching, CORS

Served from an S3 bucket

HTTP endpoint on API Gateway

Static website

S3 Save

S3 Get

S3 Bucket Data store

Frontend

API

Backend

The Good Parts

  • Deploy each function individually
  • Each micro-service is simple
  • Piggyback off existing AWS Infrastructure
  • Very attractive pricing model + generous free tier
  • Lambdas and endpoints are easily disposable
  • Versioning for CI/Prod
  • More complex integration testing
  • Debugging
  • Many moving parts
  • Latency issues if multiple lambdas executed in series 

How to tame your microservices

  • One repo per service
  • Document interfaces very clearly
  • Deployment scripts instead of manual deployments
  • Architecture diagrams
  • Local invoke scripts/tests so you don't have to deploy the service to test it
  • Don't hop more than 3 services deep

@nikhilaravi

www.github.com/nikhilaravi

 

@dwylhq

www.dwyl.io

www.github.com/dwyl

www.onelifetwoways.com

Copy of Serverless architecture in the wild

By Nikhila Ravi

Copy of Serverless architecture in the wild

  • 774