The server is dead,

long live the λάμδα!

About me


twitter: @markbaraban

github: @shmuga

How many of you can handle 1 RPS?

... and scale it to

1000 RPS without literally doing nothing

diagram from cloudcraft

...and after 5 minutes downgrade it to

1 RPS 


Calm down.

Take it easy.

But what is

AWS Lambda?

AWS Lambda

Serverless architectures refer to applications that significantly depend on third-party services (knows as Backend as a Service or "BaaS") or on custom code that's run in ephemeral containers (Function as a Service or "FaaS"), the best known vendor host of which currently is AWS Lambda.

Martin Fowler

exports.handler = (event, context, callback) => {
    callback(null, 'Done!');

All you need to create a function:

Who can fire an event

  • Api Gateway
  • CloudWatch
  • SNS
  • SQS
  • DDB
  • Alexa
  • and other


is your payload (in other words json)

it's configured on the level of service who fires it


is information about currently called function and it's parameters


is old-school technology to handle async actions

Ok, so what about performance.


is tightly connected with


Each function has

  • provisioned memory (RAM from 128Mb up to 1536Mb) 
  • time it's working ( minimum 100ms)
  • network/cpu is connected with RAM.

Everything is calculated in


Example 1:

You have function been called 

100 000 times with 128Mb RAM parameter and execution time was 1s


so you have used 0.128 * 100 000 = 12800 GB-seconds


and price per 1GB-second = 0.00001667

So you pay 0.21$

Actually NO.

You pay nothing.

product owner counting saved money

Free tier

400 000 GB-second*

*is free permanently 

For what it's enough

400 000 GB-seconds is enough for 128Mb RAM function to work whole month

If your function works


whole month with


128Mb RAM it costs 5$.


  • C#

  • Java 8

  • Python 2.7

  • Python 3.6

  • Node 4.3

  • Node 6. 10

1 time a year

update cycle of node version

But how can i make simple HTTP(s) call?

API Gateway

you just say you want to call function GetUser


when you receive call such call

POST /get-user

API Gateway

out of the box stuff

  • cache
  • authorized endpoints 
  • custom domains
  • free https certificates
  • Swagger
  • throttling

How can I manage


of functions?


Each function call creates CW log group.


Each console.log() call puts records into this log. 


out of the box stuff

  • metrics and custom filters
  • alarms
  • notifications

Simple metric

Simple alarm

How can I manage

state or use DB

for functions?


You can easily use any lib/db.

But DynamoDB is preferred.


is key-value auto-scalable DB with atomic operations.

You can use Lambda

  • to handle http
  • to call it periodically 
  • to handle some queue
  • to use it as trigger to DB/S3
  • pipe lambda functions
  • and other.


Title Text

Tool #1. CloudFormation

1k lines of json config

to deploy 1 function.

Tool #2.

Serverless config

general information

service: Users

  name: aws
  runtime: nodejs6.10
  memorySize: 512
  timeout: 20
  region: eu-west-1
  profile: default
  role: arn:aws:iam::XXX:role/APIRole

Serverless config

function definition

    handler: functions/add-user.default
    name: ${self:service}AddUser-${opt:stage, self:provider.stage}
    description: Adds user
      - http:
          path: /user/add
          method: post
            arn: arn:aws:lambda:eu-west-1:XXX:function:Authorizer
            resultTtlInSeconds: 600
            identitySource: method.request.header.AuthToken

Serverless config

other options

  individually: true
    - test/**
    - .git/**
    - .vscode/**
    - .idea/**
    - yarn.lock
    - node_modules/**/README.*
    - node_modules/**/test/**

  - serverless-plugin-webpack


  • auto scaling
  • force you to think in small functions
  • force you to use less modules
  • good for decomposition
  • pay as you go
  • minimizing DevOps


  • not suitable for real highload
  • vendor lock
  • no connection pool
  • no state?
  • needs some skills with aws
  • no websockets


Happy Hacking!