AWS Lambda interview questions — practice quiz

Reviewed by Mark Dickie · Last updated

14 questions on this page you can answer and see marked on the spot. Go to the first one

AWS Lambda is a serverless compute service that runs your code in response to events without provisioning or managing servers. For interviews, you need to know how Lambda's execution model works: cold starts, the invocation lifecycle, concurrency limits, and how function configuration choices affect cost and latency. You should also be comfortable with VPC networking for Lambda, IAM execution roles, and the trade-offs between synchronous and asynchronous invocation.

What does an AWS Lambda interview typically test?

Interviewers usually focus on a few areas where Lambda behaves differently from traditional compute:

TopicWhat they ask
Cold startsWhy they happen, how provisioned concurrency mitigates them
ConcurrencyReserved vs. unreserved account limits, throttle behavior
Invocation typesSynchronous (RequestResponse) vs. asynchronous (Event) semantics
VPC configENI creation, cold start impact, internet access for non-VPC functions
Limits15-minute max duration, 10 GB ephemeral storage (/tmp), 10 GB memory
PricingGB-second billing model, free tier, how memory size affects cost

How does Lambda concurrency work?

Each AWS account gets a concurrency limit for the entire region (default 1,000, adjustable). Every concurrent execution counts against that pool until it finishes. You can carve out reserved concurrency for specific functions so they always have headroom, even if other functions spike. When the pool is exhausted, new synchronous invocations get throttled (429 errors); asynchronous invocations queue and retry with exponential backoff.

What should you review before the interview?

  1. The difference between provisioned concurrency and reserved concurrency — they solve different problems.
  2. How to set up dead-letter queues for async invocations and understand the retry policy (two retries by default).
  3. The /tmp storage mount, its 10 GB cap, and how it persists across invocations on the same execution environment.
  4. Lambda layers for shared dependencies and how they reduce deployment package size.
  5. Event source mappings: which AWS services invoke Lambda synchronously vs. asynchronously vs. via polling (SQS, DynamoDB Streams, Kinesis).
  6. How environment variables, including encrypted ones via KMS, are exposed at runtime.

Key facts

  • Tarmac's AWS interview questions cover 24 questions at difficulty 1–5 of 5.
  • Tarmac tracked 5,372 job postings asking for AWS in September 2026.
  • Roles asking for AWS advertise a median base salary of US$172,500, across 1,891 job postings as of September 2026.
  • Tarmac last reviewed these AWS interview questions on 13 October 2026.

At a glance

Questions24
Difficulty1–5 of 5
FormatsMultiple choice, Short answer, True / false, Multiple answer, Fill in the blank

What you'll review

  1. lambda

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

Which two factors primarily determine the cost of a single AWS Lambda function invocation?#

Options

Show answer

AWS Lambda charges per request plus compute duration, where compute cost equals the configured memory allocation multiplied by execution time in milliseconds. Package size, event payload size, and concurrency settings do not directly determine per-invocation cost.

Why:

AWS Lambda bills per request plus the compute time consumed, where compute time is calculated as the configured memory size multiplied by the execution duration in milliseconds. The deployment package size, S3 storage, event payload size, and concurrency settings do not directly factor into the per-invocation cost formula.

Which AWS service lets you run code without provisioning or managing servers and bills you only for the compute time your code actually consumes?#

Options

Show answer

AWS Lambda is the AWS service that runs code without provisioning or managing servers. It bills only for the compute time your code consumes, metered in milliseconds, and charges nothing while code sits idle.

Why:

AWS Lambda is the serverless compute service that runs code in response to events without requiring you to provision or manage servers, and it bills based on actual execution duration metered in milliseconds. Amazon EC2 provides virtual servers that you must provision and pay for while they run, Amazon EBS is block storage rather than a compute runtime, and AWS CloudFormation is infrastructure-as-code that provisions resources but does not execute your application code.

What is the maximum allowed execution timeout for a single AWS Lambda function invocation?#

Show answer

15 minutes (900 seconds).

Why:

