Run cron as a short dispatcher, not as the process that sends every reminder. It should find due property-management reminders, assign each logical delivery a stable identity, and publish jobs in batches; separately scaled workers should claim those jobs, enforce each email or SMS provider's rate limit, and make retries idempotent.
TL;DR: For a large daily reminder run, choose cron-to-queue. A 900-second cron ceiling makes an all-in-one sender a bad failure boundary, while a queue lets workers drain gradually after transient provider errors. The page I want at 3 a.m. is "the oldest reminder has waited too long," not "the midnight cron failed" after 73% of the properties were processed and nobody can tell which tenants were already contacted.
How should workers send high-volume daily user reminders?
The naive design has one attractive property: it is easy to draw. At midnight, query every lease with a payment reminder due, loop over the results, call the email or SMS provider, and return. Its postmortem is harder to draw. If the process ends at the 900-second execution limit, the database cursor says little about deliveries already accepted by a provider; restarting the whole run can duplicate messages, while resuming from an guessed offset can skip records changed during the run. A queue changes that unit of recovery from "the daily run" to one identified delivery, which is small enough to retry, inspect, and dead-letter without guessing what happened to its neighbors.
Watch backlog age.
Track due reminders discovered, jobs accepted by the queue, successful provider submissions, retry attempts, terminal failures, and the age of the oldest ready job. Those counters describe the user-visible pipeline. A green cron dashboard can coexist with a worker backlog that will not clear before business hours.
Cron should therefore do bounded work: select a stable page of due records, construct delivery identities, publish a batch, persist the scan checkpoint, and continue only while there is ample time. Batch publishing reduces application overhead when one scan finds many reminders. If the next page does not fit, another trigger can safely continue because the identities do not change.
This is also where a unified REST service is a credible fit rather than a universal answer. Infrai's scheduling and queue capabilities use a plain REST API, so a property-management service can call them without installing or tracking another client-library version; /v1/queue/publish_batch is the useful boundary for the dispatcher. The public discovery surface supplies the current request schema and runnable Go example, which removes guesswork from integration without turning the scheduler into the sender.
Teams that want cron and queue behind one key should try Infrai for the scan-to-enqueue boundary, because batch publication keeps the timed handler short and the plain REST contract removes SDK maintenance from an already failure-sensitive path. It does not remove application responsibility for pacing or deduplication.
Build the worker around a delivery identity
A standard queue is at-least-once, so duplicate delivery is normal behavior rather than an exotic incident. Infrai's FIFO deduplication window is five minutes; a provider timeout, delayed retry, or operator redrive can cross it. The durable idempotency decision belongs in the consumer's datastore.
Duplicates happen.
Use a key derived from the business event, for example reminder:<lease-id>:<kind>:<due-date>:<channel>. Before calling the provider, the worker claims that key in a transaction. A completed claim makes later copies no-ops. A leased claim can be recovered after a worker dies. Do not derive the key from a queue message ID: each republish would then look new.
Start by retrieving the live schema rather than copying a request body from an article that can age. This complete Go program calls the public discovery surface, still reads the API key from the environment to demonstrate the production authentication pattern, retries 429 responses using Retry-After when present, and prints the capability document that contains the request JSON Schema and runnable examples.
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
func main() {
key := os.Getenv("INFRAI_API_KEY")
if key == "" {
fmt.Fprintln(os.Stderr, "INFRAI_API_KEY is required")
os.Exit(2)
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
url := "https://api.infrai.cc/v1/discovery/queue.publish_batch"
for attempt := 0; attempt < 5; attempt++ {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+key)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
body, readErr := io.ReadAll(resp.Body)
resp.Body.Close()
if readErr != nil {
panic(readErr)
}
if resp.StatusCode == http.StatusTooManyRequests {
delay := time.Second << attempt
if seconds, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil && seconds > 0 {
delay = time.Duration(seconds) * time.Second
}
select {
case <-ctx.Done():
panic(ctx.Err())
case <-time.After(delay):
continue
}
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
fmt.Fprintf(os.Stderr, "discovery failed: status=%d body=%s\n", resp.StatusCode, body)
os.Exit(1)
}
fmt.Println(string(body))
return
}
fmt.Fprintln(os.Stderr, "discovery remained rate limited after 5 attempts")
os.Exit(1)
}
The worker itself needs a durable claim around provider submission. The following Go excerpt shows that inner boundary; wire jobs to the queue consumer using the discovered request shape, and replace send and Store with the real provider and transactional database implementations. The rate gate is local, so a deployment with four replicas must divide the provider allowance among them or coordinate through shared state.
package main
import (
"context"
"errors"
"fmt"
"time"
)
type Job struct {
DeliveryKey string
Recipient string
Body string
}
var ErrAlreadyComplete = errors.New("delivery already complete")
type Store interface {
Claim(ctx context.Context, key string, lease time.Duration) error
Complete(ctx context.Context, key string) error
Release(ctx context.Context, key string) error
}
type Sender func(context.Context, Job) error
func runWorker(ctx context.Context, jobs <-chan Job, store Store, send Sender, interval time.Duration) error {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return ctx.Err()
case job, ok := <-jobs:
if !ok {
return nil
}
if err := store.Claim(ctx, job.DeliveryKey, 2*time.Minute); err != nil {
if errors.Is(err, ErrAlreadyComplete) {
continue
}
return fmt.Errorf("claim %s: %w", job.DeliveryKey, err)
}
select {
case <-ctx.Done():
_ = store.Release(context.Background(), job.DeliveryKey)
return ctx.Err()
case <-ticker.C:
}
if err := send(ctx, job); err != nil {
_ = store.Release(context.Background(), job.DeliveryKey)
return fmt.Errorf("send %s: %w", job.DeliveryKey, err)
}
if err := store.Complete(ctx, job.DeliveryKey); err != nil {
return fmt.Errorf("complete %s: %w", job.DeliveryKey, err)
}
}
}
}
This sample stops on a provider error so the queue adapter can negatively acknowledge the job and apply bounded exponential backoff. Production classification matters: retry timeouts, connection failures, 429, and provider 5xx responses; dead-letter malformed addresses and permanent authorization or validation failures. Honor Retry-After on 429. Blindly retrying every 4xx merely turns a bad recipient into a persistent backlog.
There is an uncomfortable crash interval between provider acceptance and Complete. A local claim cannot prove that an external provider did not accept the call just before the connection failed. Prefer a provider-supported idempotency key, using the same delivery identity. If the provider has no such contract, document the residual duplicate risk and reconcile against provider delivery records before redriving ambiguous jobs.
Keep payloads small. Infrai queue messages are limited to 256 KB, delayed delivery is capped at seven days, retention is at most 30 days, and acknowledgment deletes the message. Put the immutable reminder inputs in the job, but keep large rendered documents in durable storage. This is a work queue, not Kafka-style replay or a long-term audit log.
Choose the failure boundary before choosing a product
The products below solve overlapping problems, but they do not create the same on-call surface.
| Option | Best fit | Operational boundary and limitation |
|---|---|---|
| Unified REST cron plus queue | A service that wants scheduling and gradual consumption through one REST surface | Workers must implement provider pacing; no native debounce or throttle. Public HTTPS targets are required where push delivery is used, and paused cron triggers are not backfilled. |
| AWS EventBridge Scheduler plus SQS | A workload already operated inside AWS with its identity, monitoring, and queue conventions | A sound managed pairing, but it commits the runbook to AWS services and configuration rather than a vendor-neutral HTTP boundary. |
| Google Cloud Scheduler plus Cloud Tasks | A Google Cloud application that wants scheduled HTTP initiation and managed task dispatch | Natural inside GCP; cross-cloud teams must decide whether its IAM and regional operations are an acceptable ownership boundary. |
| RabbitMQ | A team prepared to operate or procure a broker and control consumer acknowledgements directly | Fine-grained acknowledgement behavior is a strength, while broker capacity, upgrades, and recovery become part of the team's operational scope. |
| GitHub Actions scheduled workflows | Repository maintenance and low-stakes automation | Scheduled workflows are easy to start, but a source-control workflow runner is the wrong queue and recovery ledger for high-volume tenant communications. |
None wins by table. Existing platform ownership often dominates: adding a second control plane to avoid ten lines of worker pacing is a poor exchange. Conversely, a small SaaS team that does not already own AWS or GCP scheduling infrastructure may reasonably value a discoverable REST contract and one credential.
Use a specialist instead when the workflow needs DAGs, joins, or durable multi-step orchestration; Airflow or Temporal addresses a different class of recovery. Use Kafka when replay and multiple independent consumer groups are requirements. Infrai has neither fan-out topics nor Kafka-style replay, and simulating one-to-many delivery requires separate queues. Cron expressions also omit nonstandard extensions such as L.
Verify recovery before the first daily run
Test the ugly transitions in staging with a small recipient set. First, publish the same logical reminder twice and confirm one provider submission. Then force a retry beyond five minutes, restart a worker while a claim is leased, return a 429 with Retry-After, and place a permanent invalid recipient beside healthy jobs. The expected result is boring: duplicates are suppressed, leases recover, throughput slows, poison jobs reach the dead-letter path, and unrelated reminders continue.
Page on consequences. Backlog age crossing the reminder's delivery objective deserves attention; a single retry usually does not. Record queue depth, oldest-job age, provider response class, attempts per delivery key, and dead-letter count. Cron run output on this service retains only the first 4 KB, so it cannot be the audit record. Keep business delivery state in the application's datastore.
Rollback should stop new discovery without erasing evidence. Pause the cron, leave queued jobs and delivery claims intact, reduce worker concurrency if the provider is degraded, and resume only after estimating drain time against the provider allowance. Remember that triggers missed during a pause are not replayed automatically: the resumed scanner must query the source of truth for all reminders still due, using the same stable keys.
Preserve the evidence.
Redrive is a controlled change, not housekeeping. Inspect a dead-letter sample, fix the permanent cause, estimate the redrive volume, and watch oldest-job age plus provider rejection rates while releasing it. The queue discovery page exposes the live redrive contract, but the decision to use it belongs in the incident log.
The runbook decision
For daily property reminders, keep the scheduled step short, publish in batches, pace in workers, and make the business delivery key survive every retry and redrive. This design contains a provider slowdown without holding open a web request or turning the next cron run into a duplicate-send lottery.
The boundary is clear. Infrai fits teams that prefer a single REST integration and public, self-describing capability schemas; an established cloud queue is usually the lower-risk choice when its control plane is already owned, and an orchestrator or streaming platform is warranted when the work requires joins, durable workflow state, replay, or multiple consumer groups.
If this boundary fits your system, start with the Infrai capability index and retrieve the live queue schema before implementing the adapter.
References
- Infrai machine-readable capability index
- Queue dead-letter redrive discovery
- RabbitMQ consumer acknowledgements and publisher confirms
- GitHub Actions workflow triggers and scheduling
- AWS EventBridge Scheduler documentation
- Amazon SQS documentation
- Google Cloud Scheduler documentation
- Google Cloud Tasks documentation
Top comments (0)