Re: [flask] create a new job per HTTP request
- Daniel Neuhäuser
- 2014-12-30 @ 21:54
> does it make sense for an app to create a new job for each http POST
> request on a certain endpoint or should the endpoint process the
> request immediately?
No, it does not make sense at all to create new jobs for each HTTP post
request. You should always process the request immediately.
> by immediately, i mean use a few function calls to validate the data,
> insert the data, and on success or failure of updating the db, return
> this status to the user
Which is btw, exactly what happens in the tutorial.
> i can do this with 3-4 lines, but i can't decide if i should just
> throw the request into a job scheduler
You should never throw requests in a job scheduler.
One caveat to what I said: Sometimes you will find that you simply cannot
perform a computation fast enough to respond to a request in any
acceptable timeframe with a final result. In that case you should still
respond immediately but process asynchronously in a matter that allows you
to check on the progress/state of the process and retrieve the result once
it has been computed. This is however the exception and not the rule.