h8h
h8h4w ago

Where is the source code of the worker that handles scheduled functions?

Hi team, I want to understand how does Convex handle scheduled functions "internally". I guess it's a worker pool that pick jobs from a queue then execute them. But I want to understand it deeply Thanks
8 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
jamwt
jamwt4w ago
that's the self-hosted impl of the multi-threaded runner
jamwt
jamwt4w ago
GitHub
convex-backend/crates/isolate/src/client.rs at main · get-convex/c...
The open-source reactive database for app developers - get-convex/convex-backend
jamwt
jamwt4w ago
basically, if the mutation commits, then the deployment has a system table called _scheduled_jobs which gets a new entry added to it: https://github.com/get-convex/convex-backend/blob/db57318ffa4779d2be212fd89a1c9e737b0fc5a3/npm-packages/system-udfs/convex/schema.ts#L313
jamwt
jamwt4w ago
then this part of the application runtime monitors the scheduled jobs table to find eligible jobs to run: https://github.com/get-convex/convex-backend/blob/db57318ffa4779d2be212fd89a1c9e737b0fc5a3/crates/application/src/scheduled_jobs/mod.rs
GitHub
convex-backend/crates/application/src/scheduled_jobs/mod.rs at db57...
The open-source reactive database for app developers - get-convex/convex-backend
jamwt
jamwt4w ago
GitHub
convex-backend/crates/application/src/scheduled_jobs/mod.rs at db57...
The open-source reactive database for app developers - get-convex/convex-backend
jamwt
jamwt4w ago
so there's some quick pointers! the runner in the cloud product is actually a distributed service, not an in-process thread pool. that's the difference with the cloud product hth

Did you find this page helpful?