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

Launch a simple, serverless REST API using Node.js and cloud functions by leveraging AWS Lambda and API Gateway. This quiz checks your understanding of key concepts and best practices for building rapid, production-ready APIs in a serverless architecture.

  1. Server-Based vs Serverless: Key Differences

    Which of the following is a primary advantage of using a serverless approach like AWS Lambda compared to traditional server-based deployment?

    1. Manual firewall setup required
    2. Long-running process support
    3. Continuous billing regardless of usage
    4. Automatic scaling per request

    Explanation: Serverless platforms automatically manage scaling in response to incoming requests, reducing operational overhead. Traditional deployments often incur costs even when idle and require manual setup like firewalls. Serverless functions are not well suited for long-running tasks, since they have strict timeout limits.

  2. Cold Starts in Serverless Functions

    What is a cold start when working with cloud-based serverless functions?

    1. A function that processes cold storage files
    2. An error caused by invalid code deployment
    3. Failing to connect to an external API
    4. A delay in first request after a period of inactivity

    Explanation: A cold start refers to the initial latency when a serverless function is triggered after being idle, as the cloud platform initializes the function. It is not related to cold storage, code errors, or connectivity issues.

  3. Statelessness of Lambda Functions

    Why must you use external storage like databases when designing with AWS Lambda functions?

    1. Functions cannot execute any code logic
    2. Functions can only process image files
    3. Functions run only in a local environment
    4. Functions do not retain data between invocations

    Explanation: Lambda functions are stateless, meaning any data in memory is lost after execution, so persistent storage must be in an external database. Lambda functions clearly can execute code logic, can run in the cloud, and are not limited to image files.

  4. Common Use Cases for Serverless APIs

    Which scenario is best suited for deployment as a serverless REST API using Node.js and AWS Lambda?

    1. Long-running scientific simulations
    2. Hosting a real-time, high-frequency trading platform
    3. On-demand processing of web requests
    4. Continuously streaming video

    Explanation: Serverless APIs excel at handling on-demand web requests because they scale automatically and cost nothing when idle. Streaming, simulations, and real-time trading require low latency or long execution times, which serverless platforms are not designed to handle due to their limitations.

  5. Potential Drawbacks of Serverless Architectures

    What is a possible downside of heavily relying on serverless cloud services to build your API?

    1. Requirement to purchase physical hardware
    2. Increased risk of vendor lock-in
    3. Guaranteed free usage at all times
    4. Inability to scale under load

    Explanation: Building with specific cloud services ties your architecture to a provider, which can complicate future migration (vendor lock-in). Serverless services do scale well, are not always free, and do not require physical hardware purchases by the user.