Skip to content

Best practice for handling concurrent jobs in a multi-instance Express app #1015

Open
@kbzowski

Description

@kbzowski

I am currently using Nginx Unit to run multiple instances of an Express application. I have several cron jobs that perform database operations (using node-cron). These jobs need to be managed in such a way that they do not run simultaneously to avoid conflicts or data integrity issues. I am looking for the best practices or solutions to ensure that cron jobs are handled by only one process at a time.

Is there a way to designate an instance of the application under nginx unit to handle specific task (can I pass process id or some other value dynamically to identify first/main process)?

The only alternative I can see is to develop some kind of database locking mechanism that only allows one instance to do the task.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions