Serverless & Edge Interview Questions Hindi mein

Serverless & Edge कोर्स के 32 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

Mental Model and Prerequisites

1. Which statement best describes serverless computing?

  1. Code runs without any physical servers being involved
  2. The provider manages servers and scaling, and you pay mainly for actual use
  3. All application code runs inside the user's browser
  4. It is a hosting option that only works for static websites
जवाब देखें

जवाब: The provider manages servers and scaling, and you pay mainly for actual use

Servers still exist, but provisioning, patching and scaling are the provider's job, and billing follows usage. Browser-only code and static hosting are different things.

पाठ: What Serverless Really Means

2. What is a point of presence (PoP)?

  1. A database replica that accepts writes
  2. A single large data centre that hosts an entire cloud region
  3. A billing unit used to price serverless functions
  4. A smaller network location of a CDN placed close to users
जवाब देखें

जवाब: A smaller network location of a CDN placed close to users

PoPs are the many CDN locations spread across cities. A region is a much larger, less numerous cluster of data centres.

पाठ: Regions, PoPs and the Edge

3. Which workload is the weakest fit for a typical FaaS platform?

  1. Generating a thumbnail whenever a photo is uploaded
  2. A nightly job that emails a short summary report
  3. A video transcoding job that runs for two hours per file on steady, round-the-clock input
  4. An API for a contest site that is idle except during contest weekends
जवाब देखें

जवाब: A video transcoding job that runs for two hours per file on steady, round-the-clock input

Function duration limits and constant high utilisation both work against FaaS. The other three are short, event-driven or bursty: classic fits.

पाठ: When Serverless Fits and When It Does Not

Functions as a Service Foundations

4. In a Lambda Node.js handler `async (event, context) => {...}`, what is `event`?

  1. A JSON payload whose shape depends on the trigger that invoked the function
  2. An EventEmitter you must subscribe to with `.on()`
  3. The function's configuration such as memory and timeout
  4. A stream of log lines from previous invocations
जवाब देखें

जवाब: A JSON payload whose shape depends on the trigger that invoked the function

The event is the input data from the trigger: an HTTP request, queue records, an S3 notification and so on. Configuration and logs are separate.

पाठ: The Handler Contract

5. An S3 upload triggers a Lambda function asynchronously and the function throws an error. What happens by default?

  1. S3 immediately shows an error to the user who uploaded the file
  2. Lambda retries the invocation, and after the retries it can go to a configured DLQ or destination
  3. The file upload is automatically rolled back
  4. Nothing; asynchronous invocations are never retried
जवाब देखें

जवाब: Lambda retries the invocation, and after the retries it can go to a configured DLQ or destination

For asynchronous invocations the platform owns retries. S3 has already finished the upload and does not wait for the function.

पाठ: Synchronous, Asynchronous and Poll-Based Invocation

6. Which code runs only during a cold start?

  1. The body of the handler function
  2. Code inside a `finally` block in the handler
  3. Any `console.log` call
  4. Top-level module code outside the handler
जवाब देखें

जवाब: Top-level module code outside the handler

Top-level code runs once during Init. The handler body runs on every invocation, warm or cold.

पाठ: Execution Environments and Cold Starts

Triggers and Event-Driven Design

7. A handler returns `{ statusCode: 200, body: { ok: true } }` behind API Gateway. What is wrong?

  1. Nothing; API Gateway serialises objects automatically in every configuration
  2. The status code must be a string
  3. Handlers behind HTTP must return a Promise of a Response object
  4. The body should be a string, for example `JSON.stringify({ ok: true })`
जवाब देखें

जवाब: The body should be a string, for example `JSON.stringify({ ok: true })`

Proxy integrations expect a string body. Serialise objects yourself and set a content-type header.

पाठ: Serving HTTP with Functions

8. Without partial batch reporting, what happens when one message in an SQS batch of ten makes the handler throw?

  1. Only the failed message is retried
  2. All ten messages become visible again and are retried
  3. The failed message is deleted and the other nine are retried
  4. The queue is paused until an operator intervenes
जवाब देखें

जवाब: All ten messages become visible again and are retried

A thrown error fails the whole batch, so successful messages are reprocessed too. Returning `batchItemFailures` limits the retry to the failed ones.