AWS Lambda enforces a hard maximum of 15 minutes (900 seconds) per invocation, and the function's configured timeout cannot be set above that limit. If an invocation runs longer than its timeout, Lambda terminates it. The answer is an open fact, so a short free-text answer is the right format.

True or false: AWS Lambda automatically provisions and manages the compute infrastructure needed to run your code, so you do not need to provision or manage servers yourself.#

Options

Show answer

True. AWS Lambda automatically provisions and manages the compute infrastructure needed to run your code, so you do not provision or manage servers yourself. You upload the code, and Lambda handles provisioning, scaling, and operating the underlying servers, which is the defining trait of serverless computing.

Why:

AWS Lambda is a serverless compute service. You upload your code and Lambda automatically handles provisioning, scaling, and operating the underlying servers, which is the defining characteristic of serverless computing. The statement therefore holds, so the answer is true.

True or false: AWS Lambda functions can be invoked in response to Amazon S3 events, such as object creation.#

Options

Show answer

True, AWS Lambda functions can be invoked by Amazon S3 events such as object creation. You configure an event notification on the bucket, and S3 sends the event to Lambda, which runs your function automatically. No polling or server is required on your side.

Why:

This is true. Lambda is one of the supported destinations for Amazon S3 event notifications. When you configure a notification on an S3 bucket for events like object creation, S3 sends the event to Lambda, which invokes your function automatically.

Which of the following statements about AWS Lambda execution environment reuse (warm starts) are true? Select all that apply.#

Options

Pick every one that applies.

Show answer

Variables declared outside the handler and initialization code outside the handler both carry over when Lambda reuses an execution environment, so that code is not re-run on warm invocations. Lambda does not give every invocation a new environment, and concurrent requests run in separate environments rather than sharing global state.

Why:

Lambda runs each invocation inside an execution environment, and it reuses that environment for later invocations (warm starts). Because the environment persists, module-level variables keep their values, and the initialization code outside the handler runs only when the environment is created, not on each reused invocation. Lambda does not guarantee a new environment per invocation, since environments are reused whenever available. Concurrent requests are handled by separate execution environments, each processing one event at a time, so global state is not shared across concurrent invocations.

AWS Lambda SnapStart is a performance feature that addresses a specific cold-start problem for a particular set of runtimes. Briefly explain what SnapStart does and name the runtime family it was originally designed to support.#

Show answer

AWS Lambda SnapStart reduces initialization latency for Lambda functions by capturing a snapshot of the fully-initialized execution environment and restoring that snapshot when new execution environments are needed, instead of rerunning the init code each time. It was originally designed to support the Java runtime family (Java managed runtimes, such as Corretto-based ones), which has long JVM startup and class-loading overhead.

Why:

SnapStart takes a snapshot of the function's initialized state after the init phase and restores that snapshot for new execution environments, so the init code does not run again on each cold start. The feature launched for the Java runtime family because JVM startup and class loading made Java cold starts especially slow. A correct answer must name both the snapshot-and-restore mechanism and the Java runtime family.

You are configuring an AWS Lambda function that processes large batch files and you need to set the longest possible execution timeout. What is the current maximum configurable timeout for a single AWS Lambda function invocation?#

Options

Show answer

The maximum configurable timeout for a single AWS Lambda function invocation is 15 minutes (900 seconds). Lambda lets you set the timeout anywhere from 1 second up to this 15-minute ceiling; exceeding it causes Lambda to terminate the invocation and return a timeout error. Workloads needing longer execution should use a different compute service like Fargate or EC2.

Why:

AWS Lambda allows you to configure a function timeout between 1 second and 15 minutes (900 seconds). If the function does not complete within the configured timeout, Lambda terminates it and returns a timeout error. For workloads that need more than 15 minutes, you must split the work across multiple invocations or use a different compute service such as AWS Fargate or EC2.

When you create a new AWS Lambda function from the AWS Management Console without changing any timeout settings, what is the default maximum execution duration before the function is forcibly terminated?#

Show answer

