Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
aws lambda & api gateway
1. AWS Lambda & API Gateway
Tech Talks Tokyo #3
2016-07-05 Tue
2. 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
3.
4. ➢ 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.
5. AWS
➢ Amazon Web Services
➢ Iaas
➢ One of the most famous cloud infrastracture service.
➢ But it’s not come cheap ( of course depends on usage).
6. 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
9. 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.
12. 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).
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-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/)
15. 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.
16. 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.
17. 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!)
18. 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
20. 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).