DBRaven
Full ReviewModerate Readinessdraft

Architecture Review: Search-Heavy Content Platform

A content platform architecture centered on Elasticsearch for full-text search, faceted navigation, and ranked results, with PostgreSQL as the transactional source of truth and Redis for session management and hot content caching. WAL-based CDC maintains index freshness by streaming PostgreSQL changes into Elasticsearch asynchronously. The core tension is between search index freshness, query performance, and index maintenance cost under high write volume.

Evidence Confidence

Moderate

strong

Executive Summary

Search-Heavy Content Platform: moderate operational readiness (81% evidence confidence). 5 architectural strengths identified, 4 operational risks to manage. Primary concern: Hot Partition. Requires Intermediate operational maturity.

Readiness Rationale

Overall moderate readiness across 8 dimensions. Weak: consistency. Strong: operational, migration, observability.

Key Concerns

  • !Hot Partition
  • !Thundering Herd (Cache Stampede)

Key Strengths

  • +Redis caching absorbs repeated read requests at the edge, reducing database load and latency for high read-to-write ratio workloads by orders of magnitude
  • +Redis distributed locks (via SET NX EX or Redlock) prevent thundering herd by ensuring only one caller repopulates a cache entry…
  • +Read-heavy APIs benefit directly from Redis as a caching tier that absorbs repeated identical reads and provides sub-millisecond…
  • +Search-heavy workloads cache popular queries and their result sets, absorbing the majority of search traffic from cache and…

8

Assessments

4

Tradeoffs

6

Sections

11

Recommendations

Readiness Assessments

8

Architectural Tradeoffs

4

Recommendations

11
High

Monitor: Hot Partition

risk_monitoring

One partition (a database shard, a Kafka topic partition, a Redis hash slot) receives traffic so far above its peers that it saturates while the others sit idle. Aggregate capacity looks healthy, but the hot partition throttles or lags, and everything routed to it degrades. The cause is skew in how keys map to partitions, and the fix depends on whether the skew is spread across many keys or concentrated in one.

Affects 0 nodes

High

Monitor: Thundering Herd (Cache Stampede)

risk_monitoring

When a popular cached key expires or a service recovers from downtime, all requests that were waiting or arrive simultaneously miss the cache and hit the origin database concurrently, producing a request spike that can overwhelm the database within seconds.

Affects 1 node. (Redis). 1 mitigation identified

High

Implement: Monitor generic risk probe signals

observability

Seed 'Thundering Herd (Cache Stampede) Risk Probe' identifies 2 metrics relevant to thundering_herd.

Metrics to instrument: error_rate, p95_latency_ms

Moderate

PostgreSQL full-text search (tsvector) serving all search queries → Elasticsearch for full-text and faceted search, PostgreSQL as source of truth

migration_planning

Trigger: Search query p99 > 500ms on full-text queries; faceted navigation requires aggregation over more than 5 dimensions simultaneously; relevance ranking quality insufficient for product requirements. Migrate from 'PostgreSQL full-text search (tsvector) serving all search queries' to 'Elasticsearch for full-text and faceted search, PostgreSQL as source of truth'. Design the Elasticsearch index mapping and shard count before the first document is indexed. Consult the expected document count at 2-year growth before setting primary shard count. Initial sync from PostgreSQL to Elasticsearch must run before the CDC pipeline takes over incremental updates.

Dual-write period (writing to both PostgreSQL and Elasticsearch) requires careful consistency management; Elasticsearch shard sizing and index design decisions made at creation time are expensive to change later

Moderate

Synchronous dual-write (application writes to PostgreSQL then Elasticsearch) → Asynchronous CDC-based indexing pipeline (PostgreSQL → WAL CDC → Kafka → Elasticsearch)

migration_planning

Trigger: Application write latency increasing due to Elasticsearch indexing latency in the synchronous path; Elasticsearch unavailability causing application write failures. Migrate from 'Synchronous dual-write (application writes to PostgreSQL then Elasticsearch)' to 'Asynchronous CDC-based indexing pipeline (PostgreSQL → WAL CDC → Kafka → Elasticsearch)'. The CDC pipeline decouples search availability from write path availability. Elasticsearch downtime no longer causes write failures. Communicate the indexing lag expectation to product stakeholders before the migration.

CDC pipeline introduces indexing lag: search results will lag writes by 1–30 seconds; CDC setup requires PostgreSQL logical replication, adding WAL overhead

Moderate

Prepare runbook for: Burst Traffic Cold Cache Stampede

simulation_preparedness

Simulation demonstrates critical degradation of redis, postgresql

Without a runbook, recovery from this failure mode will be ad-hoc

burst-traffic-cold-cache-stampede
Moderate

Prepare runbook for: Connection Pool Exhaustion with Horizontal User Scale

