Run PHP Task Asynchronously

后端 未结 15 1237
青春惊慌失措
青春惊慌失措 2020-11-22 15:15

I work on a somewhat large web application, and the backend is mostly in PHP. There are several places in the code where I need to complete some task, but I don\'t want to m

15条回答
  •  一生所求
    2020-11-22 15:31

    If it just a question of providing expensive tasks, in case of php-fpm is supported, why not to use fastcgi_finish_request() function?

    This function flushes all response data to the client and finishes the request. This allows for time consuming tasks to be performed without leaving the connection to the client open.

    You don't really use asynchronicity in this way:

    1. Make all your main code first.
    2. Execute fastcgi_finish_request().
    3. Make all heavy stuff.

    Once again php-fpm is needed.

提交回复
热议问题