पाठ: Queues and Streams as Triggers

9. A function triggered by uploads to `photos/` writes thumbnails to `photos/thumbs/` in the same bucket, with no filter on the trigger. What is the risk?

  1. Thumbnails will be written in the wrong image format
  2. S3 will reject writes from a function it triggered
  3. Each thumbnail triggers the function again, creating a recursive loop
  4. The function will be throttled to one invocation per minute
जवाब देखें

जवाब: Each thumbnail triggers the function again, creating a recursive loop

The output lands under the prefix that triggers the function. Use a separate bucket or prefix, or filter the trigger, to break the loop.

पाठ: Scheduled Jobs and Storage Events

State, Data and Idempotency

10. Which of these is safe to keep in a module-level variable of a function?

  1. An SDK client configured once from environment variables
  2. The ID of the user making the current request
  3. A running total of orders that must be reported accurately
  4. The only copy of a file uploaded by a user
जवाब देखें

जवाब: An SDK client configured once from environment variables

A client is safe to share and costly to recreate. Per-request data, authoritative totals and the only copy of user data belong in external storage.

पाठ: Designing Stateless Functions

11. Which operation is naturally idempotent?

  1. Sending a welcome email
  2. Adding 100 reward points to a user
  3. Setting a ticket's status to "closed"
  4. Appending a row to an audit log
जवाब देखें

जवाब: Setting a ticket's status to "closed"

Setting a value to a fixed state gives the same result however many times it runs. The others repeat their effect on every execution.

पाठ: Idempotency and At-Least-Once Delivery

12. A spike creates 800 concurrent Lambda environments, each opening one Postgres connection, and the database allows 200. What is the most direct fix?

  1. Increase the function memory
  2. Route connections through a pooler such as RDS Proxy and limit function concurrency
  3. Move the function to another region
  4. Open a fresh connection inside the handler on every call
जवाब देखें

जवाब: Route connections through a pooler such as RDS Proxy and limit function concurrency

A pooler multiplexes many clients onto few connections, and a concurrency cap keeps the function from overrunning the database. Opening per-call connections makes it worse.

पाठ: Databases for Serverless Workloads

Edge Runtimes

13. Why are cold starts on isolate-based edge runtimes typically much shorter than on container-based functions?

  1. Edge functions are written in a faster programming language
  2. Edge platforms keep a dedicated server running for every customer
  3. Edge functions cannot make network requests
  4. A new isolate is created inside an already-running runtime process instead of booting a container or VM
जवाब देखें

जवाब: A new isolate is created inside an already-running runtime process instead of booting a container or VM

Isolates share an existing engine process, so there is no OS or container to boot. Language choice and dedicated servers are not the reason.

पाठ: Edge Runtimes and V8 Isolates

14. In a Cloudflare Worker `fetch(request, env, ctx)`, what is `env` used for?

  1. Reading bindings such as variables, secrets and KV namespaces
  2. Setting the HTTP status code of the response
  3. Accessing the Node.js `process` object
  4. Choosing which PoP the request is routed to
जवाब देखें

जवाब: Reading bindings such as variables, secrets and KV namespaces

`env` carries the bindings declared in configuration. The response status is set on the `Response` you return, and PoP routing is done by the network.

पाठ: Writing a Fetch Handler

15. Which job is the poorest fit for edge middleware?

  1. Redirecting old blog URLs to new ones
  2. Rejecting requests that carry an invalid token
  3. Adding security headers to every response
  4. Generating a 50-page PDF report from several database queries
जवाब देखें

जवाब: Generating a 50-page PDF report from several database queries

Middleware sits in front of every matching request and has tight CPU limits. Heavy, data-bound work belongs in a regional function or a background job.

पाठ: Edge Middleware Patterns

Edge Data and Caching

16. Which directive sets freshness for shared caches like a CDN without changing what browsers do?

  1. private
  2. no-store
  3. s-maxage
  4. must-revalidate
जवाब देखें

जवाब: s-maxage

`s-maxage` applies only to shared caches. `private` and `no-store` prevent caching rather than tune it.

पाठ: HTTP Caching at the CDN

