7

We are currently developing an image processing restful api. Server performs some CPU-heavy computations image processing upon request and return the image to the client.

We want to make this a single http request (all computation should be done).

My questions.

  • What is the best workflow for this. With speed has an high factor.

  • Other alternatives suggest using a Master/Worker Server workflow. But will mean multiple requests (first to put job in queue, others to poll if job is done). We want to make it a one trip request. How can we achieve this?

  • The single request would most definitely take some time how do we handle timeouts

One more thing, we are using NodeJS.

Tom Peach
  • 209

1 Answers1

8

You should submit your requests using a POST, and your service should return a URL that will retrieve the image once it's been processed. If the URL is accessed before the processing is complete, you should return a 202 (ACCEPTED) response. Once processing is complete, you can serve the processed image.

TMN
  • 11,383