Why Go Tickers Drop Ticks When the Receiver Falls Behind
A slow Go ticker receiver can miss ticks without losing a stored job. Separate periodic refreshes, post-completion delays and durable work obligations.
Your Go poller asks for a tick every second, but the number of completed polls falls behind elapsed time. The API still answers. The loop still runs. Where are the missing turns?
First check whether the receiver spends longer working than the ticker's period. A Go ticker may adjust its interval or drop ticks for a slow receiver. It doesn't promise to retain a job for every interval that passes. Keep a ticker for periodic opportunities, use a separate timer when you need a delay after completion, and store explicit jobs when every scheduled unit of work must survive. The NewTicker contract makes the dropped-tick behavior explicit.
This is an AI-prepared, documentation-based explainer, not a personally reproduced incident. Code, scenarios and proposed checks below are illustrative and unexecuted. See the editorial policy.
The receiver disappears into its own work
Consider this illustrative sequential poller. The caller supplies the operation and its context-aware I/O behavior:
func poll(
ctx context.Context,
period time.Duration,
work func(context.Context) error,
) error {
if period <= 0 {
return errors.New("period must be positive")
}
ticker := time.NewTicker(period)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return ctx.Err()
case <-ticker.C:
if err := work(ctx); err != nil {
return err
}
}
}
}The excerpt uses the standard context, errors and time packages. It waits before the first poll and returns on the first work error; those are deliberate example policies, not universal retry advice.
While work runs, this goroutine isn't receiving from ticker.C. If work takes longer than the period, the receiver falls behind. The next receive doesn't come with a ledger of everything the application thinks should have happened during that absence.
Imagine a one-second period and an operation that takes several seconds. That is an illustrative workload assumption, not a benchmark. The documented contract permits losing tick notifications. It doesn't specify an exact printed sequence, a fixed number of missed ticks or a universal catch-up burst. Don't turn a timing trace from one machine into the application contract.
Count receipts separately from obligations
A plausible first suspicion is that the remote API is skipping requests. Before investigating that, count starts and completions around the actual call. If the call starts only after the loop receives a tick, there may never have been a request for each elapsed interval in the first place.
Keep these measurements separate:
| Observation | What it can establish | What it doesn't establish |
|---|---|---|
| Elapsed time | How long the process or operation has been running | How many tick notifications were retained |
| Ticks received | How often this receiver got a notification | Every interval that passed while it was busy |
| Work starts and completions | Attempts and completed operations under your error policy | A durable backlog or successful external side effect |
| Persisted due jobs | The work your application recorded as owed | That every recorded job has completed exactly once |
This is the diagnostic distinction that matters: missing notifications and missing stored jobs are different failures. A ticker can't lose an application job that you never created. It can, however, expose a design that quietly treated a clock signal as a job queue.
Measure handler duration, cancellation and actual work outcomes alongside the configured period. Use time.Since for elapsed-time observations rather than multiplying a tick count by the period. No sample timings or measurements are claimed here.
Choose which kind of waiting you actually need
For a best-effort refresh, dropped opportunities may be fine. If you're fetching the latest status, five stale refresh attempts after a slow response may have little value. Document that coalescing or skipping is acceptable, and monitor how long the refresh is taking.
If the requirement is “wait a full period after the previous request finishes,” model that delay directly. A small illustrative helper uses a fresh one-shot timer:
func wait(ctx context.Context, delay time.Duration) error {
timer := time.NewTimer(delay)
defer timer.Stop()
select {
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
return nil
}
}Inside a polling function with a validated positive period, the loop can then be:
for {
if err := wait(ctx, period); err != nil {
return err
}
if err := work(ctx); err != nil {
return err
}
}This policy waits before the first attempt and again after each completed attempt. Its start-to-start spacing includes the work duration plus the wait. The NewTimer contract describes a notification after at least the requested duration; scheduler delays can add more. This is a minimum gap design, not an exact wall-clock appointment.
For billing periods, scheduled exports or any work that must catch up, represent the obligation explicitly. Store a job or a checkpoint identifying the last completed interval, derive what is due, and define a bounded recovery policy. Decide how retries, duplicates, partial failures and expired work behave. A durable queue still needs idempotency; a clock doesn't provide it on your behalf.
More goroutines can move the bottleneck
Launching a goroutine for every received tick may let the receiving loop return sooner. It doesn't create notifications that were already dropped, guarantee capacity or bound in-flight work. If requests slow down, concurrency can grow while the dependency is least able to handle it.
Choose a concurrency limit and an explicit overload policy: skip, coalesce, reject or queue work within a defined bound. If jobs must survive process failure, an in-memory channel alone doesn't satisfy that requirement. A system with a tidy tick count and an untidy number of live requests has merely changed which dashboard looks alarming.
Don't diagnose today's behavior solely from an old explanation of ticker channel capacity. Go's Go 1.23 timer changes altered channel and garbage-collection behavior, with compatibility conditions documented there. The stable point for this diagnosis is the current slow-receiver contract, not an assumed internal buffer size.
Stopping the ticker isn't stopping the operation
Ticker.Stop stops further ticks without closing the channel. A loop that ranges over ticker.C shouldn't expect Stop to make that range finish. Give the receiver a separate shutdown path, as the context select does above.
That select runs only when control is back in the loop. It can't interrupt work that ignores its context or blocks indefinitely. The context package provides cancellation signals; the operation has to observe them through its own I/O and cleanup. Don't claim that stopping a notification source canceled an already-started request.
Make a slow receiver part of the design review
For proposed regression checks, hold work open longer than the period and verify the policy you chose. A sequential poller should not silently turn into overlapping requests. A minimum-gap poller should schedule its next wait after work completes. Durable work should recover recorded obligations after restart without inventing exactly-once guarantees.
Avoid a brittle test that expects an exact number of ticker deliveries under real scheduling. Assert the business behavior, cancellation and concurrency bounds instead. These are suggested checks, not tests executed for this article.
This is a different timer boundary from recreating time.After inside a select loop. That problem renews a timeout; this one confuses notifications with work owed. More related posts are in the backend archive.
Before adding a ticker to the next worker, write down what should happen when one operation takes longer than the period. Put that decision beside the loop. “The channel will probably remember” isn't a backlog policy.