Skip to content

November 2026 · Queues · Laravel · Background Jobs

What Belongs in a Queue, and What Does Not

A web request should finish quickly and do one thing. Here is how I decide what gets pushed to a background worker, with real examples from my school system.

What Belongs in a Queue, and What Does Not

The fingerprint machine lesson

ZKTeco attendance machines at a school gate push each punch straight to the server, and they can send a burst of them in a few minutes every morning. If each punch had to look up the student, write attendance and trigger a parent message inside the request, the device would be waiting on a text message gateway. So the API now accepts the punch, hands it to ProcessMachinePunchJob and answers straight away. The first punch of the day records the arrival time, and a later one updates the departure.

My simple test

I ask two questions. Does the person need this result before the page can respond? And can this fail for reasons that have nothing to do with them? If the answers are no and yes, it goes in a queue. Sending email and SMS are the obvious cases. A saved order is not, because the customer needs to know it worked. The system has eight job classes right now, and each one exists because that step used to be slow, unreliable, or both.

Scheduled work is queued work too

Some jobs are not triggered by anyone. Carrying forward unpaid dues, moving staff leave into a new period and running database backups all happen on a schedule at quiet hours. Pushing them onto the queue means a long task will not hold up everything else, and a failure gets recorded rather than disappearing into a cron log nobody reads.

Jobs run twice, so plan for it

A worker can crash halfway, and a retried job starts from the top. If running a job twice would charge someone twice or send two messages, that is a bug waiting for a bad day. So jobs need to check what has already happened before acting. It also pays to think about what a failure looks like. A failed SMS can retry a few times and stop. A failed backup should tell a person, because the day you need that backup is not the day to find out.

Database queue or Redis?

This project runs on Laravel’s database queue, and I am happy with that. It needs nothing extra on the server, which matters for a school hosting on modest infrastructure, and jobs are easy to inspect with plain SQL. I would switch to Redis when volume makes the database the bottleneck, and a multi-school SaaS may well get there. Choosing the simple tool first is not laziness. It just means I only pay for complexity once I actually need it.

Md. Fawjul Azim

Focusing on building high-performance web applications with modern tech stacks.