simulation_preparedness

Simulation demonstrates critical degradation of postgresql

Without a runbook, recovery from this failure mode will be ad-hoc

connection-pool-growth-with-user-scale
Moderate

Plan evolution: Single Cache Layer → Distributed Cache

evolution_planning

Evolution from Single Redis Node / Sentinel Cluster → Distributed Redis Cluster (Consistent Hash Ring)

Migration complexity: medium. Rollback: complex.

single-cache-to-distributed
Moderate

Plan evolution: Direct DB Queries → CQRS Read Models

evolution_planning

Evolution from Unified Read/Write Database → CQRS with Separate Read Projections

Migration complexity: high. Rollback: complex.

direct-db-to-cqrs
Low

Monitor threshold: Tier 1: Index Freshness Degradation

scaling_monitoring

Signal: Elasticsearch index CDC consumer lag > 10s; search results showing items that no longer exist or missing recently published items; CDC connector health dashboard showing processing rate below write rate

Bottleneck: CDC consumer or Elasticsearch bulk indexer not keeping pace with PostgreSQL write rate. Evolution: Increase Elasticsearch bulk indexer thread count; tune bulk index batch size and flush interval; profile CDC connector bottleneck (network vs Elasticsearch write throughput vs mapping complexity)

Low

Monitor threshold: Tier 2: Search Cluster Heap Pressure

scaling_monitoring

Signal: Elasticsearch JVM heap usage > 75% sustained; GC pause events visible in cluster logs; query p99 latency spikes during GC; cluster health showing yellow (unassigned shards during GC recovery)

Bottleneck: Large aggregation queries or high document count per shard exceeding JVM heap budget. Evolution: Increase Elasticsearch heap to 50% of node RAM (max 30GB for ZGC); reduce shard count to keep per-shard document count < 50M; disable dynamic mapping and explicitly define all field types; move to doc values for all non-analyzed fields

Scaling Pressure Signals

8

Elasticsearch index CDC consumer lag > 10s; search results showing items that no longer exist or missing recently published items; CDC connector health dashboard showing processing rate below write rate

Threshold

Tier 1: Index Freshness Degradation

Likely Bottleneck

CDC consumer or Elasticsearch bulk indexer not keeping pace with PostgreSQL write rate

Recommended Evolution

Increase Elasticsearch bulk indexer thread count; tune bulk index batch size and flush interval; profile CDC connector bottleneck (network vs Elasticsearch write throughput vs mapping complexity)

Evidence:elasticsearch-reindexing-pressurepartition-hotspot-amplification

Elasticsearch JVM heap usage > 75% sustained; GC pause events visible in cluster logs; query p99 latency spikes during GC; cluster health showing yellow (unassigned shards during GC recovery)

Threshold

Tier 2: Search Cluster Heap Pressure

Likely Bottleneck

Large aggregation queries or high document count per shard exceeding JVM heap budget

Recommended Evolution

Increase Elasticsearch heap to 50% of node RAM (max 30GB for ZGC); reduce shard count to keep per-shard document count < 50M; disable dynamic mapping and explicitly define all field types; move to doc values for all non-analyzed fields

Elasticsearch node stats showing one shard handling > 3x the query/index operations of others; hot-spotted shard's node CPU > 80% while others are idle

Threshold

Tier 3: Hot Shard Imbalance

Likely Bottleneck

Skewed routing key causing disproportionate document routing to one shard

Recommended Evolution

Enable shard-level routing with custom routing hash; review document routing key selection; for write-heavy scenarios, increase primary shard count and reindex with a new shard allocation

Evidence:elasticsearch-reindexing-pressurepartition-hotspot-amplification

Index mapping change required (new field type, changed analyzer); full catalog reindex estimated > 4 hours; active searches against index during reindex causing performance degradation

Threshold

Tier 4: Full Reindex Requirement

Likely Bottleneck

Mapping change requiring full document reprocessing on a large index

Recommended Evolution

Implement blue/green index alias strategy before this event occurs; new index is built under an alias while the old index serves traffic; alias is atomically flipped on reindex completion

Elasticsearch index CDC consumer lag > 10s; search results showing items that no longer exist or missing recently published items; CDC connector health dashboard showing processing rate below write rate

Threshold

Escalation trigger: CDC consumer or Elasticsearch bulk indexer not keeping pace with PostgreSQL write rate

Likely Bottleneck

Tier 1: Index Freshness Degradation

Recommended Evolution

Monitor: error_rate, p95_latency_ms

Elasticsearch JVM heap usage > 75% sustained; GC pause events visible in cluster logs; query p99 latency spikes during GC; cluster health showing yellow (unassigned shards during GC recovery)

Threshold

