Serverless Flashcards
1
Q
What’s Serverless ? Tell name of services which are serverless in AWS ?
A
- Serverless is a new paradigm in which we don’t need to manage servers anymore. We just deploy our code or functions.
- For example Lambda, Cognito, S3, API Gateway, DynamoDB, Kinesis, Aurora, SNS and SQS etc are managed services in AWS
2
Q
Why do we need AWS Lambda ? Why it’s preferred over EC2 ?
A
- EC2 has some drawbacks. EC2 are virtual servers on the cloud. We require manual intervention to add/remove servers. They are limited by CPU and RAM. They are continuously running.
- On the other hand Lambda are virtual functions. We don’t need to manage servers. They run on demand. Even scaling is automated.
3
Q
What are some salient features of Lambda ?
A
- Easy Pricing - Pay per request and compute time. Free tier of 10,00,000 requests and 4,00,000 GBs of compute time
- Integrated with whole suite of services and many programming languages
- Easy monitoring with AWS CloudWatch
- Easy to get more resources per Lambda function (up to 10 GBs of RAM)
- INCREASING RAM WILL ALSO IMPROVE CPU & NETWORK
4
Q
What languages are supported by Lambda ?
A
- NodeJS
- Python
- Java
- C#
- Ruby
- Custom Runtime API. Community supported, for example Rust & Golang
5
Q
How can we expose a Lambda function as an HTTPS endpoint ?
A
We can integrate a Lambda function with an Application Load Balancer or API Gateway. The Lambda function must be registered in a target group.
6
Q
How can we synchronously and asynchronously invoke a Lambda function ?
A
- Synchronous Invocation - CLI, SDK, API Gateway, Application Load Balancer. Results are returned right away and error handling must happen client side.
- Asynchronous Invocation - S3, SNS & CloudWatch Events, Event Bridge, Code Commit, Code Pipeline. The events are placed in an Event Queue. Lambda retries 3 times on errors. 1 min wait after first retry. 2 mins wait after second retry. We have to ensure our function is idempotent because of retries. We can define SQS or SNS as a Dead Letter Queue for failed processing.
- We can invoke Lambda function from a cron job trigger using EventBridge
- We can invoke Lambda function on STATE change in CodePipeline
7
Q
How can we deliver S3 event notifications to Lambda functions
A
- S3 event notifications - We can generate events every time an object is created, removed, restored or replicated in S3 bucket. (APIs - S3: ObjectCreated, S3: ObjectRemoved, S3:ObjectRestored, S3:Replication)
- Use case - Create thumbnails of images uploaded in S3
3.Typically events are delivered in seconds, but sometimes it could take more than a minute or two
- For ensuring successful event notifications for every write, we can enable versioning on the S3 bucket
8
Q
A