AI Memory · 비용

자체 구축 Agent Memory vs SaaS Memory, 어느 쪽이 더 저렴할까? Redis·Postgres·TencentDB 가이드(2026)

2026.08.07 · 약 9분 읽기

Agent Memory 청구서는 'DB 임대료'가 아니라 메모리 계층 × 리콜 빈도 × 운영 인력의 곱입니다. 3계층 모델로 자체 구축과 SaaS를 비교하고 Redis·Postgres·TencentDB를 평가합니다.

서버 랙과 데이터베이스 노드—AI 에이전트 메모리 저장 아키텍처

Bottom line: Below roughly 5,000 memory writes per month, SaaS Memory is usually cheaper all-in. Above ~10k writes/month or when you need private deployment, self-hosted Redis + Postgres (or TencentDB in China) typically wins. For engines: Redis for session/hot memory, Postgres (pgvector) for semantic recall, TencentDB when you need managed compliance domestically.

Last updated August 7, 2026. Price bands come from 2026 public cloud and Mem0/Zep-style SaaS pages; your invoice will vary by region, discounts, and usage.

Why “database rent” misleads Agent Memory budgets

Teams often treat Agent Memory as “one more database.” In practice you pay for at least three different things:

  1. Write cost—summaries after each turn, embeddings, cross-session merges—driving LLM and vector compute bills.
  2. Storage cost—hot data in Redis, warm rows in Postgres, cold archives in object storage; a single tier is usually the most expensive mistake.
  3. Recall cost—how many lookups per user message, reranking, and whether latency must stay under 100ms; high QPS can make Redis cost more than Postgres.

Monthly Memory total = writes (model + embedding) + storage (DB + backup) + recall (QPS × latency tier) + ops labor

SaaS vendors (Mem0, Zep, LangMem Cloud) bundle the last three into seats or MAU pricing. Self-hosted means you own every line item—SaaS saves ops at small scale; self-hosted saves marginal cost at scale.

How to classify Agent Memory (What)

Before comparing Redis, Postgres, and TencentDB, align on memory layers—or you will store session IDs in a vector index or run full-text search on Redis.

LayerTypical contentLifetimeBest store
L1 workingCurrent session context, tool state, short preferencesMinutes–hoursRedis / in-process cache
L2 episodicConversation summaries, task history, preference tagsDays–monthsPostgres JSONB / document store
L3 semanticEmbedded knowledge, RAG chunks, shared factsLong-termPostgres pgvector / vector DB

Asymmetric takeaway: For most coding agents and support bots, L2 episodic memory is the cost center because writes include LLM summarization—not because the vector database is inherently expensive.

Core compare: self-hosted vs SaaS Memory (2026 monthly anchors)

Three bands: side project, small-team beta, ~10k MAU production. Technical layer only (no model API), includes basic monitoring and backup. USD bands; TencentDB row for RMB teams in China.

ApproachSide projectSmall team~10k MAUOps load
Mem0 / Zep SaaS$0–29$49–99$199–499+Low (vendor SLA)
Self-hosted Redis + Postgres (VM)$25–45$60–120$150–280Medium (patching, backups)
TencentDB Redis + PostgreSQL¥300–600¥800–1,500¥2,000–4,500Low–medium (managed, domestic)
Redis only (all-in)$15–30$40–80RAM explodes—avoid prod all-inMedium

Rule of thumb: <5k writes/month with no dedicated SRE → SaaS wins on total cost. >30k writes/month or strict data residency → self-hosted or TencentDB.

Redis vs Postgres vs TencentDB for AI Memory

EngineStrengthTypical AI Memory useMain risk
RedisSub-ms KV, TTL, pub/subL1 session state, rate limits, hot profile cacheRAM cost; durability misconfig loses memory
Postgres + pgvectorACID, rich queries, vectors + relationsL2 tables + L3 vectors in one DB; audit, multi-tenantNeeds HNSW tuning at large vector scale
TencentDBManaged domestic compliance, backups, alertsMainland-facing agents instead of DIY VM databases15–30% premium vs DIY VM; cross-border latency
  • Redis (L1) + Postgres pgvector (L2+L3)—most examples for Claude Code / LangChain stacks.
  • TencentDB Redis + PostgreSQL—same app pattern for China production and filing/compliance needs.
  • SaaS Memory only—two-week demos with zero DB ops; plan export to Postgres later.

How to choose (decision matrix)

If you are…PickWhy
Solo dev proving an agentSaaS free tier → migrate laterZero ops, fast write/recall validation
Domestic B2B agent, data stays in ChinaTencentDB + your app layerManaged compliance without 24/7 DBA
High-frequency coding agentRedis L1 + Postgres L2Hot state in Redis, auditable summaries in SQL
Knowledge RAG agentPostgres pgvector or dedicated vector DBAt 1M+ vectors tune Postgres or add Qdrant
10+ person team with SRERedis + Postgres on K8sLowest marginal cost, unified observability

Stack A — fastest MVP (2 weeks)

  • Mem0 or Zep Cloud for episodic + semantic memory
  • App calls SaaS API; session state on Upstash Redis free tier
  • Monthly tech anchor: $0–49

