Kubernetes for the Laravel developer who fears YAML
Deployments, services and ingress explained through the mental model of a Laravel app you already understand.
Background jobs are the quiet workhorses of a production app — sending mail, resizing images, calling slow third-party APIs. Do them inline and every request pays the cost; push them onto a queue and your app stays fast.
Why queues, really
A queue is just a list of work to do later. Your web process pushes a job onto it and returns immediately; a separate worker process pulls jobs off and runs them.
- Requests return in milliseconds instead of waiting on slow I/O.
- Spiky workloads get smoothed out — the worker drains at a steady rate.
Your first job
Generate a job class and put the slow work inside handle(). Keep the constructor cheap — everything you pass in gets serialized onto the queue.
Pass an id, not a whole object graph. Eloquent models are serialized by key and re-fetched in the worker.
Key takeaways
- Push slow work to a queue; keep constructors lightweight.
- Always set tries, backoff and timeout.
- Make every job idempotent — assume it will run twice.
Discussion 5
Newest firstThis is the clearest explanation I have read on the topic. We got burned by exactly this last year — bookmarking to share with the team.
Thanks Priya! Glad it was useful — that scenario is exactly why I wrote it up.
Do you have a follow-up planned that goes deeper on the production setup?
Great write-up. One thing I'd add from experience: measure before you optimise — the bottleneck is rarely where you think it is.
Bookmarking this one. Exactly what I needed this week — thank you for sharing.