Abhishek
Abhishek•9mo ago

Need help with building a Scheduler app

I need some advice on how can we do this, I am building a social media schedule app where users can select their timezone, date range and at what time to post on social media. For example - If I chose to run the scheduler for 3 days ie (7-10) at the same time 5 pm then for these days on 5pm the post will be published Could anyone give me an overview of how can we build this? Thanks
5 Replies
FleetAdmiralJakob 🗕 🗗 🗙
convert the time on the backend to utc time and then run a scheduled function with utc time. If u want to do it on more than one day you just spin up more scheduled functions but unless you don't want to do it forever that's the way to go this way you also don't have to deal with the time zone the server is running in on the frontend you convert everything back to the time the user has
Abhishek
AbhishekOP•9mo ago
So should run a scheduled function or cron job ? Can someone from the convex team help with this if possible 🤗
erquhart
erquhart•9mo ago
If you're letting the user choose a time down to the minute, you could have a cron job run every minute, query all scheduled posts for that minute and send away.
FleetAdmiralJakob 🗕 🗗 🗙
Oh, maybe I messed this up. Sure, thats a very good solution. But it really comes down to scaling. Your solution scales better but needs way more resources with not so many users. If you have only a few users and run a query every minute it needs more resources than just saving everything in a scheduled function
erquhart
erquhart•9mo ago
Not necessarily, cron will use ~4% of function call monthly quota on the starter plan, and any "wasted" calls that don't result in a published post will be a ~1ms query that returns empty. I guess the ~1ms part is really optimistic and assumes minimal user control of the schedule, to be fair. Could be more involved and require filtering, pagination, etc. But still shouldn't be prohibitive, even on starter plan.

Did you find this page helpful?