17. Which data is the best fit for an eventually consistent edge KV store?

  1. A feature-flag configuration updated a few times a day
  2. The remaining seat count for a flash-sale train booking
  3. A bank account balance
  4. A counter that must give every user a unique ticket number
जवाब देखें

जवाब: A feature-flag configuration updated a few times a day

Rarely written, often read data tolerates a short propagation delay. Seat counts, balances and unique counters need strong consistency.

पाठ: Edge Key-Value Stores and Consistency

18. An edge function makes five sequential queries to a database on another continent. What is the most likely result?

  1. It is always faster because edge code runs closer to the user
  2. It is slower than the same function deployed next to the database
  3. The queries automatically run in parallel at the edge
  4. The database replicates itself to every PoP
जवाब देखें

जवाब: It is slower than the same function deployed next to the database

Each sequential query pays the long round trip. Co-locating the function with the database turns five long trips into one.

पाठ: Compute Near Users or Near Data

Tooling, Deployment and Infrastructure as Code

19. What is the main benefit of declaring a function's IAM permissions in the same IaC template as the function?

  1. Permissions become unnecessary once they are in a template
  2. The function runs faster
  3. Permission changes are versioned and reviewed together with the code that needs them
  4. The template automatically grants administrator access during development
जवाब देखें

जवाब: Permission changes are versioned and reviewed together with the code that needs them

IaC puts permissions under version control and code review, so least privilege can actually be checked. It does not change performance or remove the need for permissions.

पाठ: Infrastructure as Code for Serverless

20. Why separate business logic from the handler?

  1. Handlers are not allowed to contain more than ten lines
  2. The logic can be unit-tested with plain inputs, without events, mocks or cloud access
  3. It removes the need for integration tests
  4. It makes the deployment package smaller
जवाब देखें

जवाब: The logic can be unit-tested with plain inputs, without events, mocks or cloud access

Pure functions are the easiest code to test. Integration tests are still needed for permissions and wiring.

पाठ: Local Development and Testing

21. In Lambda, what is an alias?

  1. A copy of the function deployed to another region
  2. An immutable snapshot of the function code
  3. An environment variable that stores the function name
  4. A named pointer to a version that can also split traffic between two versions
जवाब देखें

जवाब: A named pointer to a version that can also split traffic between two versions

Versions are the immutable snapshots; an alias points at one (or weights two), so triggers need not change during a rollout.

पाठ: Versions, Aliases and Safe Rollouts

Observability, Failures and Cost

22. Why should a latency dashboard show p99 and not only the average duration?

  1. The average cannot be computed for serverless functions
  2. p99 is always lower and therefore looks better in reports
  3. Rare slow requests, such as cold starts, are hidden by the average but visible in the tail
  4. Providers bill only for p99 duration
जवाब देखें

जवाब: Rare slow requests, such as cold starts, are hidden by the average but visible in the tail

A small share of slow requests barely moves the average yet hurts real users. Tail percentiles expose them.

पाठ: Logs, Metrics and Traces

23. An asynchronously invoked function keeps failing and has no DLQ or on-failure destination configured. What happens to the event after the retries are exhausted?

  1. It stays in the platform queue forever
  2. It is discarded
  3. It is returned to the original caller as an HTTP error
  4. It is written automatically to an S3 bucket
जवाब देखें

जवाब: It is discarded

Without a DLQ or destination, the event is dropped after the retries. Configure one and alarm on it.

पाठ: Errors, Retries and Dead-Letter Queues

24. A function configured with 1024 MB runs for 200 ms per request. How many GB-seconds does one request use?

  1. 0.2
  2. 204.8
  3. 1024
  4. 0.02
जवाब देखें

जवाब: 0.2

1024 MB is 1 GB, and 200 ms is 0.2 s, so 1 x 0.2 = 0.2 GB-seconds.

पाठ: Understanding the Cost Model

Performance and Security

25. What does provisioned concurrency on Lambda do?

  1. Removes the per-region concurrency quota
  2. Makes every function run on dedicated hardware for free
  3. Bundles and minifies your code automatically
  4. Keeps a configured number of environments initialised and ready, billed while it is enabled
जवाब देखें

जवाब: Keeps a configured number of environments initialised and ready, billed while it is enabled

