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
8Architectural Tradeoffs
4Recommendations
11Monitor: Hot Partition
risk_monitoringOne 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
Monitor: Thundering Herd (Cache Stampede)
risk_monitoringWhen 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
Implement: Monitor generic risk probe signals
observabilitySeed 'Thundering Herd (Cache Stampede) Risk Probe' identifies 2 metrics relevant to thundering_herd.
Metrics to instrument: error_rate, p95_latency_ms
PostgreSQL full-text search (tsvector) serving all search queries → Elasticsearch for full-text and faceted search, PostgreSQL as source of truth
migration_planningTrigger: 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
Synchronous dual-write (application writes to PostgreSQL then Elasticsearch) → Asynchronous CDC-based indexing pipeline (PostgreSQL → WAL CDC → Kafka → Elasticsearch)
migration_planningTrigger: 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
Prepare runbook for: Burst Traffic Cold Cache Stampede
simulation_preparednessSimulation demonstrates critical degradation of redis, postgresql
Without a runbook, recovery from this failure mode will be ad-hoc
Prepare runbook for: Connection Pool Exhaustion with Horizontal User Scale
simulation_preparednessSimulation demonstrates critical degradation of postgresql
Without a runbook, recovery from this failure mode will be ad-hoc
Plan evolution: Single Cache Layer → Distributed Cache
evolution_planningEvolution from Single Redis Node / Sentinel Cluster → Distributed Redis Cluster (Consistent Hash Ring)
Migration complexity: medium. Rollback: complex.
Plan evolution: Direct DB Queries → CQRS Read Models
evolution_planningEvolution from Unified Read/Write Database → CQRS with Separate Read Projections
Migration complexity: high. Rollback: complex.
Monitor threshold: Tier 1: Index Freshness Degradation
scaling_monitoringSignal: 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)
Monitor threshold: Tier 2: Search Cluster Heap Pressure
scaling_monitoringSignal: 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
8Elasticsearch 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)
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
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
12Migration Stages
3PostgreSQL full-text search (tsvector) serving all search queries → Elasticsearch for full-text and faceted search, PostgreSQL as source of truth
infoMigration 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
Synchronous dual-write (application writes to PostgreSQL then Elasticsearch) → Asynchronous CDC-based indexing pipeline (PostgreSQL → WAL CDC → Kafka → Elasticsearch)
infoMigration trigger: Application write latency increasing due to Elasticsearch indexing latency in the synchronous path; Elasticsearch unavailability causing application write failures
Single Elasticsearch cluster serving all query types → Separate read-optimized and write-optimized Elasticsearch indexes
infoMigration 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
9Dual-write period (writing to both PostgreSQL and Elasticsea
warningDual-write period (writing to both PostgreSQL and Elasticsearch) requires careful consistency management
Elasticsearch shard sizing and index design decisions made a
warningElasticsearch shard sizing and index design decisions made at creation time are expensive to change later
CDC pipeline introduces indexing lag: search results will la
warningCDC pipeline introduces indexing lag: search results will lag writes by 1–30 seconds
CDC setup requires PostgreSQL logical replication, adding WA
warningCDC setup requires PostgreSQL logical replication, adding WAL overhead
Two-index strategy doubles storage and operational surface
warningAlias management becomes more complex with separate read/wri
warningAlias management becomes more complex with separate read/write indexes
Projection lag creates a read-after-write window where users
criticalProjection 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
Projection rebuild after schema change can take hours or day
criticalProjection 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
Missing partition for current time window causes all INSERTs
criticalMissing 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
6Referenced Intelligence