Loki caching with Memcached: what it speeds up and when you need it
A team running Loki usually notices the problem first in query latency. A dashboard that returned in seconds last quarter now takes much longer, and the object storage bill and read volume climb as more history is scanned for the same questions. Caching is the lever that reduces repeated work against object storage, and Loki separates it into three places: query results, chunks (the compressed log data) and index lookups. Each has its own cache, so you can size and tune them independently instead of treating caching as one switch.
In the Loki Helm chart, Memcached is included and enabled by default for the chunksCache and resultsCache settings. The index lookup cache is configured separately, so confirm in your chart version whether it is deployed and wired up before you assume it is covered. Memcached is the option the Loki caching documentation recommends for production deployments with multiple replicas, because the replicas can share one cache tier rather than each keeping its own copy. Before go-live, check which caches your values file enables, how much memory each pod is given, and whether query results are being served from cache by looking at cache hit metrics in your monitoring stack.
Caching does not fix a slow cluster caused by oversized queries, poor labels or undersized queriers, and it adds memory and pods that must be sized and monitored. Ask your implementation partner or platform team to confirm the memory reserved for each cache, the eviction behavior under your query mix and the expected effect on object storage requests before and after enabling it. Plan a load test that repeats the same dashboards over a long time range, so you can see whether the cache changes latency at your data volume rather than assuming it does.
Memcached, Redis or embedded: how each cache backend fits
Memcached is the backend the Loki documentation recommends for production deployments with multiple replicas, and it is the one the Loki Helm chart includes and enables by default for the chunks cache and the results cache. Because several Loki components can read from the same cache, a shared Memcached tier lets every querier and frontend benefit from data another replica already fetched.
- Helm chart default: The chart deploys Memcached for
chunksCacheandresultsCacheout of the box, so the first production install needs no extra cache service. - Shared across replicas: Every replica points at the same cache endpoints, so hit rates improve as the cluster grows.
- Sizing is per cache: Memory allocation for each cache is set separately, so review the chart values for each one before go-live.
- No persistence assumed: Treat cached data as disposable. A cache restart costs performance, not correctness.
- Operational ownership: Your platform team monitors the Memcached pods, their memory and their eviction rate.
Before relying on Memcached, confirm the memory sizing in your chart values against your query pattern, and check the Loki caching documentation for the current defaults in your chart version.
Redis is a supported alternative for each Loki cache, but it brings licensing and high availability questions that Memcached does not. Choosing it is usually a decision driven by a standard you already run, not by a performance argument alone, so settle the license and the failover design before you write the values file.
- Licensing by version: Redis 7.2 and earlier are under BSD-3-Clause. Redis 7.4.x through 7.8.x are under RSALv2 or SSPLv1, which are not OSI-approved. Redis 8.0 and later can be used under RSALv2, SSPLv1 or AGPLv3 at your choice, according to the Redis licenses page. Have legal review the version you pin, and read the Redis licenses page before deciding.
- Sentinel for high availability: Redis Sentinel provides automatic failover by promoting a replica to master when Redis is not run in Redis Cluster. The Sentinel documentation says a robust deployment needs at least three Sentinel instances.
- Extra infrastructure: Three Sentinels plus primary and replica nodes add pods or servers to operate for each Redis-backed cache.
- Support model: Redis Software and Redis Cloud are commercial products from Redis Ltd. If you need vendor support, confirm the terms with the vendor.
- Platform limits: Redis Open Source runs on Linux and BSD systems, and on Windows only through Docker.
Before choosing Redis, confirm the exact version and license with your legal team, and check the Sentinel topology you can operate in your environment.
The embedded option runs the cache inside the Loki process rather than in a separate service. It removes a dependency and an operational component, which suits small installs and single-replica setups, but its cache is local to one process, so other replicas cannot reuse what it holds.
- No extra service: There is nothing to deploy, patch or monitor beyond Loki itself.
- Local to one process: Each replica builds its own cache, so a multi-replica cluster gets little shared benefit.
- Lost on restart: A restart empties the cache, which is acceptable for a lab or a small single-node install.
- Good fit for small volumes: When query load is light, the cost of a separate cache tier may not be justified.
- Clear upgrade path: Moving to Memcached later means changing the cache configuration and reviewing memory limits, so plan that change with the rest of your scaling work.
Before choosing embedded caching, confirm the replica count you expect, and check the Loki caching documentation for how the embedded cache is configured in your version.
Each Loki cache takes exactly one backend. The chunks cache, the results cache and the index-related caches are configured separately, and each one can use Memcached, Redis or the embedded cache. Mixing backends inside a single cache is not a supported pattern, and the Loki documentation says that configuring both Memcached and Redis for the same cache makes Loki fail to start.
- One choice per cache: Select a backend for each cache on its own, and do not set two backend blocks for the same cache.
- Startup failure is the safe outcome: Loki refuses to start rather than running with an ambiguous configuration, so the error appears during rollout, not in production traffic.
- Mixed designs are allowed across caches: You can use Memcached for the results cache and Redis for another cache, if your operating model needs that.
- Review values files carefully: Copied Helm values often carry blocks from an older example, so check each cache section after a merge.
- Test the rendered config: Render the chart or review the generated configuration before deployment.
Before the first deploy, confirm that each cache section in your values file names exactly one backend.
The right backend depends on how many replicas you run, what your platform already operates and what your licensing rules allow. A practical choice starts from those three facts and then checks the cost of operating the backend you pick, since each option moves work to a different team.
- Replica count: Multi-replica production clusters generally favor a shared cache such as Memcached, while single-replica setups may not need a separate tier.
- Existing platform standards: If your organization already runs Redis with Sentinel and has approved its license, reusing that pattern can reduce new operational work.
- Failover tolerance: Decide how a cache outage should behave. Losing a cache slows queries, and your design should accept that.
- Ownership and support: Name the team that patches, monitors and upgrades each backend.
- Quote scope: When you ask a partner to design this, request the backend choice for each cache in writing, along with the Sentinel layout if Redis is selected.
Before committing, confirm the license, the replica plan and the operating owner for every cache backend in your design.
Cache options and when each one fits
This table compares the three Loki cache roles (chunks, results and index) against Memcached, Redis and embedded backends, showing when each combination fits and what to confirm before choosing. Read each row as one cache, and remember that every cache can use only one backend. The main takeaway is that Memcached is the documented production default for multi-replica clusters, while the other options fit narrower situations.
| Cache role | Memcached | Redis | Embedded |
|---|---|---|---|
| chunksCache (log chunk reads from object storage) | Fits most multi-replica production clusters and is the default in the Loki Helm chart. Confirm memory sizing with your query pattern. | Fits teams that already run Redis and want one caching service. Confirm the Redis license and version you deploy, since Redis 8 offers AGPLv3 among its options. | Fits single-instance or test setups only. Each replica keeps its own cache, so it does not share hits across replicas. |
| resultsCache (query results at the query frontend) | Default in the Helm chart and a common production choice. Confirm that repeated dashboard queries benefit before sizing it. | Works where Redis is already operated with high availability. Confirm failover design, since Sentinel expects at least three Sentinel instances. | Acceptable for a single query frontend in a small or non-production environment. Not suited to several frontends. |
| Index cache (index lookups) | Supported for production, but confirm the index store version and schema in your Loki release before choosing. | Supported as a backend, but confirm with your Loki version's caching documentation that the index cache role accepts it. | Suitable for small test clusters. Lookups are not shared across replicas. |
| Memcached option: memcached-extstore | Spills cached data to disk. Pays off only when memory is the constraint, and confirm disk speed and eviction behavior with your own load test. | Not applicable. Redis is configured for in-memory data and does not use this Memcached feature. | Not applicable. |
| One backend per cache rule | Set one backend per cache role. Configuring Memcached and Redis for the same cache makes Loki fail to start. | Same rule applies. Choose one backend per cache and check values files for leftover settings. | Same rule applies. Remove any external backend block when using the embedded option. |
| Operational load | Runs as a cache service you deploy, monitor and size. Confirm who owns patching and restarts. | Runs as a cache service you deploy and license. Confirm whether you use Redis Open Source, Redis Software or a managed service, since these differ. | No separate service to run, but cache memory sits inside each Loki process. Confirm memory headroom on the components that host it. |
Why Redis licensing matters when you pick a cache backend
Choosing Redis as a cache backend for Loki is also a licensing decision, and the answer depends on which Redis line you deploy. Redis Open Source 8.0 and later can be used under the Redis Source Available License v2 (RSALv2), the Server Side Public License v1 (SSPLv1) or the GNU AGPLv3, at the user's choice. That option took effect with the general availability release of Redis 8, and Redis 8.0.0 was published on May 2, 2025. The Redis 7.4.x to 7.8.x releases remain under the dual RSALv2 or SSPLv1 license, which neither is OSI-approved, and Redis 7.2.x and earlier remain under BSD-3-Clause. A team that pins Redis 7.x or 8.x for a cache without checking this will not know which terms apply to its build.
The Redis licenses FAQ draws a line that matters for platform teams. Teams moving from Redis 7.2 or earlier with unmodified Redis artifacts see no impact from the change. Teams that offer modified Redis code as a network service must make the modified source available to that service's users. A standard Loki caching deployment runs unmodified Redis images, but a team that patches Redis, bundles it into a larger internal product, or wraps it in a custom managed service should treat that as a separate review item. Confirm which Redis build and version your Helm values and container images reference, and record it in your software inventory.
Before you choose Redis over Memcached for any Loki cache, have your legal counsel confirm the license position for your exact version, distribution and use. This page describes the license terms as stated on the Redis licenses page and does not replace that advice. Also note that Redis Open Source and Redis Ltd.'s commercial products are separate offerings with separate terms, so a managed service on another vendor's platform may carry different obligations. Put the license check in the same change record as the cache backend decision so that a future version bump triggers a review.
How to configure Memcached caches for Loki step by step
This sequence takes a Loki deployment from its current topology to enabled, verified Memcached caches for chunks and query results, and then shows whether the change reduced query latency and object storage reads.
Confirm deployment mode and replica count
Record which Loki deployment mode you run (monolithic, simple scalable or microservices) and how many replicas each read path component has, including queriers and query-frontends. The Loki documentation lists three modes, and simple scalable mode is being deprecated, so note this for later upgrade planning. Cache placement depends on which components query the data, so confirm the query path before changing any values. The step is done when you have a written topology that names every component that reads from the caches and its replica count.
Enable Memcached for chunks and results caches
In the Loki Helm chart values, review the chunksCache and resultsCache sections, which use Memcached by default. Confirm the Memcached settings you intend to keep, such as memory allocation and replica count, and record them in version control. Ask your platform team which Memcached image and version your Kubernetes environment permits, since the chart's supplied defaults should be checked against your own registry policy. The step is done when the values file renders with the cache sections enabled and the diff is reviewed.
Choose one backend per cache
For each cache, select exactly one backend: Memcached, Redis or an embedded in-process cache. Loki documentation recommends Memcached for production deployments with multiple replicas, and configuring both Memcached and Redis for the same cache causes Loki to fail at startup. Search your values files and any overrides for Redis settings on chunksCache, resultsCache and index-related caches, then remove or disable conflicting entries. If you use Redis for other Loki features, keep it on the cache where you have chosen it and document the decision. The step is done when a rendered configuration shows one backend per cache and no startup conflict is present.
Decide whether memcached-extstore is needed
Review whether your working set justifies memcached-extstore, which lets Memcached store items on disk in addition to memory. Assess your query volume and cache hit behavior before deciding, and ask the Loki or Memcached maintainers for guidance on whether the extra storage tier fits your environment. Record the decision with the reason, so the next operator knows whether it is intentional. The step is done when the decision is written down and the matching values are either set or explicitly left out.
Deploy and verify connectivity from queriers and query-frontends
Roll out the updated Helm release and confirm that the Memcached services are reachable from the query path components. Check the Loki pod logs for cache connection errors at startup, and run a test query from Grafana to confirm results return. Inspect the Memcached pods to verify they accept connections and are receiving traffic. The step is done when queriers and query-frontends start cleanly, log no cache connection failures, and show cache traffic from Memcached.
Measure query latency and object storage reads
Before the rollout, capture baseline query latency for a fixed set of representative LogQL queries and the object storage read volume reported by your storage provider or Loki metrics. Repeat the same queries and measurements after the caches are warm, using the same time ranges and load so the comparison is fair. Load testing with a tool such as k6 can make this repeatable. The step is done when you have a before and after table that shows whether latency and object storage reads changed, and you can explain any result that did not improve.
Security and operational considerations for Loki caches
Caches sit beside Loki's write and read paths, so they inherit risk from the logs they hold and from the software that serves them. The cards below cover where cache endpoints live, who can reach the data they hold, how they behave when evicted or restarted, how to watch them, and how to keep the cache software current.
Isolate cache endpoints inside the cluster
Memcached and Redis endpoints should accept connections only from the Loki components that use them, typically queriers, query-frontends and the components that read chunks and index data. Memcached has no built-in authentication in its standard deployment, so reachability is the control. Confirm with a network policy or security group that the cache service is not exposed to other namespaces, node networks or workloads, and that no ingress route or load balancer points at it.
Treat cache contents as log data
Chunk and results caches hold copies of log lines and query output, so a cache dump or a process with memory access exposes the same content the logs do. Apply the same access rules to the cache tier as to the object store: encrypted transport where your environment supports it, restricted host access, and tenant isolation that matches your Loki tenancy model. Ask who can exec into cache pods or read their memory.
Expect eviction and restart
A cache can drop entries at any time under memory pressure, and a restart empties it. Loki must then fetch chunks and index data again from object storage, which slows queries but does not lose data. Confirm that the object store remains the system of record, size cache memory so normal eviction does not starve queries, and test a cold-cache query path before go-live.
Monitor hit rates and evictions
Track cache hit ratio, eviction counts and memory use for each cache separately, since chunks, results and index caches fail in different ways. A falling hit ratio after a rollout or a rise in evictions usually points to undersized memory or a change in query shape. Set alerts on sustained evictions and compare query latency with cache state so slow queries are traced to the right cause.
Keep the cache software patched
Pin Memcached and Redis to a release line that still receives security fixes, and schedule upgrades with the Loki chart version. For Redis, check the license of the release line you deploy before adopting it, since Redis 7.4 through 7.8 use a dual RSALv2 or SSPLv1 license and Redis 8.0 and later offer AGPLv3 among the options. Review the release notes of each security update, then test in a non-production cluster before rolling it out.
Redis licensesQuestions teams ask before configuring Loki caching
Can our own team configure Memcached for Loki caching?
Yes, many teams can, provided they already run Loki and have someone comfortable with Kubernetes or their Helm workflow. The Loki Helm chart includes Memcached and enables it by default for the chunks cache and the results cache, so the first step is often reviewing and sizing those settings rather than building anything new. The harder parts are choosing which cache backend each cache uses, sizing memory against your query pattern, and proving the change helped. A partner is useful when the team lacks time for that validation or wants an independent review of the configuration before go-live.
What drives the effort of a Loki caching setup?
The main drivers are cluster size, the deployment mode you run, your query load and whether Redis is already in use in your environment. A monolithic installation with light querying needs far less review than a simple scalable or microservices cluster serving many tenants and dashboards. Existing Redis use matters because a cache can use only one backend, so you must decide whether to standardize on Memcached, Redis or an embedded cache and plan for any Redis instance you already operate. Each additional cache, replica or tenant with heavy queries adds validation work.
How long does a Loki caching setup and validation take?
The duration depends on the cluster and the validation you need, so it should be set in the written scope rather than assumed. Ask any provider to break the timeline into configuration, a test environment run, a production change window and post-change measurement. Your own team should also confirm how much change freeze, maintenance window or review time its processes require. No fixed timeline is given here because it depends on your environment.
What does our team need to provide for the work?
You will need access to the Loki cluster and its Helm values, read access to the Loki and cache metrics, and a sample of the queries your users actually run, including dashboards and alert rules that query Loki. Cache behavior depends on the access pattern, so representative query samples matter more than generic examples. You should also name an approver for configuration changes and a time window in which a restart of queriers or the cache can be tolerated. Confirm these inputs with your platform team before the scope is agreed.
What recurring work follows a Loki caching go-live?
Caches need ongoing attention after go-live. Teams typically monitor hit rates, memory use and evictions, review sizing when query volume or retention changes, and recheck the configuration during Loki upgrades, since the cache settings and defaults can change between releases. If you use Memcached in a cluster you operate, you also own its patching and availability. Decide early who watches these signals and how often sizing is reviewed, whether that is your team or a retainer with a partner.
Is there a published price for Loki caching implementation?
No, DeployOpen does not publish a price list. A quote follows from a written scope that names the Loki deployment mode, cluster size, cache backends, the systems to be validated and the deliverables you expect. Most engagements are fixed-scope, so scope, deliverables and timelines are agreed in writing before work starts. When you request a quote, ask for each component to be itemized, including validation, documentation, handover and any optional ongoing support as a separate retainer.
Should we choose Redis or Memcached for Loki caches?
Loki documentation recommends Memcached for production deployments with multiple replicas, and it can also use Redis or an embedded in-process cache. Redis licensing has changed across versions, so confirm which Redis release and license terms apply to your use before adopting it. Configuring both Memcached and Redis for the same cache prevents Loki from starting, so pick one backend per cache. Review the licensing and high availability requirements with your legal and platform teams before deciding.
How Loki reads through its caches before object storage
A query starts in Grafana and reaches the query-frontend, which checks the results cache before splitting work for the queriers. Queriers look up the index cache and the chunks cache, and only a miss in those caches goes to object storage. Each cache has one backend chosen from Memcached, Redis or an embedded cache, shown as alternatives. Check that each cache is configured with exactly one backend, since configuring both Memcached and Redis for the same cache stops Loki from starting.
Query path through Loki's caches, with object storage as the fallback on a miss.
Trade-offs to settle before rollout
The main trade-off is memory cost against cache hit rate. Each Loki cache, whether chunks, query results or index lookups, is a separate decision, and a larger Memcached pool generally keeps more chunks and results warm, which reduces object storage reads and query latency for repeat queries. The cost is RAM on the cache nodes, which recurs every month for as long as the cache runs. Before sizing, check which query patterns your teams actually run: dashboards that refresh the same ranges benefit from the results cache, while ad hoc searches across long, unique time windows often miss it regardless of pool size. Measure hit rates in your own environment during a load test before committing to a memory figure, and ask your partner or vendor to show how those numbers were derived.
The memcached-extstore option changes the economics. It lets Memcached keep part of its item store on local disk, so a large cache can hold more data than the RAM alone would allow. That pays off only when the cache is large and memory is the actual bottleneck, because disk-backed items are slower to read than items held in memory and the extra storage needs its own sizing, monitoring and node placement. For a small or moderate cache, the added complexity usually buys little. Confirm the extstore setup with the Loki caching documentation and your Memcached version before enabling it, and test whether hit rates and query latency improve enough to justify it.
Changing a cache backend should be planned as a change with a rollback path, not a casual config edit. Loki refuses to start when both Memcached and Redis are configured for the same cache, so a switch means removing one backend and adding another in a single controlled step, with the old configuration kept ready to restore. Write down the expected effect on query latency, the warm-up period after a restart, and the owner who approves the change, then roll it out during a window where query load is low and watch the cache and query metrics closely. Cache contents are disposable, so a rollback costs cold-cache performance rather than data loss, but only if the previous configuration is saved and tested.

