Serverless
- Serverless is a new paradigm in which the developers don't have to manage servers anymore
- just deploy code, just deploy functions
- Serverless == FaaS(Function as a Service)
- Serverless was pioneered by AWS Lambda but now also includes anything that's managed such as databases, messaging, storage, etc.
- Serverless doesn't mean there are no servers
Serverless in AWS
: AWS Lambda, DynamoDB, AWS Cognito, AWS API Gateway, S3, Fargate...
[ Why use AWS Lambda (compare Amazon EC2 with AWS Lambda) ]
Amazon EC2
- Virtual Servers in the Cloud
- Limited by RAM and CPU
- Continuously running
- Scaling means intervention to add /remove servers
AWS Lambda
- Virtual functions - no servers to manage
- Limited by time - short executions
- Run on-demand
- Scaling is automated
[ Benefits of AWS Lambda ]
-Easy Pricing
Pay per request and compute time
Free tier of 1,000,000 AWS Lambda requests and 400,000 GBs of compute time
- Integrated with the whole AWS suite of services
- Integrated with many programming languages
- Easy monitoring through AWS CloudWatch
- Easy to get more resources per functions (up to 10GB of RAM)
- Increasing RAM will also improve CPU and network
[ AWS Lambda language support ]
- js
- Python
- Java
- C#
- Go
- Ruby
- Custom Runtime API
- Lambda Container Image
The container image must implement the Lambda Runtime API
ECS / Fargate is preferred for running arbitrary(임의적인 멋대로인) Docker images
[ AWS Lambda Integrations Main ones ]
- API Gateway
- Kinesis
- Dynamo DB
- S3
- CloudFront
- CloudWatch Events Event Bridges
- CloudWatch Logs
- SNS
- SQS
- Cognito
[ Example : Serverless Thumbnail creation ]
[ Example : Serverless CRON job ]
[ AWS Lambda Pricing ]
- https://aws.amazon.com/lambda/pricing/
- Pay per calls
first 1,000,000 requests are free
$0.20 per 1 million requests
- Pay per duration :
400,000 GB seconds of compute time per month if FREE
== 400,000 sec if function is 1GB RAM
== 3,200,000 seconds if function is 128MB RAM
- After that $1.00 for 600,000 GB-sec
- It is usually very cheap to run AWS Lambda so it's very popular
[ AWS Lambda Limits to Know - per region ]
Execution :
1) Memory allocation 128mb-10GB (64mb increments)
2) Maximum execution time : 900 sec (15min)
3) Environment variables (4 KB)
4) Disk capacity in the function container (in /tmp) : 512MB
5) Concurrency executions : 1000 (can be increased)
Deployment :
1) Lambda function deployment size (compressed .zip) : 50MB
2) Size of uncompressed deployment (code + dependencies) : 250MB
3) Can use the /tmp directory to load other files at startup
4) Size of environment variables : 4 KB
'infra & cloud > AWS' 카테고리의 다른 글
[AWS] 15. DynamoDB (0) | 2021.09.06 |
---|---|
[AWS] 14-2. Lambda@Edge (0) | 2021.09.02 |
[AWS] 13. Docker, ECS/Fargate/EKS (0) | 2021.04.25 |
[AWS] 12-4. Amazon MQ, SQS vs SNS vs Kinesis (0) | 2021.04.25 |
[AWS] 12-3. Kinesis Data Streams (0) | 2021.04.18 |