don't schedule the cron job for each item, set it ...
# help
y
don't schedule the cron job for each item, set it to run in an interval, do whatever it is in concurrent batches or batches or just one after the other, depends on your resources and your expectation of how performant you want it to be. I didn't get what you meant by be@by item, but if you mean that each item has a very specific time when you should process it, then depending on whether or not you can control that time you could make sure that all your items follow a pattern ex: they'd only require processing every 5 mins. If you can't control it at all, try to find the lowest time gap between when the processing should happen and set the interval of the cron job to that period of time aka try to keep it at 1 cron job at best.
j
Thanks @User . The be@by was a typo. Noted. So what you're saying is, query the entire table, and run the job for each item one by one using a Promise all await or something?
y
i wouldn't recommend querying the whole table, unless you've only got some 100 or 200 rows and each row doesn't hold a lot of data. Instead you could fetch say the first 50 rows, process them, then the next 50 etc. depends on your resources and how fast you want it to happen tbh
also let me make it clear I wouldn't recommend running a cron job for every item, just run 1 job in an interval
j
Do cloud functions have memory and remember last fetch? Lol. I'm in over my head. Any chance I could hire you for this 😂
y
Cloud functions are stateless, they kind of "live" until they're hot (being called frequently) and die when they're cold so the memory or processing power allocated for them is free for something else. I'm too busy with work irl, but you could send me a DM as to what you're trying to do and I'll could throw a few pointers your way