Choose the right NoSQL database. Covers document stores, key-value, wide-column, graph databases, time-series databases, and when to use NoSQL vs relational.
NoSQL databases are a foundational choice for applications that need flexible schemas, high scalability, and low-latency reads and writes. This guide helps engineers select the right NoSQL database for a given workload, from initial project scoping to production deployment. It focuses on decisions that directly influence performance, reliability, and operational complexity—without assuming a specific platform or tooling stack.
Choose a NoSQL database when:
A selection decision is critical when:
The primary driver in NoSQL selection is the query and access pattern of the application.
Start by listing the core operations:
Use the following query types to define your access profile:
GET /users/{id} — fetch a single record by key.GET /events?from=2023-01-01&to=2023-01-31 — fetch records within a time window.SELECT COUNT(*), AVG(duration) FROM events WHERE region = 'us-west'.Each NoSQL database excels at certain access patterns:
| Access Pattern | Best-Fit Databases |
|---|---|
| High-frequency point reads | Key-value stores (e.g., DynamoDB, Redis, Riak) |
| Document-centric queries | Document databases (e.g., MongoDB, CouchDB) |
| Graph traversal | Graph databases (e.g., Neo4j, JanusGraph) |
| Time-series analytics | Time-series databases (e.g., InfluxDB, TimescaleDB) |
For example, if your application relies on GET /users/{id} with 90% of requests serving a single user record, and you expect 100K requests per second, a key-value store with native support for consistent reads and low-latency writes is essential.
NoSQL databases trade off consistency for availability and partition tolerance. Choose a model based on how your application handles data staleness and failure.
PUT /accounts/123, all subsequent GET /accounts/123 calls must return the new value.Use the following criteria to decide:
Set up replication to ensure data survival across failures.
acknowledged: write succeeds when written to one node.committed: write confirmed on a quorum of nodes (e.g., 2 out of 3).synchronized: write committed to a majority and flushed to disk.Configuration example (JSON-based, widely used in distributed NoSQL systems):
{
"replication": {
"factor": 3,
"write_concern": "majority",
"write_timeout_ms": 5000,
"read_preference": "nearest"
}
}
A common failure: setting write_concern = "acknowledged" but expecting majority. Without explicit quorum, writes may be lost during a network partition.
Horizontal scalability is a hallmark of NoSQL. The selection process must include how data is partitioned and how the system handles growth.
hash(user_id) % num_shards → assign document to shard.region first, then by user_id within each region.Use the following when designing partition keys:
user_id with 100K users) that lead to uneven load across shards.Hotspots occur when one partition receives disproportionately more traffic.
PUT /users/{id} for a subset of users.Diagnose with:
SELECT shard_id, count(*), avg(latency) FROM operations GROUP BY shard_idSHOW TABLES WITH STATS (common in distributed systems)To resolve:
NoSQL databases vary in operational demands. Assess the required effort for deployment, monitoring, and maintenance.
Use standard tools: docker-compose.yml, kubectl apply -f, systemctl enable, curl.
Example docker-compose.yml for a NoSQL cluster:
version: '3.8'
services:
db:
image: redis:7
ports:
- "6379:6379"
volumes:
- redis-data:/data
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=db-master
command: ["redis-server", "--appendonly", "yes", "--cluster-enabled", "yes"]
db-master:
image: redis:7
ports:
- "6380:6379"
volumes:
- redis-data:/data
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-announce-ip", "db-master"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
volumes:
redis-data:
Key operations:
docker-compose up -ddocker-compose scale db=5docker-compose up --no-recreate --force-recreateUse standard metrics:
latency, throughput, error_rate, replication_lag, cache_hit_rate.Common failure modes:
ping, tcpdump, or systemd healthchecks.timeout or 504 Gateway Timeout responses.write_timeout, connection_pool_full, disk_full.SELECT * FROM system.nodes WHERE status = 'read_only'.Use curl to probe cluster health:
curl -s http://db-master:6379/health | jq
{
"status": "healthy",
"nodes": [
{ "id": "node-1", "latency_ms": 12, "status": "up" },
{ "id": "node-2", "latency_ms": 18, "status": "down" }
],
"replication_lag": 2000
}
Select the database based on where it will be used in the product lifecycle.
CREATE TABLE IF NOT EXISTS, ALTER TABLE ADD COLUMN, INSERT OR REPLACE.curl to test APIs: curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "email": "[email protected]"}'
avg_cpu > 70% or pending_writes > 1000.systemctl to manage database daemons.keepalived or haproxy for high availability.tar -czf backup-$(date +%Y-%m-%d).tar.gz /var/db/ nightly.pg_dump for PostgreSQL-like systems.{"version": 1, "data": {...}}kubectl rollout restart deployment/db for Kubernetes-based deployments.Overhead of document parsing, indexing, and query planning. Fix: use a key-value store (e.g., Redis, DynamoDB) for high-frequency access.
Users see old data; updates appear asynchronously. Fix: implement cache stamping:
{
"user_id": 123,
"name": "Alice",
"last_updated": "2023-10-05T12:00:00Z",
"cache_version": 4
}
Clients check cache_version and refresh when outdated.
A poorly chosen key causes hotspots and uneven load. Fix: monitor latency per shard, then re-partition using a tool like aws dynamodb update-table.
New nodes fall behind, leading to inconsistent data. Fix: set replication_lag_threshold = 10s and alert when exceeded.
acknowledged vs majority leads to data loss during failures. Fix: use write_concern = majority and validate with SELECT COUNT(*) FROM writes WHERE status = 'committed'.
The right NoSQL database is not just a technology—it is a strategic decision in how data flows through your system.
This page was rewritten on 17 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy