swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 788 forks source link

异步任务投递使用queue模式 投递任务变慢 #167

Closed jianhuihi closed 6 years ago

jianhuihi commented 6 years ago

task_ipc_mode=2会出现问题

task_ipc_mode=1则正常

测试代码 task

public function deliverCo(string $p1, string $p2) {
        sleep(10);
        return sprintf('deliverCo-%s-%s', $p1, $p2);
    }

controller

public function getuser() {
        set_time_limit(0);
        $number = range(1, 50);
        foreach ($number as $key => $value) {
            $re[] = Task::deliver('sync', 'deliverCo', [$value, 2], Task::TYPE_ASYNC);
        }
        return $re;
}

swoft: 1.0.0, php: 7.1.14, swoole: 2.1.1

daydaygo commented 6 years ago

@jianhuihi 测试 task_ipc_mode = 1/2 的时候, 表现是相同的, 你说的 投递任务变慢 是什么情况?

stelin commented 6 years ago

@jianhuihi 问题已经复现,我们尽快修复。

stelin commented 6 years ago

建议使用非队列模式!