$30 off During Our Annual Pro Sale. View Details »

Going Serverless with AWS Lambda

Going Serverless with AWS Lambda

The main topic for the night is Amazon Web Service's Lambda presented by Martin Smith. Martin will present an overview of AWS Lambda, how it works, as well as some interesting projects he's used it for. He will tell you why it's the new normal, the new cloud, and why you should start using it & learning about it immediately.

Martin Smith

January 20, 2016
Tweet

More Decks by Martin Smith

Other Decks in Technology

Transcript

  1. Going Serverless:
    AWS Lambda
    Martin Smith, DevOps Engineer
    [email protected]

    View Slide

  2. Martin B. Smith, DevOps Engineer @ Rackspace
    @martinb3 - http://martinb3.io - [email protected] - github:martinb3
    15 years of infrastructure automation, software development,
    systems administration.
    Unhealthy obsession with acquiring new hobbies: Memes in
    presentations, Photography, Knitting, Baking, Kayaking,
    Languages, Travel…

    View Slide

  3. The Plan
    What is Lambda. Why it matters.
    Demo. Limits.

    View Slide

  4. I lied.
    Here’s what I want
    you to know.

    View Slide

  5. The Plan
    What is Lambda. Why it matters.
    Demo. Limits.

    View Slide

  6. AWS ‘Services’
    Compute: EC2, ECS, EMR, Lambda*
    Net: Route53, VPC, DirectConn., ELB
    CDN: CloudFront
    Storage: S3, Glacier, EBS, EFS
    DB: Dynamo, RDS, Kinesis, SimpleDB
    Deployment: CF, ElasticBeanstalk,
    OpsWorks, CodeDeploy
    Mgmt: IAM, Directory Services,
    CloudWatch, KMS
    App Mgmt: API Gateway, Search, SES,
    SQS, SNS, SWF, ad nauseam.
    Mechanical turk...

    View Slide

  7. AWS ‘Services’
    Compute: EC2, ECS, EMR, Lambda*
    Net: Route53, VPC, DirectConn., ELB
    CDN: CloudFront
    Storage: S3, Glacier, EBS, EFS
    DB: Dynamo, RDS, Kinesis, SimpleDB
    Deployment: CF, ElasticBeanstalk,
    OpsWorks, CodeDeploy
    Mgmt: IAM, Directory Services,
    CloudWatch, KMS
    App Mgmt: API Gateway, Search, SES,
    SQS, SNS, SWF, ad nauseam.
    Mechanical turk...

    View Slide

  8. View Slide

  9. Lambda “AWS Lambda lets you run
    code without provisioning
    or managing servers.”
    Like the calculus.

    View Slide

  10. Lambda
    exports.myHandler = function(event, context) {
    console.log("value1 = " + event.key1);
    console.log("value2 = " + event.key2);
    context.succeed("some message");
    }
    NodeJS

    View Slide

  11. Lambda
    package example;
    import com.amazonaws.services.lambda.runtime.
    Context;
    public class Hello {
    public String myHandler(String name, Context
    context) {
    return String.format("Hello %s.", name);
    }
    }
    Java

    View Slide

  12. Lambda
    def my_handler(event, context):
    message = 'Hello {} {}!'.format (event
    ['first_name'], event['last_name'])
    return {'message' : message}
    Python

    View Slide

  13. $ (requests) *
    (GB*seconds)

    View Slide

  14. 1M requests
    400k GB-seconds

    View Slide

  15. $0.00001667 per GB*s
    $0.0000002 per req.

    View Slide

  16. Pricing Example 1
    If you allocated 512MB of memory to your function, executed it 3 million times in one month, and it ran for 1 second each time, your
    charges would be calculated as follows:
    Monthly compute charges
    The monthly compute price is $0.00001667 per GB-s and the free tier provides 400,000 GB-s.
    Total compute (seconds) = 3M * (1s) = 3,000,000 seconds
    Total compute (GB-s) = 3,000,000 * 512MB/1024 = 1,500,000 GB-s
    Total compute – Free tier compute = Monthly billable compute GB- s
    1,500,000 GB-s – 400,000 free tier GB-s = 1,100,000 GB-s
    Monthly compute charges = 1,100,000 * $0.00001667 = $18.34
    Monthly request charges
    The monthly request price is $0.20 per 1 million requests and the free tier provides 1M requests per month.
    Total requests – Free tier requests = Monthly billable requests
    3M requests – 1M free tier requests = 2M Monthly billable requests
    Monthly request charges = 2M * $0.2/M = $0.40
    Total monthly charges
    Total charges = Compute charges + Request charges = $18.34 + $0.40 = $18.74 per month

    View Slide

  17. Pricing Example 2
    If you allocated 128MB of memory to your function, executed it 30 million times in one month, and it ran for 200ms each time, your
    charges would be calculated as follows:
    Monthly compute charges
    The monthly compute price is $0.00001667 per GB-s and the free tier provides 400,000 GB-s.
    Total compute (seconds) = 30M * (0.2sec) = 6,000,000 seconds
    Total compute (GB-s) = 6,000,000 * 128MB/1024 = 750,000 GB-s
    Total Compute – Free tier compute = Monthly billable compute seconds
    750,000 GB-s – 400,000 free tier GB-s = 350,000 GB-s
    Monthly compute charges = 350,000 * $0.00001667 = $5.83
    Monthly request charges
    The monthly request price is $0.20 per 1 million requests and the free tier provides 1M requests per month.
    Total requests – Free tier request = Monthly billable requests
    30M requests – 1M free tier requests = 29M Monthly billable requests
    Monthly request charges = 29M * $0.2/M = $5.80
    Total compute charges
    Total charges = Compute charges + Request charges = $5.83 + $5.80 = $11.63 per month

    View Slide

  18. The Plan
    What is Lambda. Why it matters.
    Demo. Limits.

    View Slide

  19. So much
    integration
    potential.

    View Slide

  20. Could easily replace crontab or batch workloads.
    Scaling is a non-issue. Parallel-friendly workloads.
    Already seeing backup jobs for S3 built in Lambda.
    Could replace Heroku. Could replace FastCGI & workers.
    Single page apps...
    Event driven infrastructure

    View Slide

  21. Image processing app

    View Slide

  22. Squirrelbin

    View Slide

  23. Deploy Lambda w/ Lambda

    View Slide

  24. CI/CD or Load Testing Pipeline

    View Slide

  25. CRISPR: edit genomes with unprecedented precision,
    efficiency, and flexibility.

    View Slide

  26. The list goes on
    - Architectures
    - Event-driven computing
    - Startups
    - Microservices
    - Testing
    - Analytics
    - Stream processing
    - ETL / Batch
    - Statistics / metrics
    - Machine learning
    Serverless...

    View Slide

  27. The New Normal
    - EC2 & S3 replaced VMs &
    File Storage
    - Immutable infrastructure,
    cattle not pets. Automated
    provisioning. Self-healing.
    - Will Lambda replace these?
    All the right constraints for
    another revolution.

    View Slide

  28. Next?

    View Slide

  29. Cost dominated by CDN

    View Slide

  30. The Plan
    What is Lambda. Why it matters.
    Demo. Limits.

    View Slide

  31. I lied.
    These demos
    aren’t live.

    View Slide

  32. Sending Slack
    messages

    View Slide

  33. Validating Chef
    configurations

    View Slide

  34. Fanout jobs

    View Slide

  35. View Slide

  36. The Plan
    What is Lambda. Why it matters.
    Demo. Limits.

    View Slide

  37. Language Choice
    C++, Ruby, Golang, etc

    View Slide

  38. Identity & Access
    Management
    $$$$$$$$$$$$$$$$$$$$$$$

    View Slide

  39. Performance Options
    Many more EC2 instance sizes.

    View Slide

  40. Return Values
    Uneven. Mapping to HTTP errors is hard.

    View Slide

  41. Dependency packaging
    OpenSSL? PyCrypto? :redflag:

    View Slide

  42. Testing
    Local environments != Production

    View Slide

  43. No Structure
    Huge List only gets bigger.

    View Slide

  44. Regions in AWS.
    Not available everywhere.

    View Slide

  45. Latency
    Around 1s for initial call, 100ms after

    View Slide

  46. Never-catch-up Problem
    > 300s ad infinitum.

    View Slide

  47. Vendor Lockin
    Perhaps. Perhaps not.

    View Slide

  48. Competitors?
    Facebook: Parse, Firebase

    View Slide

  49. Fin.

    View Slide