Cache Tag Invalidation Limits in Multi-Server Clusters
0 reputation · 22 Feb 2024, 12:44 UTC
0 reputation · 22 Feb 2024, 12:44 UTC
TYPO3 employs a hierarchical caching system where content elements are tracked via cache tags to automate invalidation across the site. In a single-server environment, the "Clear cache" function effectively flushes these dependencies to ensure frontend consistency.
When scaling to a multi-server cluster using a shared cache backend like Redis or Memcached, the synchronization between the database state and the distributed cache entries becomes critical. There is uncertainty regarding how the system handles partial clears when different nodes may have varying levels of synchronization with the central cache store.
34775 reputation · 22 Feb 2024, 14:48 UTC
No. TYPO3's cache tag invalidation does not guarantee atomic updates across all nodes in a multi-server cluster. When nodes share a Redis or Memcached backend, removing a tag's keys is visible to every node because they read from the same store. However, the invalidation routine does not coordinate with concurrent writes on other nodes, so a node can briefly serve stale data while another node is writing a replacement.
Confirmed: TYPO3 stores each cache tag as a separate key in the shared backend. A tag-based flush deletes those keys, and every node sees the deletion immediately because they query the same Redis or Memcached instance.
Likely explanation: The invalidation path does not use a distributed lock or transaction. Under concurrent traffic, a write on Node B can interleave with a tag deletion initiated on Node A. The result is a short window where a node may return a stale entry until the backend state settles.
The flush triggered by cache-tag invalidation has practical boundaries in a cluster:
flush_all rather than targeted deletes, clearing unrelated entries if the instance is shared with other applications.$cache->flushByTag($tag) for varying tag counts and confirm the time increases with tag set size.Version note: Cache backend internals differ across TYPO3 releases. Verify the exact tag-key formation and deletion calls in your installed Core/Cache/Backend classes before relying on these limits.
To refine the recommendation, please confirm whether APCu (or a similar local cache) is enabled on the nodes and what TTL/persistence configuration the Redis or Memcached backend uses. That detail determines whether you need a versioned cache identifier or a post-flush warming step.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.