3 seconds. The console sets a default timeout of 3 seconds on every new function, which stops runaway invocations quickly. The timeout can be raised to a maximum of 15 minutes (900 seconds).

Why:

AWS Lambda applies a default timeout of 3 seconds to every newly created function. This is deliberately conservative so that runaway invocations are stopped quickly and unexpected cost is minimized. The timeout can be increased up to a hard ceiling of 15 minutes (900 seconds), but 3 seconds is the out-of-the-box default.

You invoke an AWS Lambda function using the AWS CLI with --invocation-type Event. What is the behavior the caller observes?#

Show answer

With --invocation-type Event, the Lambda API returns a 202 (Accepted) response immediately and does not block until the function finishes executing. The event is queued internally and retried on failure according to the configured asynchronous retry policy, so the caller receives no return value from the function itself.

Why:

AWS Lambda supports two primary invocation modes. RequestResponse (the default) is synchronous: the caller blocks and receives the function's return value. Event is asynchronous: the API immediately returns a 202 Accepted and the event is queued for processing, so the caller does not wait for, nor receive, the function's result. Failed asynchronous invocations are retried under the function's async retry configuration.

When you increase the memory allocation for an AWS Lambda function, what does AWS automatically scale in proportion to that memory setting?#

Show answer

CPU power (vCPU). Lambda allocates CPU in proportion to the configured memory, so more memory gives more vCPU, which can shorten execution time and lower the total duration cost.

Why:

Lambda has no separate CPU setting. The only resource you configure is memory, and Lambda allocates CPU power proportionally to it, so raising the memory setting raises the available vCPU share. Because a CPU-bound function can finish faster with more vCPU, the higher memory setting can sometimes reduce total billed cost even though the per-millisecond rate is higher.

You configure provisioned concurrency on an AWS Lambda function (alias prod). Which statement accurately describes the behavior of provisioned concurrency?#

Options

Show answer

Provisioned concurrency pre-initializes a set number of Lambda execution environments so invocations within that level skip the init (cold-start) phase. It does not cover invocations that exceed the provisioned level — those can still cold-start on on-demand environments. You are billed for the provisioned capacity regardless of actual usage, and it is configured independently from reserved concurrency.

Why:

Provisioned concurrency pre-initializes a requested number of execution environments so that invocations routed to them skip the initialization code (the cold-start phase) and begin executing the handler immediately. Only invocations that fall within the provisioned level get this benefit — any surge beyond provisioned concurrency is served by on-demand environments that may still cold-start. It is independent of reserved concurrency (a hard cap on total concurrent executions), so the claim that it must be set equal to the function's reserved concurrency value is wrong. Billing is for the provisioned capacity over time, not per invocation, so the claim that you are billed only for invocations that actually use a pre-initialized environment is wrong. And the claim that it eliminates cold starts for every invocation of the function, including those that exceed the provisioned concurrency level, is wrong because the guarantee does not extend to invocations beyond the provisioned level.

Which statement about AWS Lambda provisioned concurrency is correct?#

Options

Show answer

Provisioned concurrency pre-initializes a fixed number of Lambda execution environments so that invocations up to that level avoid cold-start latency. You pay for the provisioned capacity whether or not it is invoked, and it must target a published version or alias rather than $LATEST. It is separate from reserved concurrency, which only caps concurrency.

Why:

Provisioned concurrency pre-initializes (warms) a fixed number of execution environments, so invocations up to the configured level skip cold-start initialization. The statement about billing for idle capacity is wrong because you pay for provisioned capacity whether or not it is invoked. Provisioned concurrency cannot be set on $LATEST; it must target a published version or an alias. Reserved concurrency is a separate feature that only caps concurrent executions without pre-warming, so the two are not the same setting.

In the AWS Lambda execution environment lifecycle, a cold start happens when AWS must create a new execution environment. The cold start includes the _____ phase, during which the runtime loads your code and runs any initialization logic declared outside the handler. On a warm start, this phase is skipped and the environment goes straight to the _____ phase, where the handler function is called.#

Show answer

