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:
- separate heavy logic function being called upon @route , move separate place (a file, function, etc)
- introduce celery run pieces of heavy logic (it processed in separate thread @route-decorated functions). quick way of doing using redis message broker.
- 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
Post a Comment