Comparison

Workers KV vs D1 for bot state (conceptual)

Ephemeral key-value versus SQL at the edge — choose from official limits.

Comparison1 min readUpdated

On Cloudflare, KV is eventually consistent key-value; D1 is SQL. Chat bots that need relational queries and transactions usually want D1 (or an external DB), not KV as a primary store.

Checklist

  • Use KV for cache and config snapshots
  • Use D1 for relational bot state
  • Do not treat KV as a strongly consistent lock store
  • Measure cold-start + query latency together

When to choose what

Write the decision down with a revisit date. Re-evaluate when latency, cost or ops load changes.

Frequently asked questions

Is this exhaustive?

No. It is a practical starting point; verify details in official docs before production.

Related comparisons and tools