I am developing a RESTful web service using flask-restful.
The client needs to be able to request a job to be performed by the server. This job can take anywhere from ~1 second to ~1 hour to perform. Generally, it is expected to take 1-5 minutes.
When the job is complete, the client needs to download a JSON dump. Anywhere from 100KB to 100MB in size.
I see 2 options:
- The client submits the job as a POST request, and the response from the server only comes when the job is complete. The response includes the JSON dump.
- The client submits the job as a POST request, and the server responds immediately with a 200 OK. The client then submits a GET status request every, say, 60 seconds. When the job is complete, it submits another GET request to download the JSON dump.
Which option is preferred under REST principles?
The problem I see with Option 1 is the possibility of network disruption whilst waiting for the response.