最近,我們的 Laravel 查詢?nèi)罩咀兊妹黠@更大。每天約為 50-100mb,一天后增加到約 1-1.5gb。有很多對(duì)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]他們整天都在這樣詢問。我怎樣才能減少這個(gè)金額?或者有那么多疑問可以嗎jobs?
1 回答

郎朗坤
TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊
是的,如果您有積壓的工作需要幾秒鐘才能完成,這似乎很正常。
來自文檔:
當(dāng)隊(duì)列中有可用作業(yè)時(shí),工作人員將繼續(xù)處理作業(yè),作業(yè)之間不會(huì)有任何延遲。但是,該
sleep
選項(xiàng)確定如果沒有新的工作可用,工作人員將“睡眠”多長(zhǎng)時(shí)間(以秒為單位)。睡眠期間,worker 不會(huì)處理任何新作業(yè) - 這些作業(yè)將在worker 再次醒來后處理。https://laravel.com/docs/7.x/queues#job-expirations-and-timeouts
因此,在您的示例中,隊(duì)列工作線程有積壓的作業(yè)需要處理,并且在每個(gè)完成的作業(yè)后立即獲取下一個(gè)作業(yè)。
- 1 回答
- 0 關(guān)注
- 98 瀏覽
添加回答
舉報(bào)
0/150
提交
取消