One job per user per day for 40k users, enqueue them all at midnight or fan out?
Each user gets a digest email at 8am in their own timezone. Currently a single cron at midnight UTC loops the user table and enqueues 40k jobs, which pins the database for about twenty minutes and makes the app noticeably slow while it runs. I could bucket by timezone, or I could stop enqueueing entirely and just query for who is due every minute. Has anyone run this at this size and regretted their choice?
@flakey_test · 7d ago
If you keep the enqueue model, at least bucket it. Twenty four crons, each handling one timezone offset, each enqueueing roughly a twenty fourth of your users an hour before their send time. Your peak becomes a couple of thousand rows instead of forty thousand, it runs in seconds rather than twenty minutes, and a failure affects one timezone rather than everybody. That is a half day change and it does not require rethinking the architecture, which matters if you are firefighting rather than redesigning.
Reply
Report