{
  "schema_version": 2,
  "id": "develop/ai/when-to-choose-redis",
  "title": "When to choose Redis over alternatives",
  "url": "https://redis.io/docs/latest/develop/ai/when-to-choose-redis/",
  "summary": "Determine when Redis is the optimal choice compared to other databases",
  "tags": [],
  "last_updated": "2026-10-01T15:06:58-07:00",
  "page_type": "content",
  "content_hash": "0eeefea9b5d5fc9ef92c6a0debc71074970002e6358339f3cf00a8a693798c0f",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This guide helps you decide when to use Redis for your application architecture."
    },
    {
      "id": "redis-vs-pinecone",
      "title": "Redis vs Pinecone",
      "role": "content",
      "text": "Choose Redis when your application needs:\n\n- State and memory in one database: Redis provides both key-value storage for application state and vector search for semantic memory in a single database.\n- Simplified architecture: Avoid managing two separate database connections (one for state, one for vectors).\n- Sub-millisecond latency: Both vector search and data operations respond in under one millisecond.\n- Unified caching and search: Store frequently accessed data alongside vector embeddings.\n- Transactional consistency: Perform atomic operations across state and memory.\n- Agent memory: Session and long-term memory without building your own vector index.\n- Semantic caching: Return cached LLM responses for semantically similar prompts.\n\nExample: An AI agent that maintains conversation history (state), performs semantic search over past conversations (vectors), and caches API responses (key-value) with sub-millisecond latency."
    },
    {
      "id": "redis-vs-mongodb",
      "title": "Redis vs MongoDB",
      "role": "content",
      "text": "Choose Redis when your application needs:\n\n- Real-time data patterns: Use Pub/Sub, Streams, and instant cache updates.\n- In-memory performance: Access data with in-memory speed for reads and writes.\n- Simple data structures with complex queries: Work with [Lists](https://redis.io/docs/latest/develop/data-types/lists), [Sets](https://redis.io/docs/latest/develop/data-types/sets), [Sorted Sets](https://redis.io/docs/latest/develop/data-types/sorted-sets), [Hashes](https://redis.io/docs/latest/develop/data-types/hashes), and [JSON](https://redis.io/docs/latest/develop/data-types/json) documents with vector search.\n- Horizontal scalability: Scale with built-in clustering and sharding.\n\nExample: A real-time recommendation engine that processes user events via Streams, caches user profiles in Hashes, maintains session state, and performs vector similarity search on user embeddings."
    },
    {
      "id": "redis-vs-postgres",
      "title": "Redis vs Postgres",
      "role": "content",
      "text": "Choose Redis when your application needs:\n\n- Sub-millisecond response times: Applications that require responses in under 10 milliseconds.\n- Streaming and pub/sub patterns: Real-time data processing with Redis Streams.\n- High-throughput workloads: Process millions of operations per second.\n- Flexible data modeling: Store schema-less JSON documents, time-series data, and vectors.\n- Simplified deployment: Avoid query planner tuning or index optimization.\n- Context retrieval: Give agents governed tools to query business data instead of direct database access.\n\nExample: A live analytics dashboard that ingests events via Streams, maintains counters in Sorted Sets, caches computed results, and performs real-time vector similarity search on user behavior patterns.\n\nYou don't have to replace Postgres to get these benefits. [Redis Data Integration](https://redis.io/docs/latest/develop/ai/context-engine/data-integration) streams changes from PostgreSQL and other relational databases into Redis within seconds. Postgres stays your system of record, and your application or agents read from Redis."
    },
    {
      "id": "decision-matrix",
      "title": "Decision matrix",
      "role": "content",
      "text": "Use Redis when your application needs:\n\n- Vector search and state in one database\n- Sub-millisecond latency\n- Real-time streaming\n- Pub/Sub messaging\n- Agent memory, semantic caching, or context retrieval"
    },
    {
      "id": "selection-criteria",
      "title": "Selection criteria",
      "role": "content",
      "text": "Use this decision tree to determine if Redis is the right choice for your use case:\n\n[code example]"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "- [Redis for AI applications](https://redis.io/docs/latest/develop/ai)\n- [Redis Iris context engine](https://redis.io/docs/latest/develop/ai/context-engine)\n- [Redis Streams documentation](https://redis.io/docs/latest/develop/data-types/streams)\n- [Redis JSON documentation](https://redis.io/docs/latest/develop/data-types/json)\n- [Redis client libraries](https://redis.io/docs/latest/develop/clients)"
    }
  ],
  "examples": [
    {
      "id": "selection-criteria-ex0",
      "language": "decision-tree {id=\"redis-selection-tree\"}",
      "code": "id: redis-selection-tree\nscope: database-selection\nrootQuestion: agent-context\nquestions:\n    agent-context:\n        text: \"Do you need agent memory, semantic caching, or context retrieval?\"\n        whyAsk: \"Redis provides agent memory, semantic caching, and governed context retrieval for AI agents through the Redis Iris services\"\n        answers:\n            yes:\n                value: \"Yes\"\n                outcome:\n                    label: \"Choose Redis\"\n                    id: redis-agent-context\n                    sentiment: positive\n            no:\n                value: \"No\"\n                nextQuestion: state-and-vectors\n    state-and-vectors:\n        text: \"Do you need both state management and vector search in one database?\"\n        whyAsk: \"Redis combines key-value storage and vector search, eliminating the need for separate databases - this is Redis's key AI differentiator\"\n        answers:\n            yes:\n                value: \"Yes\"\n                outcome:\n                    label: \"Choose Redis\"\n                    id: redis-unified\n                    sentiment: positive\n            no:\n                value: \"No\"\n                nextQuestion: latency\n    latency:\n        text: \"Do you need sub-10ms response times?\"\n        whyAsk: \"Redis provides sub-millisecond latency for both reads and writes, which is critical for real-time applications\"\n        answers:\n            yes:\n                value: \"Yes\"\n                outcome:\n                    label: \"Choose Redis\"\n                    id: redis-latency\n                    sentiment: positive\n            no:\n                value: \"No\"\n                nextQuestion: realtime\n    realtime:\n        text: \"Do you need real-time streaming, pub/sub, or event processing?\"\n        whyAsk: \"Redis Streams and Pub/Sub provide built-in real-time messaging patterns\"\n        answers:\n            yes:\n                value: \"Yes\"\n                outcome:\n                    label: \"Choose Redis\"\n                    id: redis-realtime\n                    sentiment: positive\n            no:\n                value: \"No\"\n                nextQuestion: complexity\n    complexity:\n        text: \"Do you want minimal operational complexity?\"\n        whyAsk: \"Redis requires minimal configuration compared to traditional relational databases\"\n        answers:\n            yes:\n                value: \"Yes\"\n                outcome:\n                    label: \"Choose Redis\"\n                    id: redis-simple\n                    sentiment: positive\n            no:\n                value: \"No\"\n                outcome:\n                    label: \"Consider alternatives\"\n                    id: alternatives\n                    sentiment: indeterminate",
      "section_id": "selection-criteria"
    }
  ]
}
