Redis in open-source AI tools: caching, queues and vector search for Dify, Langfuse, LiteLLM and n8n in 2026
What Redis does in an AI stack
Redis keeps data in memory and answers in well under a millisecond. In AI apps it rarely holds the main records, which live in PostgreSQL or another database. It does the coordination work around them:
| Job | Example |
|---|---|
| Task queue broker | Dify's Celery workers pick up document indexing and workflow jobs |
| Cache | Store embeddings, model responses or settings to avoid repeat calls |
| Rate limiting and budgets | LiteLLM tracks requests and spend per key across proxy instances |
| Pub/sub and streams | Push workflow progress to the browser; fan out events |
| Sessions and locks | Share login sessions and prevent duplicate jobs across servers |
| Semantic cache | Return a stored answer when a new prompt is similar enough to an old one |
Which directory projects use it
| Project | Redis role |
|---|---|
| Dify | Celery broker and cache; required in the default Docker Compose |
| Langfuse | Queue for ingesting traces and cache; required for v3 and later |
| LiteLLM | Shared rate limits, budgets and response caching across proxy instances |
| n8n | Queue mode, which splits workflow executions across worker processes |
In each case the project works with a standard Redis or Valkey instance. You do not need Redis Stack or Redis 8 features unless the project documents them.
Redis 8 and 8.10
Redis 8.0, released in 2025, merged the former Redis Stack modules into the main distribution, so JSON documents, time series, probabilistic data structures and the Redis Query Engine with vector search ship in one package. It also introduced vector sets, a data type designed for similarity search with a simpler API than the query engine. Later 8.x releases continued performance work, and 8.10.2, on September 17, 2026, is the current release.
Licensing history
Redis licensing has changed twice, and it matters for some organizations:
| Period | License |
|---|---|
| Until March 2024 | BSD-3-Clause, fully open source |
| March 2024 to Redis 8 | RSALv2 or SSPLv1, source-available, not OSI-approved |
| Redis 8 onward | RSALv2, SSPLv1 or AGPLv3, at the user's choice |
The 2024 change prompted the Linux Foundation, with support from AWS, Google Cloud, Oracle and others, to fork Redis 7.2.4 as Valkey under the original BSD license. Salvatore Sanfilippo, Redis's creator, returned to Redis in late 2024, and the company added the AGPL option with Redis 8, which made Redis open source by the OSI definition again.
For self-hosting an AI tool internally, any of these licenses permits use. The differences matter mainly to companies offering Redis itself as a hosted service.
Valkey
Valkey has continued development independently. It has added multi-threaded I/O improvements and new features of its own, and AWS ElastiCache, Google Memorystore and others now offer Valkey, often at lower prices than their Redis options. For the queue and cache roles that Dify, Langfuse, LiteLLM and n8n need, Valkey is a drop-in replacement. Choose Redis 8 if you want its built-in vector search and JSON features; choose Valkey if you want a BSD-licensed server and broad cloud support.
Hosted options
| Service | Starting price | Notes |
|---|---|---|
| Redis Cloud | Free 30 MB; Essentials from $5/mo; Pro from $200/mo | Run by Redis Ltd., includes Redis 8 features |
| AWS ElastiCache | Pay per node or serverless | Redis OSS and Valkey engines |
| Google Memorystore | Pay per GB-hour | Redis and Valkey |
| Upstash | Free tier, pay per request | Serverless Redis with an HTTP API, popular with Vercel apps |
Self-hosting Redis for AI tools
- Keep it private. Redis was designed for trusted networks. Never expose port 6379 publicly; attackers scan for open Redis servers and abuse them within hours. Set a password with
requirepassor ACLs. - Persistence for queues. Turn on AOF persistence if Redis holds jobs, so a restart does not lose queued work. Cache-only instances can run without it.
- Memory limits. Set
maxmemoryand an eviction policy such asallkeys-lrufor caches. For queues, usenoevictionso jobs are never silently dropped. - Separate instances. If one Redis serves both cache and queues, a full cache can push out jobs. Larger installs use two instances or separate databases with care.
- Monitor. Track memory, connected clients and queue lengths. A queue that keeps growing means workers cannot keep up.
Semantic caching with Redis
Model calls are slow and cost money, and many users ask nearly the same questions. A semantic cache stores each prompt's embedding with its answer; when a new prompt arrives, it searches for a stored prompt within a similarity threshold and returns the cached answer if one is close enough. Redis's vector search makes this fast. LiteLLM supports Redis semantic caching through configuration, and RedisVL, the Redis vector library for Python, provides a ready-made semantic cache class. Set the threshold carefully: too loose and users get answers to questions they did not ask.
Redis versus alternatives for queues
| Option | Strength |
|---|---|
| Redis or Valkey | Fast, simple, supported by Celery, BullMQ, RQ and Sidekiq |
| PostgreSQL-based queues | One less service; pg-boss, Graphile Worker, Procrastinate |
| RabbitMQ | Rich routing, delivery guarantees |
| Kafka or Redpanda | Very high-throughput event streams |
| Temporal | Durable workflows with retries and state |
Small self-hosted installs increasingly use Postgres-backed queues to avoid running Redis at all, but the AI platforms in our directory still expect Redis.
Redis in multi-instance deployments
A single server running Dify or LiteLLM can keep some state in memory. Once you run two or more instances behind a load balancer, they must share that state, and Redis is where it goes. LiteLLM needs Redis to enforce a team's budget correctly when requests land on different proxy instances; without it, each instance counts separately and the team can spend several times its limit. Langfuse uses Redis queues so web containers accept traces quickly while worker containers write them to ClickHouse. n8n's queue mode puts each workflow execution on a Redis queue so a pool of workers can run them in parallel, which is how large n8n installs handle thousands of executions an hour.
For high availability, run Redis with replicas and Redis Sentinel, or use a managed service that handles failover. Check that the AI tool supports Sentinel or cluster mode before relying on it; some only accept a single Redis URL.
Common problems
| Symptom | Likely cause |
|---|---|
| Documents stuck "indexing" in Dify | Worker not connected to Redis, or worker crashed |
| LiteLLM budgets not enforced across instances | Redis not configured, so each instance tracks its own counts |
| Out-of-memory errors | No maxmemory limit, or a cache with no expiry |
| Lost jobs after restart | Persistence disabled |
Related: PostgreSQL stack, LiteLLM stack, n8n stack, Docker stack, Qdrant stack, Stack index.
Frequently asked questions
Why do AI platforms need Redis?
To split work between web servers and background workers. When you upload documents to Dify, the API puts an indexing job on a Redis-backed queue and a worker processes it. Redis also caches model responses and settings, enforces rate limits and budgets in gateways like LiteLLM, and lets several server instances share state.
Is Redis open source again?
Since Redis 8 in 2025, the Redis Open Source edition can be used under the AGPLv3, an OSI-approved license, as one of three options. Between March 2024 and that change, Redis was available only under source-available licenses. The AGPL requires sharing source if you offer a modified Redis as a network service.
Can I use Valkey instead of Redis for Dify or Langfuse?
Usually yes. Valkey is compatible with the Redis protocol and commands up to Redis 7.2, which covers what queues and caches in these tools need. Features added only in Redis 8, such as its built-in vector sets and query engine, are not in Valkey.
Does Redis do vector search?
Yes. Redis 8 includes the Redis Query Engine, which supports vector similarity search with HNSW and flat indexes, plus a newer vector set data type. It suits semantic caching and small to medium retrieval workloads where low latency matters.
How much memory does Redis need for a self-hosted AI app?
For queues and caching in a small Dify or n8n install, 256 MB to 1 GB is typical. Set a maxmemory limit and an eviction policy for cache use, and turn on persistence for queues so jobs survive a restart.