Short answer: keep each customer's timezone and intended local business deadline as data, calculate the next eligible instant, and let one UTC scheduler claim due email work through an idempotent delivery path. A cron expression should wake the system; it should not define what "daily" means for every user.
For a fintech renewal flow, that distinction is operationally important. The reminder may need to wait until an account's local business deadline, while the service itself runs in UTC and serves customers in Europe and the US. I've been paged by missed jobs and duplicate deliveries. The invariant I carry from those incidents is blunt: a scheduler can run twice or late, so correctness has to survive both.
No clever cron fixes that.
How should SaaS handle daily report email timezone delivery across Europe and the US?
Model the user's request as a calendar rule, not as a precomputed timestamp that lives forever. At minimum, store the account identifier, an IANA-style timezone identifier supplied by the account configuration, the local target time, the relevant local date, and a stable rule version. For the concrete renewal case, the record says, in effect, "release this reminder after the business deadline on the account's renewal date." It does not say, "send at whatever local clock reading happens to correspond to the UTC offset we observed when the account was created."
The scheduler then has two jobs. First, it resolves that local intent into an eligible UTC instant using the timezone database available to the application. Second, it claims records whose eligible instant is at or before the scheduler's current UTC time. Email construction and delivery happen after that claim, through a queue or an equivalent durable handoff.
This design makes the policy reviewable. Product and compliance teams can inspect the local rule. Operators can inspect the calculated instant. If a timezone rule or customer preference changes before release, the application can recalculate pending work and increment the rule version. Already delivered work stays an immutable fact rather than being silently reinterpreted.
Do not run one cron entry per user. That approach spreads business state into scheduler configuration, makes account updates into control-plane mutations, and still leaves duplicate execution unresolved. A single periodic UTC tick is easier to observe, but the tick interval is not the delivery guarantee. It only bounds how soon an eligible record can be noticed under normal operation.
There is an uncomfortable edge at any local clock transition where a requested wall-clock time may be ambiguous or unavailable. The policy must be explicit: choose the earlier valid instant, the later valid instant, or the next valid local time, and store which resolution was applied. I'm not sure there is one universally correct choice; the renewal contract and legal interpretation decide it. What matters to the runbook is that the choice is deterministic, versioned, and tested rather than inherited accidentally from a date library's default.
The guarantee lives in state, not cron
"Exactly once" is not a useful promise for an email side effect unless every boundary participates in one atomic transaction, which an external delivery system generally does not. Aim for at-least-once execution with an idempotent business operation. The state machine can be small: pending, claimed, and delivered, plus a claim expiry for recovery. Keep the delivery identity stable across retries.
For a daily report, a natural identity is account plus local report date plus report type. For the renewal reminder, include the renewal identifier, business-deadline date, channel, and rule version. Canonicalize those fields before hashing. RFC 2104 defines HMAC as keyed hashing for message authentication; an HMAC-derived key is useful when the raw composite identity should not be exposed in logs or downstream request metadata. The key is not a substitute for a unique database constraint. Use both: the constraint arbitrates concurrent producers, while the HMAC gives retries a stable opaque identity.
The failure sequence is worth spelling out because it catches optimistic designs. A worker claims a reminder, sends the message, and loses its process before recording delivered. Another worker later reclaims it. Without a stable delivery key, the account receives two reminders. If the process records delivered before the send, the inverse failure loses the reminder. A transactional outbox narrows the ambiguous boundary: commit the business decision and an outbox row together, then let a dispatcher retry the external side effect with the same key. You still need reconciliation because the final receipt crosses a system boundary. I've seen the operational trap on both sides of this choice: a team checks the scheduler log, finds a successful tick, and closes the investigation even though that log proves neither durable ownership nor external acceptance. Start instead from the missing business identity, trace its claim and outbox record, and compare the downstream receipt under the same idempotency key. If any link is absent, recovery resumes from the last durable transition rather than inventing a new send.
Measure the obligation.
| Evidence | What it proves | What it does not prove |
|---|---|---|
| UTC scheduler heartbeat | The scan loop was alive | Every due reminder was claimed |
| Unique outbox row | One business identity entered dispatch | The email provider accepted it |
| Stable delivery receipt | The external boundary accepted that identity | The recipient read the message |
| Reconciliation result | Expected and observed identities agree | Future ticks will remain healthy |
Keep queue priority out of the correctness rule. RabbitMQ's priority queue documentation explains that priority is configured on queues and that consumers can affect how priority behaves, including through prefetch. That makes priority an ordering aid, not proof that a renewal deadline was honored. A better separation is to encode eligible_at and deadline policy in durable application state, then use queue priority only to improve service order among work that is already eligible. Otherwise, a stream of urgent work can starve ordinary daily reports, and an apparently high-priority message can still be late if no consumer capacity exists.
The runbook question is therefore not "did cron fire?" It is "which eligible business identities have no durable delivery receipt?" That query survives scheduler restarts, queue redelivery, and worker replacement.
A preventative Go path for claiming renewal reminders
The following Go sketch keeps vendor details outside the scheduling decision. The repository transaction owns claims and the outbox write. A separate dispatcher reads the outbox and sends email with the stored idempotency key. All timestamps crossing this interface are UTC; local calendar resolution happens before insertion or rescheduling.
package reminders
import (
"context"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"time"
)
type Candidate struct {
ReminderID string
AccountID string
LocalDate string
Timezone string
RuleVersion int
EligibleAt time.Time
}
type Repository interface {
// ClaimDue uses a database transaction and skips rows claimed by another worker.
ClaimDue(ctx context.Context, now time.Time, leaseUntil time.Time, limit int) ([]Candidate, error)
// PutOutbox inserts once under a unique delivery key in the same transaction as the claim.
PutOutbox(ctx context.Context, candidate Candidate, deliveryKey string) error
}
type Claimer struct {
Repo Repository
KeySecret []byte
Lease time.Duration
}
func (c Claimer) Run(ctx context.Context, now time.Time, limit int) error {
if now.Location() != time.UTC {
return errors.New("scheduler time must be UTC")
}
if limit < 1 || c.Lease <= 0 {
return errors.New("invalid claim settings")
}
items, err := c.Repo.ClaimDue(ctx, now, now.Add(c.Lease), limit)
if err != nil {
return fmt.Errorf("claim due reminders: %w", err)
}
for _, item := range items {
key := deliveryKey(c.KeySecret, item)
if err := c.Repo.PutOutbox(ctx, item, key); err != nil {
return fmt.Errorf("write reminder outbox: %w", err)
}
}
return nil
}
func deliveryKey(secret []byte, item Candidate) string {
canonical := fmt.Sprintf(
"renewal-reminder|%s|%s|%s|%s|%d",
item.ReminderID,
item.AccountID,
item.LocalDate,
item.Timezone,
item.RuleVersion,
)
mac := hmac.New(sha256.New, secret)
_, _ = mac.Write([]byte(canonical))
return hex.EncodeToString(mac.Sum(nil))
}
The code intentionally doesn't call an email API. The dispatch boundary needs its own retry classification: authentication and malformed-message failures should stop and alert; transient transport failures should retain the same key and retry under a capped backoff; an accepted message should produce a durable receipt. Never create a fresh business identity merely because an attempt number changed.
Deployment needs a shadow phase. Calculate eligible_at for pending reminders and compare it with the existing decision without sending from the new path. Then enable claims for a bounded account cohort, watch age and duplicate indicators, and expand gradually. A rollback should stop new claims while leaving outbox rows available to the established dispatcher. Deleting ambiguous rows during rollback hides obligations.
Tests should cover properties rather than a handful of memorable city names. Given the same stored rule version and timezone data, resolution must be deterministic. Two concurrent claimers must yield one outbox identity. Reclaim after lease expiry must preserve that identity. A delayed scheduler tick must select every still-pending item with eligible_at <= now, not just items inside the latest tick interval. Finally, changing an account timezone must follow a declared cutoff policy so an imminent reminder is neither silently advanced nor postponed.
Observability should mirror those properties. Track scheduler heartbeat, oldest eligible unclaimed age, claim latency, lease expirations, outbox backlog age, attempts per delivery identity, accepted-but-unreconciled receipts, and duplicate suppressions. Break these down by timezone region and rule version, but keep account identifiers out of low-trust telemetry. Page on the age of an unmet obligation, not on a single missed heartbeat. The first is customer impact; the second may be noise.
When should a team choose a different scheduling model?
The catch is that periodic database claiming adds state, indexes, leases, and reconciliation work. It is not suitable when a reminder must execute with near-zero timing tolerance or when eligibility depends on a continuously changing market event; use a purpose-built real-time control path with an explicit deadline budget in those cases. For a tiny internal report where duplicates have no consequence and a person can rerun the job, stick with one simple UTC cron and document the manual recovery step.
Per-account timers can also be reasonable when the runtime durably persists timers, exposes their histories, and gives the team a tested replay model. Even then, keep the local business rule outside the timer identifier so timezone or policy changes can be audited. The decision isn't cron versus queue as brand categories. Ask whether the chosen system can answer four questions after an incident: what should have been eligible, who claimed it, which stable identity crossed the side-effect boundary, and how the team reconciled the receipt.
Capacity matters too. A UTC scan can create a sharp wave at common local reporting times. Partition claims, cap batches, and apply backpressure before the email boundary, but don't solve overload by moving eligible_at later without recording a policy violation. Queue priority may protect deadline-sensitive renewal reminders from bulk reports, yet it must be paired with reserved consumer capacity or fair scheduling so lower-priority work still progresses. Your mileage may vary with traffic shape; a load test using the distribution of account-local deadlines resolves that uncertainty better than an average-throughput estimate.
The final acceptance rule is compact: the local calendar policy decides eligibility; UTC provides a common comparison axis; durable state proves ownership; a stable idempotency key makes retries safe; and reconciliation closes the external side effect. Cron — useful but deliberately boring — only starts the loop.
Top comments (0)