AWS Lambda & API Gateway Tech Talks Tokyo #3 2016-07-05 Tue
me fumihiko hata (@hatappo) Server side engineer @ stylerecipe, inc [Now]: Fashion consultation & advice mobile apps (~ 1 year) [Previous]: Ad-techs (7 years) [Langs]: Java, Ruby, Clojure, Node [Likes]: Scrum, AWS, GCP
➢ We built some micro service servers. ➢ Our main web server system is a bit learge and complicated. ➢ So we decide to try Lambda & APIGateway partly.
AWS ➢ Amazon Web Services ➢ Iaas ➢ One of the most famous cloud infrastracture service. ➢ But it’s not come cheap ( of course depends on usage).
AWS::Lambda ➢ Cloud computing resources ➢ Like EC2 ■ a per-time charge ➢ Not-like EC2 ■ Very restricted environment Only for simple function code and only with Node.js, Python, or Java. ■ by 100ms (EC2: by 3,600,000ms = 1hour) ■ Very low cost! No Using, No Charge Huge free tier: 1,000,000 request/month & 400,000 GB-seconds/month
AWS::Lambda
AWS::Lambda
AWS::APIGateway ➢ Web API management layer that enable to integrate various backends. ■ web services on EC2 ■ cooperate with lambda ■ of course not only in AWS endpoints (redirect to another url). ■ (support mock response for depvelopment) ➢ Also low cost ■ You pay only for calls made to your APIs and data transfer out.
AWS::APIGateway
AWS::APIGateway
Swagger ➢ You can import / export settings of the API Gateway as swagger json (or yaml). ➢ IOW, You can commit the settings to your git repository! ➢ Of Course Lambda code is mere function (that is predefined signature).
Using Langs ➢ Node.js ■ Very famous server side implementation of JS. ○ We developed a image converter server. It convert size & aspect & bg-color only for Twitter cards & OGP. So This server need not high capacity & has independent feature. ➢ Clojure ■ Clojure is Lisp dialect built on JVM. ■ Of course Runnnable on Lamda. ○ We developed a scraping api server that only target apparel web site. It’s accept url from query, then scrape that page and response structured that. This Lambda code also work batch as well as api server.
Tools ➢ Clojure ■ Lein-clj-lambda https://github.com/mhjort/lein-clj-lambda Build jar & deploy to a Lambda ■ Lein-aws-apigateway https://github.com/trieloff/lein-aws-apigateway Import/Export settings of API Gateway as Swagger ■ Lambada https://github.com/uswitch/lambada Macros for Lambda ➢ ClojureScript ■ Cljs-lambda https://github.com/nervous-systems/cljs-lambda ➢ Node.js ■ Serverless https://github.com/serverless/serverless Big framework for AWS Lambda, Azure Functions, Google CloudFunctions (Serverlss conf was held May 26,27 2016 http://serverlessconf.io/)
Good ➢ Easy to deply. It’s only to run a api. ➢ AAMOF, Not only for server side but also for batch processing. Lambda also has scheduler like crontab. ➢ Both is auto scaling! ➢ Both is able to manage in a repo.
NotGood::Testing ➢ There is no easy way to test API Gateway localy. (Lambda is a mere function) ➢ As in common development on AWS, preparing cost for good local testing environmet is much higher if you use lambda with other AWS Services something like S3, DynamoDB.
NotGood::Lambda Restrictions ➢ Deployment package size: max 50MB → not enough to learge system. ➢ Processing time: max 300sec ➢ Number of processes & threads: 1024 ➢ Disk capacity(“/tmp”): max 512MB → not suited to learge data processing. (use asynchronous architecture!)
NotGood::Node Version ➢ Lambda currently support Node.js v4.3.2 & v0.10.36 → In other words, Lambda doesn’t support full ES6! Ex. Promise, arrow operator(=>), let, const, template literal(`foo ${v}`) Destructuring, rest parameters(...args), default function parameters
NotGood::First Call Performance Penalty http://numergent.com/2016-01/AWS-Lambda-Clojure-and-ClojureScript.html
Conclusion ➢ Lambda is easy to develop a micro-service function. ➢ APIGateway is a handy interface for http in AWS services. ➢ Lambda & API Gateway need no server manegement. ➢ Lambda & API Gateway are friendly on our wallet :) ➢ But Lambda has few caution (especialy with JVM).
thanks for listining.

