python - Handling time consuming requests in Flask-UWSGI app -


am running app flask , uwsgi , nginx. uwsgi set spawn out 4 parallel processes handle multiple requests @ same time. have 1 request takes lot of time , changes important data concerning application. so, when 1 uwsgi process processing request , others busy, fifth request have wait. problem here cannot change request run in offline mode changes important data , user cannot remain unknown it. best way handle situation ?

as option can following:

  1. separate heavy logic function being called upon @route , move separate place (a file, function, etc)
  2. introduce celery run pieces of heavy logic (it processed in separate thread @route-decorated functions). quick way of doing using redis message broker.
  3. schedule time-consuming functions @route-decorated functions in celery (it possible pass parameters well)

this way http requests won't blocked complete function execution time.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -