php7异步返回,具有FPM的PHP7上的异步/线程

我发现pthreads在Web环境中不起作用.我在Linux Debian上的FPM上使用PHP7.1,我也使用Symfony 3.2.我想要做的就是,例如:

>用户发出请求并放置文件(1GB)

> PHP Server接收文件并对其进行处理.

>立即向用户(jsonResponse)返回true,而无需等待处理上传的文件

>稍后,在完成文件处理(移动,复制,复制所需的任何内容)后,只需添加一个事件或从后台进行回调并通知用户.

现在.为此,我创建了控制台命令.我执行一个Process(‘bin / console my:command’)-> start();从背景,我做我的处理.但这对我来说是用火箭筒杀死一只苍蝇.我必须将许多变量传递给此可执行命令.

我要做的就是创建另一个线程,然后不等待处理就返回给用户.

您可能会说这是重复的.并指向pthreads.但是pthreads声明它仅用于CLI.同样,最新版本的pthreads不适用于symfony. (致命错误).

我被困在这一点上,并且怀疑我是否应该继续为每个上载的文件创建进程或移至python->詹戈

解决方法:

您不需要线程.您想要一个工作队列.看一下Gearman或类似的东西.

Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. It can be used in a variety of applications, from high-availability web sites to the transport of database replication events. In other words, it is the nervous system for how distributed processing communicates.

标签:asynchronous,pthreads,php

来源: https://codeday.me/bug/20191111/2023174.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值