From Zero to RESTful API: Node.js on AWS Lambda in Under 30 Minutes Quiz

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.

  1. Serverless vs Server-based Architecture

    Which of the following is a key advantage of serverless architectures compared to traditional server-based setups?

    1. Manual OS updates required
    2. Automatic scaling per request
    3. High control over server configuration
    4. Continuous 24/7 billing

    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.

  2. Stateless Design in Serverless

    Why do AWS Lambda functions require external storage like DynamoDB or S3 when building a REST API?

    1. They automatically persist all environment variables
    2. They support direct internal database storage
    3. They do not retain memory between invocations
    4. They always run for unlimited time

    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.

  3. Cold Starts in Serverless Computing

    What is a potential drawback of cold starts in serverless APIs built with Node.js on AWS Lambda?

    1. API cannot handle incoming requests at all
    2. Requires manual provisioning of virtual machines
    3. No scalability during high traffic
    4. First request after idle may experience extra latency

    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.

  4. Cost Efficiency in Serverless APIs

    How does AWS Lambda improve cost efficiency when hosting REST APIs compared to traditional servers?

    1. Requires up-front payment for reserved instances
    2. Always charges a flat monthly fee regardless of usage
    3. Increases costs when idle due to continuous billing
    4. Charges only for actual execution time and requests

    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.

  5. Best-fit Use Cases for Serverless APIs

    For which type of workload is deploying a Node.js REST API via AWS Lambda usually NOT recommended?

    1. Background jobs with short execution times
    2. APIs that respond to periodic user requests
    3. Long-running machine learning model training
    4. Event-driven data processing tasks

    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.