Koepe do Brasil, 2026
Reports that brought the API down
The problem
XLSX and PDF reports were generated inside the API itself. Large exports loaded everything into memory and took the service down for everyone.
Result
The memory spikes that crashed the API are gone. Users request a report, keep working, and download the file straight from S3 through a presigned URL.
What I did
- Moved exports out of the API into an event-driven microservice on RabbitMQ.
- Made the worker stream from MongoDB and stream the file to S3, never holding the whole report in memory.
- Added retries and a dead letter queue so no export fails silently.
- Wired it into the React front end with a real-time notice when the file is ready, isolated per tenant.
Request
the API answers at once and publishes an event
RabbitMQ
queue with retries; failures go to the DLQ
Worker
streams from MongoDB, builds XLSX or PDF
AWS S3
streamed upload, flat memory use
Download
presigned URL and a real-time notice