Django Asynchronous Processing

前端 未结 2 1554
清歌不尽
清歌不尽 2021-02-03 12:47

I have a bunch of Django requests which executes some mathematical computations ( written in C and executed via a Cython module ) which may take an indeterminate amount ( on the

2条回答
  •  忘掉有多难
    2021-02-03 13:47

    Since you are planning to make it async (presumably using something like gevent), you could also consider making a threaded/forked backend web service for the computational work.

    The async frontend server could handle all the light work, get data from databases that are suitable for async (redis or mysql with a special driver), etc. When a computation has to be done, the frontend server can post all input data to the backend server and retrieve the result when the backend server is done computing it.

    Since the frontend server is async, it will not block while waiting for the results. The advantage of this as opposed to using celery, is that you can return the result to the client as soon as it becomes available.

    client browser <> async frontend server <> backend server for computations
    

提交回复
热议问题