aws lambda & api gateway

  • 1.
    AWS Lambda &API Gateway Tech Talks Tokyo #3 2016-07-05 Tue
  • 2.
    me fumihiko hata (@hatappo) Serverside engineer @ stylerecipe, inc [Now]: Fashion consultation & advice mobile apps (~ 1 year) [Previous]: Ad-techs (7 years) [Langs]: Java, Ruby, Clojure, Node [Likes]: Scrum, AWS, GCP
  • 4.
    ➢ We builtsome micro service servers. ➢ Our main web server system is a bit learge and complicated. ➢ So we decide to try Lambda & APIGateway partly.
  • 5.
    AWS ➢ Amazon WebServices ➢ Iaas ➢ One of the most famous cloud infrastracture service. ➢ But it’s not come cheap ( of course depends on usage).
  • 6.
    AWS::Lambda ➢ Cloud computingresources ➢ Like EC2 ■ a per-time charge ➢ Not-like EC2 ■ Very restricted environment Only for simple function code and only with Node.js, Python, or Java. ■ by 100ms (EC2: by 3,600,000ms = 1hour) ■ Very low cost! No Using, No Charge Huge free tier: 1,000,000 request/month & 400,000 GB-seconds/month
  • 7.
  • 8.
  • 9.
    AWS::APIGateway ➢ Web APImanagement layer that enable to integrate various backends. ■ web services on EC2 ■ cooperate with lambda ■ of course not only in AWS endpoints (redirect to another url). ■ (support mock response for depvelopment) ➢ Also low cost ■ You pay only for calls made to your APIs and data transfer out.
  • 10.
  • 11.
  • 12.
    Swagger ➢ You canimport / export settings of the API Gateway as swagger json (or yaml). ➢ IOW, You can commit the settings to your git repository! ➢ Of Course Lambda code is mere function (that is predefined signature).
  • 13.
    Using Langs ➢ Node.js ■Very famous server side implementation of JS. ○ We developed a image converter server. It convert size & aspect & bg-color only for Twitter cards & OGP. So This server need not high capacity & has independent feature. ➢ Clojure ■ Clojure is Lisp dialect built on JVM. ■ Of course Runnnable on Lamda. ○ We developed a scraping api server that only target apparel web site. It’s accept url from query, then scrape that page and response structured that. This Lambda code also work batch as well as api server.
  • 14.
    Tools ➢ Clojure ■ Lein-clj-lambdahttps://github.com/mhjort/lein-clj-lambda Build jar & deploy to a Lambda ■ Lein-aws-apigateway https://github.com/trieloff/lein-aws-apigateway Import/Export settings of API Gateway as Swagger ■ Lambada https://github.com/uswitch/lambada Macros for Lambda ➢ ClojureScript ■ Cljs-lambda https://github.com/nervous-systems/cljs-lambda ➢ Node.js ■ Serverless https://github.com/serverless/serverless Big framework for AWS Lambda, Azure Functions, Google CloudFunctions (Serverlss conf was held May 26,27 2016 http://serverlessconf.io/)
  • 15.
    Good ➢ Easy todeply. It’s only to run a api. ➢ AAMOF, Not only for server side but also for batch processing. Lambda also has scheduler like crontab. ➢ Both is auto scaling! ➢ Both is able to manage in a repo.
  • 16.
    NotGood::Testing ➢ There isno easy way to test API Gateway localy. (Lambda is a mere function) ➢ As in common development on AWS, preparing cost for good local testing environmet is much higher if you use lambda with other AWS Services something like S3, DynamoDB.
  • 17.
    NotGood::Lambda Restrictions ➢ Deploymentpackage size: max 50MB → not enough to learge system. ➢ Processing time: max 300sec ➢ Number of processes & threads: 1024 ➢ Disk capacity(“/tmp”): max 512MB → not suited to learge data processing. (use asynchronous architecture!)
  • 18.
    NotGood::Node Version ➢ Lambdacurrently support Node.js v4.3.2 & v0.10.36 → In other words, Lambda doesn’t support full ES6! Ex. Promise, arrow operator(=>), let, const, template literal(`foo ${v}`) Destructuring, rest parameters(...args), default function parameters
  • 19.
    NotGood::First Call PerformancePenalty http://numergent.com/2016-01/AWS-Lambda-Clojure-and-ClojureScript.html
  • 20.
    Conclusion ➢ Lambda iseasy to develop a micro-service function. ➢ APIGateway is a handy interface for http in AWS services. ➢ Lambda & API Gateway need no server manegement. ➢ Lambda & API Gateway are friendly on our wallet :) ➢ But Lambda has few caution (especialy with JVM).
  • 21.