Chapter 1: Go Serverless
- What are the advantages of using the serverless approach?
Answer:
- NoOps: no management or configuration overhead and faster time to market.
- Autoscaling and HA: enhanced scalability and elasticity based on load.
- Cost-optimization: pay only for the compute time your consume.
- Polygot: leverage the power of nanoservices architecture.
- What makes Lambda a time-saving approach?
Answer: You pay per execution and you don't pay for idle resources, while with EC2 instances, you pay also for unused resources.
- How does serverless architecture enable microservices?
Answer: Microservices is the approach of breaking down a monolithic application into a collection of smaller and modular services. Serverless computing is a key enabled for microservices-based applications. It makes infrastructure even-driven and completely controlled by the needs of each service that makes up an application. Moreover, serverless means functions, and a microservice is a set of functions.
- What is the maximum time limit for an AWS Lambda function?
Answer: By default, each Lambda function has a 3 seconds timeout; the maximum duration you can set, is 5 minutes.
- Which of the following are supported event-sources for AWS Lambda?
- Amazon Kinesis Data Streams
- Amazon RDS
- AWS CodeCommit
- AWS CloudFormation
Answer: Amazon Kinesis Data Streams, AWS CodeCommit and CloudFormation are supported event-sources for AWS Lambda. The list of all supported event sources can be found on the following url: https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html
- Explain what a goroutine is in Go. How can you stop goroutines?
Answer: A goroutine is lightweight thread; it uses a resource called channel to communicate. Channels, by design, prevent race conditions from happening when accessing shared memory using goroutines. To stop a goroutine, we pass signal channel. That signal channel is used to push a value. The goroutine polls that channel regularly. As soon as it detects a signal, it quits.
- What's Lambda@Edge in AWS?
Answer: Lambda@Edge allows you to run Lambda functions at the edge locations of CloudFront in order to customize the content returned to your end users at the lowest latency.
- What's the difference between Function as a Service and Platform as a Service?
Answer: Both PaaS and FaaS allow you to easily deploy an application and scale it without worrying about the underlying infrastructure. However, FaaS saves you money because you pay only for the compute time used to handle the incoming requests.
- What's an AWS Lambda cold start?
Answer: Cold start happens when a new event is triggered; AWS Lambda creates and initialize a new instance or container to handle the request, which takes longer (Startup latency) compared to warm starts, where the container is reused from a previous event.
- Can AWS Lambda functions be stateless or stateful?
Answer: Lambda functions must be stateless to leverage the power of autoscaling due to increasing rate of incoming events.