cswork / libraryOpen practice workspace

Articles

Step Functions Distributed Map Interview Questions: Concurrency, Partial Failure, and Redrive

Practice Step Functions Distributed Map interviews with concurrency calculations, partial-failure accounting, replay boundaries, and safe recovery checks.

The strongest Step Functions Distributed Map interview answer separates concurrency, item failure tolerance, retries inside a child workflow, retrying the Map state, and redriving the parent execution. Those controls do not promise the same replay boundary. A workflow that failed can already have committed useful output, and recovering it can repeat externally visible work.

This guide grounds service semantics in current AWS documentation. The invoice manifest, capacity calculations, and recovery ledger are original interview exercises, not an AWS benchmark or a candidate-reported assessment. Practice Prevent Duplicate Request Processing alongside the examples: orchestration status is not proof that a business operation happened only once.

What does Distributed Map add to ordinary Map reasoning?

Distributed mode runs child workflow executions with histories separate from the parent and represents their orchestration as a Map Run. The AWS Distributed Map reference defines its configuration and constraints. Do not describe it as simply a larger loop in the parent's execution history.

Start an interview design by identifying the source dataset, its snapshot boundary, the unit assigned to a child, and the durable output. An item can mean one record; a child can process a batch. Those identities need not be interchangeable. A parent success also might permit some failures under your configured tolerance, so business completeness requires a separate policy.

For a synthetic invoice-export job, define one immutable input manifest, one invoice ID per logical record, and a versioned destination key. That gives you a stable basis for retry, reconciliation, and auditing. If the source changes during recovery, a fresh run may not be equivalent to replaying the original job. State that assumption before promising reproducibility.

Does MaxConcurrency limit downstream requests per second?

It limits concurrent child workflow executions, not directly the request rate of every service they call. A child may make several calls, launch parallel work, wait, or retry. AWS's Map configuration exposes the concurrency setting; your downstream capacity model remains your responsibility.

In the original exercise, 40 children each take about two seconds and each make one request. A rough steady-state estimate is 20 requests per second, ignoring startup, retries, and duration variation. Now suppose each child issues ten requests in its first 100 milliseconds. The same cap can create a much sharper burst. Neither estimate is a service guarantee.

Ask for the downstream sustainable rate, burst allowance, retry load, and acceptable completion time. Start with a conservative cap, instrument actual attempts and latency, and use an additional rate-control mechanism if the contract is about requests per second. Reducing concurrency alone can help without constituting a strict rate limiter.

Describe how capacity is shared. Two simultaneous Map Runs may compete for the same database or external API. A per-run cap that is safe in isolation can be unsafe at portfolio level. Your answer should distinguish account/service quotas from the much lower limit imposed by the destination workload. Check current quotas rather than memorizing one headline maximum.

Exercise: failure tolerance is not an output-quality guarantee

Assume 100 input invoices, no batching, and a tolerated failure percentage of 2%. All records have equal weight for this exercise. At completion, 97 succeeded, two failed, and one timed out. What should you predict?

The failure numerator is three, including the timeout, so 3% exceeds 2%. At exactly two unsuccessful items, 2% would not exceed that percentage threshold. AWS's documented threshold comparison is exceeded, not “reached.” If you configure both percentage and count thresholds, either exceeded threshold can fail the Map Run. These details come from the Distributed Map reference.

Now change the business requirement: one failed invoice belongs to the largest customer and must be exported. A tolerated percentage cannot express that record's importance by itself. Track required records separately and reconcile them even if the orchestrator permits partial success. Your business report might be incomplete while the Map Run is operationally successful.

Change the unit again: ten invoices are processed in each child. AWS's Map Run inspection guide explains the relationship between child failure and batched item status. One failing record can make its child fail, affecting the batch's failure accounting. Do not silently reuse the unbatched calculation without establishing how the service counts those items.

There may also be in-flight children when the threshold is crossed. Crossing a failure threshold does not establish that all work stopped at that exact instant. Read the terminal Map Run and child states, then reconcile destination commits. Treating the first failure notification as an atomic stop can cause duplicate writes during premature recovery.

What gets replayed by each retry boundary?

Place retry policy at the smallest appropriate failure boundary. A transient request failure inside a child is different from failing and retrying the entire Distributed Map state. AWS specifically documents that Map-level Retry applies to all child executions started by that Map, and retrying it creates a new Map Run. It is not a failed-items-only switch. See the Retry section of the Map reference.

Use this decision comparison while answering:

Recovery choiceScope you must reason aboutRequired follow-up
Retry a Task inside a childThat task can be invoked againDid the first call commit before its response failed?
Retry the Distributed Map stateChild work is repeated under a new Map RunCan previously successful items safely run again?
Redrive the parent at its unsuccessful MapRecovery uses Map Run redrive semanticsAre children Standard or Express, and are they eligible?
Start a new parent executionA new execution uses the supplied inputIs the dataset snapshot identical, and what is already committed?

