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

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. 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…
  2. 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...
  3. 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...
  4. Lambda “AWS Lambda lets you run code without provisioning or

    managing servers.” Like the calculus.
  5. Lambda exports.myHandler = function(event, context) { console.log("value1 = " +

    event.key1); console.log("value2 = " + event.key2); context.succeed("some message"); } NodeJS
  6. 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
  7. Lambda def my_handler(event, context): message = 'Hello {} {}!'.format (event

    ['first_name'], event['last_name']) return {'message' : message} Python
  8. 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
  9. 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
  10. 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
  11. The list goes on - Architectures - Event-driven computing -

    Startups - Microservices - Testing - Analytics - Stream processing - ETL / Batch - Statistics / metrics - Machine learning Serverless...
  12. 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.