In the AWS Lambda execution environment lifecycle, a cold start happens when AWS must create a new execution environment. The cold start includes the Init phase, during which the runtime loads your code and runs any initialization logic declared outside the handler. On a warm start, this phase is skipped and the environment goes straight to the Invoke phase, where the handler function is called.

Why:

The Lambda execution environment lifecycle has two phases: Init and Invoke. On a cold start, AWS creates a new environment and runs Init — loading the runtime and executing your code outside the handler (global/static initialization). On a warm start, the existing environment is reused so Init is skipped and the platform goes directly to the Invoke phase, where the handler is called with the event.

An AWS Lambda function written in Python contains client = boto3.client('s3') at module scope (outside the handler). The handler uses client to call list_buckets(). Lambda reuses the same execution environment across sequential invocations when possible. Which statement about the boto3.client('s3') line is correct?#

Options

Show answer

The boto3.client('s3') line at module scope runs once per execution environment initialization, during the cold start. Warm invocations that reuse the same environment skip it and reuse the existing client object. This is why SDK clients are usually created outside the handler to avoid rebuilding them on every request.

Why:

Code at module scope runs during the execution environment's initialization phase, which is the cold start. When Lambda reuses that warm environment for later invocations, it does not re-run module-level code, so the S3 client created at init persists and is reused by the handler. The statement describing a new client on every invocation contradicts this reuse. The statement about a single client shared across the whole account is wrong because execution environments are per function instance, not per account. The statement claiming the line is skipped on warm invocations and the client is recreated on return is wrong because the client is not rebuilt on return; it stays in memory for the environment's lifetime.

What is a Lambda cold start, and name at least two ways to reduce its impact on latency-sensitive requests.#

Show answer

A cold start is the extra latency incurred when Lambda has to create a fresh execution environment for an invocation — downloading/unpacking the code, starting the runtime, and running your initialization (init phase) — because no warm environment is available to reuse. Subsequent invocations reuse the warm environment and skip that cost. Ways to reduce the impact: configure Provisioned Concurrency to keep N environments pre-initialized and warm; use SnapStart (e.g. for Java) to restore from a snapshot; trim the deployment package and dependencies so init is faster; move heavy setup (SDK clients, DB connections) into the init phase so it's reused and out of the request path; right-size memory (more memory = more CPU = faster init); and avoid unnecessary VPC attachment. The init phase is also billed, so cold starts cost money as well as latency.

Why:

Cold start = the one-time cost of spinning up a new execution environment (init phase) when none is warm to reuse. The signal is whether the candidate knows the real levers: Provisioned Concurrency / SnapStart to pre-warm, slimmer packages and right-sized memory to shorten init, and moving reusable setup into the init phase. Naming Provisioned Concurrency as the only answer is shallow — it costs money around the clock, so the better engineers weigh it against optimizing the function itself.

Your team deploys a Lambda function (alias: prod) with provisioned concurrency configured at 50. The function has no reserved concurrency set, so only the account-level unreserved concurrency pool applies. A sudden burst of 120 simultaneous invocations arrives, and the account has plenty of unreserved concurrency available. In 2–3 sentences, describe exactly what happens to the 70 invocations that exceed the provisioned-concurrency limit: do they experience cold starts, and which concurrency pool do they draw from?#

Show answer

The 70 invocations that exceed the provisioned-concurrency limit of 50 overflow into the account's unreserved concurrency pool. Because no pre-initialized execution environments are available for them, they must spin up new environments, so they incur cold-start latency. They are not throttled (as long as unreserved capacity is available) and are not queued behind the provisioned environments.

Why:

Provisioned concurrency pre-initializes a fixed number of execution environments for a specific alias or version. Invocations up to that limit are served instantly from warm environments. Any invocation beyond the provisioned amount overflows to standard execution: Lambda spins up new environments on demand, so those invocations incur cold-start latency. They are not queued and not throttled while the unreserved pool has capacity, and they do not raise the provisioned limit; they simply draw from the account's unreserved concurrency pool. Throttling only occurs when total concurrent executions exceed the sum of all reserved concurrency allocations plus the unreserved pool, or when a function-level concurrency limit is hit.