The synthetic picture intentionally omits service-specific task types. In a real design, identify the actual service integration and retryable error names. Broadly retrying every error can repeatedly hammer malformed input or missing permissions. Add bounded attempts, backoff, and a quarantine or failure report that preserves the record identity.

How do Standard and Express children change redrive?

The AWS Map Run redrive guide distinguishes them. Eligible unsuccessful Standard children resume from the state that caused their unsuccessful execution. Failed or timed-out Express children restart at the first state in their ItemProcessor. Successful children are not simply rerun as though this were Map-level Retry.

That difference matters when a child first writes an export and then sends a notification. If only the notification fails, an eligible Standard child's recovery can resume at that failed state. Express recovery starts its processing again, so the earlier export step must tolerate repetition. Even Standard task retry still needs protection against ambiguous commits at the failed task.

Do not say Standard children are always redrivable. Eligibility constraints can exclude them. Also, the original Map Run may still be completing cancellation or result export after the parent stops; recovery can wait for those operations. Verify the actual status and eligibility rather than offering redrive as a universal immediate repair button.

An interviewer may ask whether switching to Standard solves duplicate business effects. No: it can change recovery behavior and visibility, but an external operation can succeed while its response is lost. You need an application-level write contract regardless of workflow type. Choose execution type for the whole workload, including duration, observability, and economics, not only this favorable scenario.

Build an item ledger that survives ambiguous commits

Use this original ledger design for the invoice export. A logical operation key is (manifest_version, invoice_id, export_version). Record the destination location, content digest, status, and attempt context. Workflow and child identifiers are diagnostic attributes, not the sole deduplication key: a new execution can represent the same logical operation.

For an object export, a deterministic destination and content check may make repeats harmless. For a charge or email, overwriting a result object is not enough. The destination needs a suitable idempotency contract or a transactional claim-and-commit design. Explain how a crashed worker that acquired a claim is recovered; a permanent “in progress” marker is another failure mode.

The ledger should distinguish “known committed,” “known failed before commit,” and “outcome unknown.” Unknown work is not automatically safe to retry. Query the destination or use its idempotency mechanism before repeating an irreversible action. If reconciliation cannot settle it, route it to a reviewable exception rather than claiming exactly-once behavior.

Test the failure after the export commits but before the child acknowledges success. Run recovery and assert one logical export version exists, its digest matches, and the ledger converges. Then test concurrent recovery attempts. Deduplication that works serially can still race when two workers both observe an absent record and commit independently.

What should ResultWriter and IAM contribute to diagnosis?

Large results should not be forced into an oversized parent output. AWS ResultWriter documentation describes exporting Map Run results, including result files and manifests. Decide which output structure preserves failed-item identity and which transformation is appropriate before treating an export as your reconciliation ledger.

Result export is evidence about workflow execution, not independent proof of every external side effect. Preserve the input manifest version and business operation keys so you can join result records to committed output. A transformation that strips those identifiers can make a visually tidy export operationally useless.

Permissions are another distinct boundary. The AWS IAM example for Distributed Map covers child execution and relevant data access. A failed S3 read or result write does not imply that every child business task failed. Investigate the action, principal, resource, and error before granting a wildcard permission.

Include failure visibility in the interview design: Map Run identity, child status, attempt count, item or batch key, downstream error category, and output reconciliation totals. Avoid placing sensitive invoice content in broad logs. A useful dashboard should answer what remains unresolved, not merely display a green or red parent execution icon.

Defend a recovery decision, not just a button

Suppose the parent is failed, most exports exist, a few outcomes are unknown, and the destination is still throttling. First reduce pressure and identify the failed boundary. Reconcile known commits and unknown outcomes against the immutable manifest. Then choose child-level recovery, eligible parent redrive, or a new selective reconciliation job with explicit input.

Define acceptance before recovery: every required invoice has one correct logical export; no prohibited duplicate notifications occurred; unresolved items are enumerated; error rate and request rate stay within the destination contract. A successful redrive is useful service evidence, but the business acceptance test must inspect output as well.

Practice questionTopic-specific follow-up
Prevent Duplicate Request ProcessingProtect item commits across repeated child execution.
Design a Task Scheduler and ExecutorDefine admission, item identity, and poison-work handling.
Debug a Concurrent Job SchedulerSeparate in-flight work from starts per second.
Design a Resilient Document Aggregation ServiceReconcile partial output before recovery.
Improve an ML Inference ServiceExplain how batching changes the failure unit.

Start with Prevent Duplicate Request Processing. Have a partner lose the response after a commit and ask which key remains stable across a new Map Run. If you can answer that and predict the Standard-versus-Express recovery boundary, you are explaining the system rather than naming features.

Sources and further reading