Stop being the product.
Become the owner.
or
sign uplog in

how can I ensure that only 1 node executes a job in a…

how can I ensure that only 1 node executes a job in a distributed system?

context: I'm working on a project that's expected to handle very high loads, so it was built with distribution (kubernetes) in mind from the ground up, still the backend is completely monolithic, I don't think this is relevant, but if it is, the backend is in python (sanic) and we're using postgres for the database, and redis for caching

problem: we have some cron jobs, things like database clean up and report generation, but we must find a way to lock the jobs only to 1 node at a time, we initially did so with kubernetes cron, but we're trying to find a way to handle everything in the backend itself

I read about distributed locking systems, and came to the conclusion that postgres's advisory locks would be perfect for this scenario, but I thought I should get some other opinions on the matter before implementing it

so what do you guys think? should I stick with advisory locks, or do you have other ideas?

keep in mind that currently all jobs are hardcoded, but we have an update planned for the future that will introduce user-defined jobs, so it's best if the architecture could grow into that

thanks in advance guys
#programming #dev #technology
earnings
2,000 mlx total
$0  total
engagement
3 views
0 reactions

0 comments