Escalation trigger: Large aggregation queries or high document count per shard exceeding JVM heap budget

Likely Bottleneck

Tier 2: Search Cluster Heap Pressure

Recommended Evolution

Monitor: error_rate, p95_latency_ms

Elasticsearch node stats showing one shard handling > 3x the query/index operations of others; hot-spotted shard's node CPU > 80% while others are idle

Threshold

Escalation trigger: Skewed routing key causing disproportionate document routing to one shard

Likely Bottleneck

Tier 3: Hot Shard Imbalance

Recommended Evolution

Monitor: error_rate, p95_latency_ms

Index mapping change required (new field type, changed analyzer); full catalog reindex estimated > 4 hours; active searches against index during reindex causing performance degradation

Threshold

Escalation trigger: Mapping change requiring full document reprocessing on a large index

Likely Bottleneck

Tier 4: Full Reindex Requirement

Recommended Evolution

Monitor: error_rate, p95_latency_ms

Migration Readiness

12

Migration Stages

3
Stage

PostgreSQL full-text search (tsvector) serving all search queries → Elasticsearch for full-text and faceted search, PostgreSQL as source of truth

info

Migration trigger: Search query p99 > 500ms on full-text queries; faceted navigation requires aggregation over more than 5 dimensions simultaneously; relevance ranking quality insufficient for product requirements

Stage

Synchronous dual-write (application writes to PostgreSQL then Elasticsearch) → Asynchronous CDC-based indexing pipeline (PostgreSQL → WAL CDC → Kafka → Elasticsearch)

info

Migration trigger: Application write latency increasing due to Elasticsearch indexing latency in the synchronous path; Elasticsearch unavailability causing application write failures

Stage

Single Elasticsearch cluster serving all query types → Separate read-optimized and write-optimized Elasticsearch indexes

info

Migration trigger: High write throughput (> 10k documents/min) causing segment refresh to degrade query latency; bulk indexing jobs competing with user search queries for heap

!

Risks

9
Risk

Dual-write period (writing to both PostgreSQL and Elasticsea

warning

Dual-write period (writing to both PostgreSQL and Elasticsearch) requires careful consistency management

Risk

Elasticsearch shard sizing and index design decisions made a

warning

Elasticsearch shard sizing and index design decisions made at creation time are expensive to change later

Risk

CDC pipeline introduces indexing lag: search results will la

warning

CDC pipeline introduces indexing lag: search results will lag writes by 1–30 seconds

Risk

CDC setup requires PostgreSQL logical replication, adding WA

warning

CDC setup requires PostgreSQL logical replication, adding WAL overhead

Risk

Two-index strategy doubles storage and operational surface

warning
Risk

Alias management becomes more complex with separate read/wri

warning

Alias management becomes more complex with separate read/write indexes

Risk

Projection lag creates a read-after-write window where users

critical

Projection lag creates a read-after-write window where users see stale data after their own writes. Mitigation: Route immediate post-write reads to the write store (session-scoped write token); accept eventual consistency only for non-user-initiated reads

direct-db-to-cqrs

Risk

Projection rebuild after schema change can take hours or day

critical

Projection rebuild after schema change can take hours or days on large datasets. Mitigation: Design blue/green projection deployment: build new projection in parallel before switching traffic; test rebuild time in staging

direct-db-to-cqrs

Risk

Missing partition for current time window causes all INSERTs

critical

Missing partition for current time window causes all INSERTs to fail with 'no partition of relation found'. Mitigation: Create partitions 7-30 days in advance; alert when next partition does not exist before its time window opens

postgresql-to-partitioned

Review Sections

6

Referenced Intelligence

elasticsearchpostgresqlredisburst-traffic-cold-cache-stampedeconnection-pool-growth-with-user-scalecqrs-projection-lag-expansioncross-region-stale-read-windowdistributed-cache-invalidation-failureelasticsearch-reindexing-pressureevent-replay-storm-recoverymulti-tenant-noisy-neighborpartition-hotspot-amplificationpostgresql-replication-lag-surgequery-cost-without-indexesread-amplification-n-plus-one-queriesredis-cache-collapse-stampederetry-storm-amplificationsplit-brain-during-network-partitionstorage-bloat-without-archivingstorage-cost-compounding-without-retentionwrite-heavy-bulk-import-saturationdirect-db-to-cqrspostgresql-to-partitionedsingle-cache-to-distributedsingle-region-to-multi-regionarchitecture-evolutionauditabilitybtree-indexingcache-invalidationcap-theoremconsistency-modelscqrs-operationalevent-sourcingeventual-consistencymulti-tenancynormalizationoltp-vs-olapquery-planningreplication-lagsearch-systemsvector-databaseswrite-amplification
Architecture Review: Search-Heavy Content Platform: DBRaven