Incidents
Post-mortem: elevated purge latency on 28 October
For 26 minutes, purges in Europe took up to 40 seconds to reach every location. Cached content was served normally throughout. What happened, and the three changes we made.
On 28 October between 14:02 and 14:28 UTC, purge requests for sites served in Europe took up to 40 seconds to reach every location instead of the usual 150 milliseconds. Cached content continued to be served normally, and no requests failed; but for 26 minutes, an update that a customer expected to be live almost instantly could take most of a minute. Several news publishers noticed, and they were right to write to us.
How purges travel
A purge request is validated by the API and written to a replicated log, partitioned by region. In each location, a consumer reads the partitions that apply to it, applies the invalidation to the local cache index, and writes an acknowledgement back. The API waits for acknowledgements from every location before reporting a purge as complete. The design gives us ordering and durability, so a location that restarts replays any purge it missed. It also means a consumer that stops advancing holds back every purge behind it in its partition.
What happened
At 14:02 a customer sent a tag purge containing a tag with the Unicode line separator character U+2028, copied from a CMS field. The API's tag validation checked length and rejected control characters in the ASCII range, but U+2028 passed. The message was written to the log.
One of the three consumer groups serving European locations used an older decoder that treated U+2028 as a record separator. It failed to parse the message, and its handler retried in a loop with backoff, forever. Every subsequent purge for the 14 locations served by that consumer group queued behind the bad message. Purges for other regions were unaffected, so the global propagation graph only showed a modest rise; our regional p95 alert fired four minutes in.
| Time (UTC) | Event |
|---|---|
| 14:02 | Purge request with a tag containing U+2028 (line separator) accepted by the API. |
| 14:02 | Consumer group purge-eu-2 fails to decode the message and starts retrying. |
| 14:06 | Alert: purge propagation p95 above 5 s for Europe. |
| 14:09 | Incident declared; status page updated. |
| 14:17 | Stuck consumer identified from its unchanged log offset. |
| 14:21 | Message moved aside by hand; consumer restarted. |
| 14:24 | Backlog of 41,000 purges drained. |
| 14:28 | Propagation back to normal (p95 190 ms). Incident resolved. |
Why it took 15 minutes to fix
The consumer was healthy by every signal we monitored: the process was running, memory was flat, it answered health checks and it was connected to the log. What it was not doing was advancing its offset. The on-call engineer found it by comparing offsets across consumer groups, which is a manual step we had not needed in two years. Moving the message aside required a tool that is deliberately hard to use, because skipping a purge is the one thing a CDN must never do silently. That took another few minutes, during which we re-applied the skipped purge by hand.
What we changed
We have made three changes, all of which are now live in every region.
- Dead-letter after three attempts. A message that cannot be decoded three times in a row is written to a dead-letter queue, which pages the on-call engineer immediately and keeps the consumer moving. The purge is re-applied as a prefix purge for the affected site as a safety net.
- Progress watchdog. Every consumer now reports its last applied offset, and a watchdog restarts any consumer that has pending messages but has not advanced in ten seconds. A second alert fires on offset lag per consumer group, not just on the global propagation time.
- Validation at the edge of the system. Tags are now normalised and validated at the API against the documented character set (
A-Z a-z 0-9 - _ . :) before anything is written to the log. Invalid tags are rejected with a400and an error that names the offending character.
-func (c *Consumer) handle(msg *log.Message) error {
- for {
- p, err := decodePurge(msg.Value)
- if err == nil {
- return c.apply(p)
- }
- time.Sleep(backoff.Next())
- }
-}
+func (c *Consumer) handle(msg *log.Message) error {
+ p, err := decodePurge(msg.Value)
+ if err != nil {
+ if msg.Attempts >= 3 {
+ return c.deadLetter.Put(msg, err) // alert fires on any DLQ write
+ }
+ return log.ErrRetry
+ }
+ return c.apply(p)
+}We also replaced the old decoder in the remaining consumer group, which was the root cause, and added a fuzz test with the full Unicode range to the decoder's test suite.
Our commitment
Purge speed is something we advertise, and for 26 minutes we did not deliver it. We are sorry to the customers whose updates were delayed. Affected Business and Enterprise customers have received service credits automatically. The original incident timeline remains available on our status site, and if you have questions about this post, write to us at support@cache.bz.