Filesystem or Redis Cache Adapter for a Symfony App Approaching Multi-Server Deployment
0 reputation · 02 Feb 2023, 02:56 UTC
0 reputation · 02 Feb 2023, 02:56 UTC
I'm deploying a Symfony application (6.4 LTS) that currently runs on a single server using the default filesystem cache adapter defined in config/packages/cache.yaml. Read traffic is heavy and writes are infrequent, and the app performs well today. However, we're planning to scale horizontally to three nodes behind a load balancer within the next quarter, which raises the question of when the cache backend needs to change.
My understanding is that the filesystem adapter offers zero-dependency simplicity and fast local reads, but entries aren't shared across nodes, so each server maintains its own cache and warming becomes redundant work. The Redis adapter solves sharing and provides atomic operations with built-in TTL handling, but adds an external service to operate, plus network round-trip latency on every cache access.
What I can't find in the documentation is any concrete threshold—requests per second, node count, or write frequency—at which the trade-off clearly favors Redis. The decision seems to rest entirely on ad-hoc profiling.
Should the adapter switch happen before scaling out, or only after measuring actual cache-miss and stampede behavior under multi-node load? Is per-node filesystem caching with independent warmers a legitimate option for read-heavy workloads, or does it create consistency problems I'm underestimating? What metrics best indicate the filesystem adapter has become the bottleneck?
For a read‑heavy, low‑write Symfony 6.4 app that will run on three load‑balanced nodes, you can keep the filesystem cache adapter only if you can tolerate brief inconsistencies and you have an automated warmer that runs on each node after every deployment. If strict cache consistency or avoidance of duplicate warm‑ups and cache‑stampede is required, switch to a shared adapter (Redis) before you add the second node.
The filesystem adapter gives the lowest local‑read latency and needs no external service, but each node maintains its own copy. Under read‑heavy traffic this leads to redundant warm‑up work and, after a cache clear, a simultaneous miss spike on all nodes (a stampede). Redis eliminates duplication by sharing entries and provides atomic TTL handling, at the cost of a small network round‑trip (≈0.5‑1 ms on a LAN) and extra operational overhead.
php bin/console cache:pool:clear cache.app) and monitor the miss rate spike. If the miss rate stays above ~20 % for more than a few seconds, a shared adapter is likely needed.Do you require strict TTL consistency for any cached data (e.g., security tokens, form CSRF, or doctrine metadata), or can you accept brief inconsistencies? If strict consistency is required, the recommendation shifts to moving to Redis before scaling; otherwise, per‑node filesystem caching with warmers remains viable.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.