最近,我们的 Laravel 查询日志变得明显更大。每天约为 50-100mb,一天后增加到约 1-1.5gb。有很多对jobs表的查询,像这样[05.08.2020 00:00:02] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574802, 1596571202][05.08.2020 00:00:05] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574805, 1596571205][05.08.2020 00:00:09] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574809, 1596571209][05.08.2020 00:00:12] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574812, 1596571212][05.08.2020 00:00:15] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574815, 1596571215][05.08.2020 00:00:18] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574818, 1596571218][05.08.2020 00:00:21] select * from `jobs` where `queue` = ? and ((`reserved_at` is null and `available_at` <= ?) or (`reserved_at` <= ?)) order by `id` asc limit 1 for update [default, 1596574821, 1596571221]他们整天都在这样询问。我怎样才能减少这个金额?或者有那么多疑问可以吗jobs?
1 回答
郎朗坤
TA贡献1921条经验 获得超9个赞
是的,如果您有积压的工作需要几秒钟才能完成,这似乎很正常。
来自文档:
当队列中有可用作业时,工作人员将继续处理作业,作业之间不会有任何延迟。但是,该
sleep
选项确定如果没有新的工作可用,工作人员将“睡眠”多长时间(以秒为单位)。睡眠期间,worker 不会处理任何新作业 - 这些作业将在worker 再次醒来后处理。https://laravel.com/docs/7.x/queues#job-expirations-and-timeouts
因此,在您的示例中,队列工作线程有积压的作业需要处理,并且在每个完成的作业后立即获取下一个作业。
- 1 回答
- 0 关注
- 69 浏览
添加回答
举报
0/150
提交
取消