5 ms·
Because you can set up a rudimentary queueing system in MySQL/PostgreSQL very quickly these days. And it scales really well for small to medium sized applicatio
by throwaway38375 2y ago
Because you can set up a rudimentary queueing system in MySQL/PostgreSQL very quickly these days. And it scales really well for small to medium sized applications!
I maintain a web application with a few hundred daily users and with the following table I have never had any problems:
CREATE TABLE `jobs` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`queue` VARCHAR NOT NULL,
`payload` JSON NOT NULL,
`created_at` DATETIME NOT NULL,
PRIMARY KEY `id`,
INDEX `queue`
);
Using MySQL's LOCK and UNLOCK I can ensure the same job doesn't get picked up twice.
All in all, it's a very simple solution. And simple is better!