__pgboss__cron taking long to complete and blocking main thread #317
Unanswered
thakkaryash94
asked this question in
Q&A
Replies: 1 comment
-
Thanks! I have not run pg-boss in a mobile application before, so the concept of "main thread" is not something I have a lot of experience in mitigating. However, I think scheduling could be optimized to improve latency since each scheduling interaction is a distinct call to postgres. If the cause is related to very popular schedule times within the same zone, the current usage of pMap() over the matched schedules in timekeeper.js would need to be replaced with a batch insertion technique that is still compatible with upserts to honor the current debouncing configuration used. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@timgit First of all, thank you so much for creating this package. I need your help with the below scenario.
I have a mobile application where I am sending daily notifications to the user's selected preference time. eg. 8:00 AM, 3:15 PM with timezone. So I have created schedules for everyone like below. I am using NestJS.
boss.schedule(
notification-job-${user.id}
,${minute} ${hour} * * *
, obj, { tz: user.currentTimeZone })Currently, there are around 1300 users, meaning 1300 records schedules table. The problem is '__pgboss__cron' is taking around 20 seconds and it is running on main thread so for every minute's first 20-30 seconds, the actual request goes into pending state, after the job is completed, the request takes max 400-500 ms to respond. Below are the logs.
Before deleting the schedules
To check the issue, I deleted all the schedules and now the jobs are completed in ms.
After deleting the schedules
So can you please help me with how can I improve this?
Beta Was this translation helpful? Give feedback.
All reactions