You enable AWS Lambda SnapStart on a Java 21 function whose handler class creates a java.security.SecureRandom instance in a static initializer. Across concurrent invocations served by execution environments restored from the snapshot, the random values repeat identically. Name the recommended fix and the SnapStart mechanism that implements it. Explain why the static initializer causes the repetition.#

Show answer

Use a SnapStart runtime hook: implement the CRaC org.crac.Resource interface on a class, create or reseed the SecureRandom in its afterRestore method, and register it with Core.getGlobalContext().register(...). Static initialization runs during the Init phase, before Lambda takes the snapshot, so every environment restored from that snapshot starts with the same SecureRandom internal state and produces the same sequence. Re-creating the instance after restore (in afterRestore, or lazily in the handler) gives each restored environment fresh state. Moving the initialization into the handler also works but runs the cost on every invocation path, so the runtime hook is the recommended approach.

Why:

SnapStart takes a snapshot after the Init phase, which includes static initializers, so a SecureRandom created there has its internal state frozen into the snapshot. When Lambda restores the snapshot to create new execution environments, Init is not re-run, so every restored environment shares the same generator state and emits identical values. The recommended fix is to use the Java runtime hooks (the CRaC Resource API) and re-create or reseed the SecureRandom in afterRestore, which runs after each restore. Lazily creating it inside the handler also avoids the stale state, but the runtime hook is the documented mechanism for this class of problem.

Design a Lambda-based real-time order processing pipeline for a large e-commerce platform. During peak events, the system receives bursts of up to 50,000 orders per second. Each order must be validated, persisted to a database, and trigger downstream notifications. The SLA requires end-to-end processing latency under 2 seconds and zero data loss. Address in your design: how orders are ingested and trigger Lambda at this throughput, how you manage Lambda concurrency and cold starts, how you prevent data loss under failures, how you handle database write throughput from Lambda, and how you monitor and auto-scale the system.#

Show answer

Ingestion: API Gateway uses its direct service integration to call Kinesis Data Streams PutRecords (up to 500 records or 5 MB per call), so no Lambda sits in the ingress path. Size the stream with shards: each shard accepts 1,000 records/sec or 1 MB/sec of writes, so 50,000 orders/sec needs at least 50 shards for small payloads. Add headroom (for example 60+ shards), and add more if payloads are large enough that the 1 MB/sec byte limit binds. Kinesis buffers bursts and preserves ordering within each shard.

Processing Lambda and concurrency: A Lambda function is attached to the stream through a Kinesis event source mapping. Set the parallelization factor to 10 so each shard is processed by up to 10 concurrent batches. Use a batch size of up to 10,000 records and a batching window of about 1 second to cut per-record invocation overhead. Cold starts are handled with provisioned concurrency on a published alias, scaled by Application Auto Scaling target tracking on the ProvisionedConcurrencyUtilization metric (target around 0.7). Register the scalable target with MinCapacity and MaxCapacity bounds (for example 50 to 600), and add scheduled actions to raise the minimum before known peak events. Set reserved concurrency on the function itself at or above the maximum provisioned concurrency, which isolates the workload from other functions in the account. A reserved value below the provisioned amount would block provisioned concurrency allocation. Request an increase to the account concurrency quota early, because the default regional limit can be exceeded at peak.

Database writes: Use DynamoDB in on-demand capacity mode so bursts need no manual capacity planning. Create the DynamoDB client outside the handler so connections are reused across invocations. Use BatchWriteItem (at most 25 items per call, so a 10,000-record batch needs several calls) to reduce API calls and round-trips. Retry any UnprocessedItems with exponential backoff. Batching does not lower write-capacity charges, since WCUs are billed per item written. BatchWriteItem does not accept ConditionExpression, so idempotency comes from keying items by orderId (replaying a write re-puts the same item) or from per-item conditional PutItem (attribute_not_exists(orderId)) or TransactWriteItems where a true duplicate check is required. Publish notifications only after the DynamoDB write is confirmed, to SNS with SQS queues per notification type, so consumers are decoupled from the critical write path.