Stack B — portable self-hosted (most teams)

  • Redis: session + 24h hot memory with TTL
  • Postgres: users, summaries, pgvector embeddings
  • Nightly jobs compress L2 → L3 to control embedding spend
  • Monthly tech anchor: $60–150 (small team)

Stack C — China production

  • TencentDB Redis 2GB + TencentDB PostgreSQL standard
  • COS object storage for cold conversation archives
  • App in same-region VPC to avoid cross-zone egress
  • Monthly tech anchor: ¥1,200–2,500

Common pitfalls

  1. Embedding everything—L2 summaries often need no vector; embeddings are a silent budget killer.
  2. Redis as permanent memory—eviction or restart feels like amnesia to users.
  3. Ignoring recall QPS—ten vector queries per message hurts more than storing 100k rows.
  4. One API key for whole team on SaaS—audit and rate limits break; compliance risk rises.
  5. Postgres without pooling—parallel tool calls exhaust connections; memory “randomly fails.”
  6. Overseas SaaS for mainland users—latency plus residency; TencentDB is often simpler.

Action plan (7 steps)

  1. Map three layers—what lives in L1/L2/L3, TTL, and access rules.
  2. Estimate monthly writes—conversations × summaries/embeddings per turn.
  3. Pick the crossover—<5k writes start SaaS; >30k or private deploy → self-hosted/TencentDB.
  4. Choose storage combo—default Redis + Postgres; swap to TencentDB in China prod.
  5. Cap recall budget—max DB/vector queries per user message as a code constant.
  6. Run a 14-day soak test—real dialogs; watch storage growth and P95 latency.
  7. Define export format—even on SaaS, keep JSON/Parquet export path to Postgres.

FAQ

What is the minimum budget for self-hosted Agent Memory?

Technical layer can hit $25–40/month on a small VM plus managed Redis/Postgres tiers. Add 2–4 hours/week ops and SaaS at $29 may be cheaper for tiny teams.

Can Redis alone power AI Memory?

Only for L1 working memory and caches. Long episodic and semantic recall need Postgres or a vector store.

How far does Postgres pgvector scale?

For sub-million vectors at 1536 dims with tuned HNSW, most agent products are fine. 90% of teams never outgrow it.

How much more is TencentDB vs DIY Postgres on a VM?

Typically 15–30% higher list price but includes backup, monitoring, patches, and HA—often lower total cost without a DBA.

Can SaaS Memory migrate to self-hosted?

Most vendors export users and memory blocks via API. Pipeline: export → Postgres L2 tables → re-embed semantic chunks into pgvector.

Conclusion

Whether self-hosted or SaaS Agent Memory is cheaper depends on monthly writes, recall frequency, and ops time—not list prices of Redis vs Postgres. A pragmatic 2026 path: SaaS for MVP, Redis + Postgres self-hosted after validation, TencentDB for compliant China production.

Before launch ask: if memory writes double next month, which line item breaks first? Embedding, Redis RAM, or SaaS seats—that answer tells you whether to stay on SaaS or migrate.

Worked example: one coding agent, 30 active users

Assume 30 developers use a Claude Code–style agent daily, 40 turns per user per month, and 30% of turns trigger an episodic summary (L2) plus embedding (L3). That is roughly 360 summary writes and ~500k embedding tokens per month.

  • SaaS path: Mem0 Pro–class tier ~$49 + embedding API ~$8–15 → ~$60–70/mo with near-zero ops.
  • Self-hosted path: Small VM $24 + managed Redis $10 + Postgres $25 + embedding ~$12 + ~3h ops → ~$75–90/mo cash, higher if you bill engineering time.

At this scale SaaS still wins on total cost of ownership. Crossover appears when the same pattern hits 300+ daily active agent users or 10k+ monthly memory writes—then Postgres storage and SaaS seat pricing compound faster than a single DBA-hour-efficient stack.

What to monitor after you ship Memory

Regardless of Redis, Postgres, or TencentDB, attach metrics before users complain about “forgetful” agents:

  1. write_latency_p95—summary + embed pipeline; spikes predict bill surprises.
  2. recall_qps_per_session—if this climbs without product changes, fix retrieval loops in agent code.
  3. memory_bytes_per_user—unbounded L2 JSON grows faster than vector tables.
  4. saas_export_age_days—if on SaaS, test restore to Postgres quarterly.

Teams running agents on remote Mac build nodes often co-locate a small Redis on the same VPC as the agent gateway to keep L1 recall under 5ms while Postgres stays regional.

Further reading

안정적인 Cloud Mac 노드에서 에이전트 개발

Agent Memory를 로컬에서 디버깅할 때 M4 통합 메모리는 embedding, 벡터 검색, Xcode를 동시에 돌리기 좋습니다. 전용 노드는 월 구독으로 시행착오용 하드웨어 구매를 피할 수 있습니다.

지금 주문

AI Memory

안정적인 Cloud Mac 노드에서 에이전트 개발

M4 · Cloud Mac · Agent dev

지금 주문