It pre-initialises environments so requests up to that level avoid cold starts, and you pay for that capacity whether or not it is used.

पाठ: Reducing Cold Start Impact

26. A function receives 300 requests per second and each takes 400 ms on average. Roughly how many concurrent executions does it need?

  1. 120
  2. 750
  3. 300
  4. 12
जवाब देखें

जवाब: 120

Concurrency is about rate x duration = 300 x 0.4 s = 120.

पाठ: Concurrency, Throttling and Downstream Protection

27. Which practice best follows least privilege for a function that only reads one DynamoDB table?

  1. Attach the AdministratorAccess policy during development and remove it later
  2. Allow `dynamodb:*` on `*` so future features work without changes
  3. Allow only the needed read actions on that one table's ARN
  4. Share one role across all functions to keep things simple
जवाब देखें

जवाब: Allow only the needed read actions on that one table's ARN

Grant the minimum actions on the specific resource. Broad or shared roles turn any bug into an account-wide risk.

पाठ: Securing Serverless and Edge Apps

Architecture Patterns and Pitfalls

28. Why is a function that synchronously invokes another function and waits for it considered an anti-pattern?

  1. Functions are technically unable to call other functions
  2. You pay for both while the first one waits, and timeouts and failures become coupled
  3. It always causes a recursive loop
  4. It disables logging for the second function
जवाब देखें

जवाब: You pay for both while the first one waits, and timeouts and failures become coupled

The caller is billed while idle, the chain's timeouts must nest, and one failure cascades. Queues or a workflow engine decouple the steps.

पाठ: Composition Patterns: Choreography, Orchestration and Fan-Out

29. An API gateway times out at 29 s, the function at 60 s, and its database call has no timeout. What is the main problem?

  1. The database call is too fast for the function
  2. Nothing; longer inner timeouts are always safer
  3. The client may get a gateway timeout while the function keeps running and billing with no one waiting
  4. The function will be retried automatically by the gateway
जवाब देखें

जवाब: The client may get a gateway timeout while the function keeps running and billing with no one waiting

Inner timeouts should be shorter than outer ones. Otherwise work continues after the caller has given up, wasting money and hiding the real error.

पाठ: Common Pitfalls and How to Avoid Them

Revision and Interview Prep

30. Which pairing is correct?

  1. Edge KV: strongly consistent; Durable Objects: eventually consistent
  2. Top-level module code: runs on every invocation
  3. Asynchronous invocation: the caller waits for the function's result
  4. Poll-based invocation: the platform reads a queue or stream and invokes the function with batches
जवाब देखें

जवाब: Poll-based invocation: the platform reads a queue or stream and invokes the function with batches

Event source mappings poll queues and streams and deliver batches. The other three pairings are reversed or wrong.

पाठ: Cheat Sheet: Serverless and Edge on One Page

31. In the serverless URL shortener design, why is an eventually consistent edge store acceptable for the redirect lookup?

  1. Edge stores are always strongly consistent anyway
  2. Redirects are never cached
  3. Short codes are recalculated from the long URL on every request
  4. Links are read far more than written, and a brief delay before a new link is visible everywhere can be handled with a fallback
जवाब देखें

जवाब: Links are read far more than written, and a brief delay before a new link is visible everywhere can be handled with a fallback

Read-heavy data that rarely changes suits eventual consistency, especially with a fallback to the regional store on a miss.

पाठ: Interview and Exam Questions

32. A Lambda function behind API Gateway takes 200 ms when warm but sometimes 3 s after a quiet hour. Logs show an Init Duration on the slow calls. What is the most targeted fix if those slow calls are unacceptable?

  1. Shrink the bundle and init work, and add provisioned concurrency if it is still too slow
  2. Add a dead-letter queue
  3. Set `Cache-Control: private` on the response
  4. Reduce the function's reserved concurrency to 1
जवाब देखें

जवाब: Shrink the bundle and init work, and add provisioned concurrency if it is still too slow

Init Duration marks cold starts. Smaller packages and lighter init reduce them; provisioned concurrency removes them for the configured capacity. A DLQ, caching headers and lower concurrency do not address it.

पाठ: Mixed Self-Check

← कोर्स पर वापस जाएँ