Failure handling and zero data loss: The Kinesis event source mapping uses bisect-batch-on-error to isolate poison records, a maximum of 3 retries, and a maximum record age. Records that exhaust retries are sent to an SQS dead-letter queue through the mapping's OnFailure destination for investigation and replay. Each notification queue also has its own DLQ. Kinesis delivers at least once, so the write path must be idempotent as described above.

Monitoring and scaling: CloudWatch alarms watch the Kinesis GetRecords.IteratorAge metric (processing lag), Lambda ConcurrentExecutions, Throttles, and error rate. An alarm can trigger a Lambda function that calls UpdateShardCount to scale shards, or the stream can use on-demand mode. X-Ray traces per-request latency across API Gateway, Kinesis, Lambda, DynamoDB, and SNS to verify the 2-second end-to-end SLA.

Why:

This is an open design question, so it is graded against its key points rather than one fixed answer. A strong answer sizes Kinesis shards from the 1,000 records/sec and 1 MB/sec per-shard limits to absorb 50,000 orders/sec. It uses a Kinesis event source mapping with parallelization factor 10, large batches, and a short batching window to drain the stream efficiently. Cold starts are addressed with provisioned concurrency managed by Application Auto Scaling, with reserved concurrency set at or above the provisioned amount. Zero data loss comes from bisect-on-error, bounded retries, and dead-letter queues, combined with idempotent writes because delivery is at least once. DynamoDB on-demand mode and BatchWriteItem handle write throughput, and the answer must note that BatchWriteItem does not support condition expressions. Monitoring uses CloudWatch metrics such as IteratorAge, with X-Ray for latency visibility.

A Lambda function has reserved concurrency set to 100. On its production alias (weighted 100%), provisioned concurrency is configured at 50. During a sudden traffic burst, 80 concurrent invocations arrive simultaneously, which is well within the reserved limit. Which statement accurately describes the execution behavior?#

Options

Show answer

With 80 concurrent invocations, a Lambda function with reserved concurrency 100 and provisioned concurrency 50 runs all 80 at once: 50 on warm provisioned environments and 30 on new on-demand environments that incur cold starts, with none throttled. Provisioned concurrency is a pre-warmed subset of reserved concurrency, not a ceiling.

Why:

Provisioned concurrency pre-warms execution environments to remove cold-start latency; it does not cap concurrency. The ceiling is reserved concurrency, here 100, and 80 is below that, so no invocation is throttled. The first 50 are served by already-initialized provisioned environments. The remaining 30 exceed the provisioned count, so Lambda creates on-demand environments for them; those invocations pay cold-start latency but run concurrently with the rest. The option claiming a limit of 150 is wrong because provisioned concurrency counts against reserved concurrency rather than adding to it. The option claiming the excess is throttled is wrong because the total stays under the reserved cap. The option claiming excess invocations are queued for warm environments is wrong because synchronous invocations overflow to on-demand environments rather than waiting for provisioned capacity.

An AWS Lambda function has reserved concurrency set to 100 and provisioned concurrency set to 20. Which statement about how these two settings interact is true?#

Options

Show answer

Within a reserved concurrency limit, Lambda serves invocations beyond the provisioned count with on-demand execution environments, which can incur cold-start latency instead of being throttled. Provisioned concurrency pre-warms environments to reduce latency, while reserved concurrency sets the ceiling on how many executions the function can run at once.

Why:

Provisioned concurrency pre-warms a fixed number of execution environments (here 20) so those invocations start immediately, which addresses latency. Reserved concurrency is the hard ceiling on concurrent executions (here 100). When concurrent invocations exceed the provisioned count but stay under the reserved limit, Lambda creates on-demand environments for the overflow; those invocations can experience cold starts but are not throttled. Throttling happens only when concurrency would exceed the reserved limit. The statement about invocations beyond the provisioned count being throttled is wrong for that reason, the claim that provisioned concurrency raises the ceiling is wrong because reserved concurrency is the maximum, and reserved concurrency does not pre-warm anything.

