High CPU & Memory Usage on Low-Spec AWS Instance When Running Laravel Queue & Cron with DB Driver
Hi everyone,
I’m running a Laravel project on an AWS EC2 instance with the following specs:
1 GB RAM
1 vCPU Core
Ubuntu OS
Both Laravel app and MySQL database are hosted on the same server.
My Laravel app uses the database driver for both queue and cache. I’ve configured everything and it works fine under low usage. However, once I start the cron job (which triggers queue workers and scheduled tasks), the MySQL server usage spikes drastically—both CPU and memory consumption increase quickly, eventually causing the server to slow down or crash.
I’m assuming the combination of Laravel queues and scheduled jobs hitting the DB, while MySQL is already running on a low-resource machine, is causing the issue.
Questions:
Is it a bad practice to use the database for both queue and cache on such a low-spec server?
Would using something like Redis help reduce the load on MySQL and improve performance?
What are the best practices for deploying Laravel with queue & cron on a low-resource instance?
Should I move the database to a separate instance, or is optimizing MySQL and Laravel enough?
Any lightweight configuration tweaks you’d recommend to keep things running more efficiently on a 1GB RAM, 1-core server?
Please or to participate in this conversation.