Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bufferoverflow's avatar

Background job stuck causing server CPU 100% usage

I have been trying to solve this issue for a long time. Sometimes my background jobs get stuck causing high CPU usage. I have to manually kill the process in order to free up the memory,

Some people recommended making smaller jobs, but in this case, I think it is not possible because this job only connects to an SMTP server and loops the folders.

How can I debug where is it getting stuck? Is it possible to autokill the process if it keeps running more than X time? Or limit the amount of CPU it can use (I think currently it's only memory limited)?

Imgur Imgur

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

Do you run this job at fixed intervals?

Is it possible that you start the job again before it has finished, which only makes it slower, then you launch another job, then another job etc

1 like
bufferoverflow's avatar

Turns out there was a deeply hidden infinite loop in some of these jobs. And they kept timing out and re-dispatched every minute.

Please or to participate in this conversation.