True or false: Provisioned concurrency on a Lambda alias eliminates cold starts for ALL invocations to that alias, regardless of whether the number of concurrent invocations exceeds the provisioned amount.#

Options

Show answer

Provisioned concurrency on a Lambda alias does not eliminate cold starts for all invocations. It only keeps the configured number of execution environments initialized, so concurrent requests up to that count avoid cold starts. Requests beyond that count are served by on-demand environments that run the standard initialization phase, so those invocations can still cold start.

Why:

Provisioned concurrency pre-initializes exactly the number of execution environments set in its configuration. While concurrent invocations stay at or below that number, each request lands on a warm environment and skips the init phase. Once concurrency exceeds the provisioned value, the overflow requests are served by on-demand environments that go through the standard initialization phase, which is a cold start. So the guarantee is capacity-bound: it covers only the first N concurrent requests, where N is the provisioned value, and does not cover all invocations regardless of concurrency.

Your Java 21 (Corretto) Lambda function is deployed with SnapStart enabled. During the Init phase it seeds a java.security.SecureRandom and a java.util.Random from static initializers. After SnapStart restores a snapshot into multiple new execution environments, which statement accurately describes the behavior of these two RNGs across restored instances?#

Options

Show answer

With AWS Lambda SnapStart on Java, the runtime automatically patches java.security.SecureRandom so each restored execution environment produces unique random values. However, java.util.Random and similar non-SecureRandom generators are not patched — their internal state is restored from the snapshot, so they may emit identical sequences across restored instances unless the developer re-seeds them (e.g., via a Restore hook).

Why:

When SnapStart restores a snapshot, the JVM heap — including the internal state of any RNG — is restored verbatim. Without intervention, two restored environments would continue from the identical RNG state and produce the same sequence of numbers. For Java, the Lambda runtime automatically patches java.security.SecureRandom (and the provider backing it) so that each restored environment yields cryptographically unique values. However, java.util.Random and other non-SecureRandom generators (e.g., ThreadLocalRandom) are NOT patched — their state is restored from the snapshot and they will produce duplicate sequences across restored environments unless the developer explicitly re-seeds them, for example via a SnapStart Restore hook (registered through the AWS Lambda Runtime Interface) or by re-initializing them on first invocation. The claim that both RNGs are automatically patched is wrong because only SecureRandom is patched. The claim that neither RNG is patched is wrong because SecureRandom is handled automatically; a Restore hook is only needed for the unpatched RNGs. The claim that the snapshot restore injects fresh OS entropy into both RNGs is wrong because the snapshot is a memory-level copy — fresh OS entropy is not mixed into the JVM's existing RNG state during restore; the runtime's SecureRandom patch is what provides uniqueness.

When AWS Lambda SnapStart is enabled on a Java 21 (Corretto) function, which of the following correctly describes what happens when a new execution environment is launched from a snapshot?#

Options

Show answer

When SnapStart launches a new Java 21 execution environment, Lambda loads the memory snapshot taken after the Init phase, so static initializers and the handler constructor do not run again. A Restore phase then runs registered runtime hooks, and only afterward does the Invoke phase begin. Network connections and file descriptors are not preserved in the snapshot and must be re-established.

Why:

With SnapStart, Lambda captures the memory of the execution environment after the Init phase has finished, so a new environment is created by loading that snapshot rather than re-running static initializers or the handler constructor. The Restore phase then runs any registered runtime hooks, and Invoke starts only after Restore completes. The distractors fail for specific reasons: re-running Init contradicts the snapshot model, OS-level resources such as sockets and file descriptors are not part of a memory snapshot and must be re-established during Restore, and Restore hooks run before the first invocation, not after it.

Related interview questions

Job market

See aws salaries and hiring demand from live job postings.

Practise these until they stick

That's every question we hold on this topic, and the page marks what you pick. What it can't do is remember. A free account keeps every answer, and what you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.