Tracking long-running operations
What's inside this article
⌄
- How to handle long running operations
- Async operation status tracking pattern
- Long running api best practices
- Implement polling status endpoint
Suppose we have a long-running application – maybe it’s processing a large video file, running complex calculations, or generating a comprehensive report.
We don’t want to block external clients waiting for the result, as this could lead to timeouts and poor user experience.
A common solution to this problem is to implement an asynchronous pattern where we:
- Accept the initial request and return a tracking ID
- Redirect the client to a status endpoint they can poll
- Allow clients to check the operation status using this endpoint
- Provide the final result when ready
High-level view:

Example implementation might look like this:
# Initial request
POST /process
Response: { "tracking_id": "abc-123" }
# Status checking endpoint
GET /status/abc-123
Response: { "status": "processing", "progress": "60%" }
# Final result
GET /status/abc-123
Response: { "status": "completed", "result": "..." }