Learn the essentials of launching a serverless Node.js REST API using AWS Lambda and API Gateway. Build understanding of serverless vs. server-based architectures, key features, pros, cons, and best-fit scenarios.
Which of the following is a key advantage of serverless architectures compared to traditional server-based setups?
Explanation: Serverless platforms, such as AWS Lambda, automatically scale based on incoming requests without user intervention. Manual OS updates are part of server-based models. Continuous 24/7 billing and high control over server configuration are characteristics of traditional server-based setups, not serverless.
Why do AWS Lambda functions require external storage like DynamoDB or S3 when building a REST API?
Explanation: AWS Lambda functions are stateless and do not remember anything between invocations, so external storage is needed for persistent data. Internal database storage is not supported. Environment variables are not persisted across executions, and Lambda functions have a maximum execution time limit.
What is a potential drawback of cold starts in serverless APIs built with Node.js on AWS Lambda?
Explanation: Cold starts mean the first invocation after a period of inactivity can be slower due to environment initialization. The API remains available and scalable, with no need for manual VM provisioning; these other issues do not describe cold starts.
How does AWS Lambda improve cost efficiency when hosting REST APIs compared to traditional servers?
Explanation: AWS Lambda charges based on usage, so there is no cost when the API is idle. There are no up-front payments for reserved instances, no flat required monthly charges, and costs do not increase when not in use.
For which type of workload is deploying a Node.js REST API via AWS Lambda usually NOT recommended?
Explanation: AWS Lambda functions have a maximum execution time limit and are not suitable for long-running tasks like model training. Event-driven tasks, periodic APIs, and short background jobs align well with Lambda's strengths.