I have a node js app, in which I need to perform background jobs. My plan is to use a data structure which will contain all the jobs needs done. My design also suggests that this data structure needs to persist between application restarts. To achieve that I can think of two options to store the datastructure:
a) use a database
b) use a file
Solutions like external queues might probably be an overkill for my app(the data structure will contain 5 - 10 entries(jobs) at any time).
Currently, I am inclined towards using a log file, which I think will be faster and plus I do not need to query that info(therefore need for a database).
How do you evaluate this approach? Is using a log file for runtime persistence a good practice? Are there any other benefits/drawbacks to it? Is there an alternative I should consider in my scenario?
batch
jobs were done with single files in a directory. All jobs were done, when the files were moved from one directory to another. In case of errors it was moved to another directory. I would call thatpoor-man's-queue
but it works. So a file approach could be viable under circumstances.log-file
could do the trick: If you know beforehand which jobs have to be done, reading the logfile could give you a clue of what is left to do, But that is - admittedly - not the best of all solutions.