Serverless Architecture
- with
AWS Lambda
by @vincent_lcy
Why Serverless
modularized
![](https://media.slid.es/uploads/59926/images/2673070/docker.png)
Atomic Unit
of a running script
Logic
Execution
API Gateway
AWS Lambda
![](https://media.slid.es/uploads/59926/images/2673109/aws-api-gateway-icon.png)
![](https://media.slid.es/uploads/59926/images/2673110/AWS-Lambda.png)
Features
- Python / NodeJS / Java8 runtime
- π Cron like execution
(CloudWatch events) - Pay-as-you-go
- Can access VPC Finally
- Auto Scalling
- Latency: so far so good
![](https://media.slid.es/uploads/59926/images/2673152/aws_lambda_regions.jpg)
When
Serverless
When to use π
π Stateless
π Short Job
π Event-driven stuff, e.g. Time-based / webhook
π Spike Patterns of usage
π Simple program with less dependency
π ad-hoc scripts with need to modify and version
π Need Real quick set up, quicker than Knubertes
When NOT to use π
π Stateful e.g. Session servers
π Long running (=>$$)
π Cache is important -> can use external elasticCache
π High CPU/Memory Usage (Max 1.5GB per process)
π Complex gcc / machine drivers etc
π High frequency self-trigger (max @1min event now) -> Use SNS/Celery!
π Need DAG Job dependencies -> Use airflow!
π Strong fault tolerance /monitor req -> Use Celery / Gearman!
π Layman stuff -> Use Zappier / IFTTT!
πUse Cases
-
Auth
-
Point to point Data Sync among 3rd part services/ platform
-
E.g. App -> Salesforce
-
Daily Logentries, GA -> ReportingDB
-
Pagination with external state
-
-
-
Integrate with Amazon Kinesis for data analytics
-
βAs simple as marshalling / aggregating & send reporting db
-
-
Scraping
-
Simple API, Slackbot etc..
yet some other pain points
- Overhead to setup proper VPC subnet
- Tedious to package
- Libraries like Pg8000 (Postgres driver) tested well on local/ec2 but failed
- hard to reproduce the environment
- Just give up and switch lib
Old school Cloudwatch events and loggings
- AWS UI is just...well
![](https://media.slid.es/uploads/59926/images/2673228/face_palm.png)
![](https://media.slid.es/uploads/59926/images/2673257/tj.jpeg)
to the rescue
Cost Structure
![](https://media.slid.es/uploads/59926/images/2682051/pasted-from-clipboard.png)
(memory type * exe time,
roughly 3M * 1s call <$20 USD)
Ecosystems
-
Integrations with
-
API Gateway, another Lambda...
-
Kinesis, Redshift, S3...
-
AWS
Others
-
your own dockerized arch
-
Non tech oriented Data integrations
-
Xplenty, Zapier/IFTTT
Serverless Architecture
By Chun Yin Vincent Lau
Serverless Architecture
- 2,974