AWS Builder Center

Step Functions Distributed Map processed 50,000 files without a single custom fan out Lambda

I used to build a custom Lambda based fan out pattern for processing large batches of files, until Distributed Map in Step Functions replaced that whole layer of custom code.

Processing a batch of tens of thousands of files used to mean writing a Lambda function whose only job was listing an S3 prefix, splitting the list into chunks, and fanning out invocations to a worker function, with all the retry and concurrency logic for that fan out written by hand.


What Distributed Map replaces


The  Distributed Map state  reads directly from an S3 prefix or a JSON array and fans out to a child workflow per item, handling concurrency limits and per item retries natively, which removed the custom fan out Lambda entirely.

json
{
"Type": "Map",
"ItemProcessor": {
"ProcessorConfig": { "Mode": "DISTRIBUTED" }
},
"ItemReader": {
"Resource": "arn:aws:states:::s3:listObjectsV2",
"Parameters": { "Bucket": "my-input-bucket" }
},
"MaxConcurrency": 200
}
```
Running it against fifty thousand files

The first real run processed a backlog of about fifty thousand files, and the built in concurrency control meant I could cap parallel processing at two hundred without writing any throttling logic myself, while a handful of items that failed due to a malformed file got automatically retried and then routed to a failure output without taking down the whole run.

What I would still watch for

The one thing that caught me off guard was mapping the per item error details back to something readable, since the failure output is structured for machines, not for a quick glance, so I added a small Lambda step just to summarize failures into something a person could scan quickly. Outside of that, this removed a whole category of custom orchestration code I used to consider unavoidable.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article