DBRaven
Full ReviewModerate Readinessdraft

Architecture Review: Two-Sided Marketplace Platform

A two-sided marketplace architecture serving buyers, sellers, listings, transactions, search, and notifications from a shared infrastructure, where multiple independent domains must coordinate without tight coupling. Event sourcing captures every state transition; the saga pattern orchestrates multi-step transactions (create order, reserve inventory, charge payment, notify seller) with compensating transactions for partial failures. Kafka decouples domain event publication from consumption; RabbitMQ handles notification fanout; Elasticsearch serves listing search; Redis caches listing display and session state.

Evidence Confidence

Moderate

strong

Executive Summary

Two-Sided Marketplace Platform: moderate operational readiness (80% evidence confidence). 0 architectural strengths identified, 5 operational risks to manage. Primary concern: Cascading Failure. Requires Advanced operational maturity.

Readiness Rationale

Overall moderate readiness across 8 dimensions. Limited: scaling, team maturity. Strong: migration, observability, failure recovery.

Key Concerns

  • !Cascading Failure
  • !Hot Partition

Key Strengths

  • +Architecture is well-defined for the marketplace platform problem profile

8

Assessments

5

Tradeoffs

6

Sections

11

Recommendations

Readiness Assessments

8

Architectural Tradeoffs

5

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 1 node. (Marketplace Mixed)

High

Monitor: Cascading Failure

risk_monitoring

A failure or degradation in one service causes increased load, held resources, or error propagation in its callers, which in turn degrade their callers, until the failure front propagates through the entire dependency graph and brings down services with no direct dependency on the original failure point.

Affects 0 nodes

High

Implement: Monitor read hotspot signals

observability

Seed 'Read Hotspot Saturation' identifies 3 metrics relevant to hot_partition. Execution preview confirms this risk manifests under modelled load.

Metrics to instrument: partition_qps, p99_latency_ms, cache_hit_rate

Moderate

Monolithic marketplace application with single database → Event-driven marketplace with Kafka + saga-based checkout flow

migration_planning

Trigger: Checkout failures from payment provider unavailability causing full transaction rollback and user-facing errors; need for asynchronous notification delivery; listing search performance insufficient from PostgreSQL full-text search. Migrate from 'Monolithic marketplace application with single database' to 'Event-driven marketplace with Kafka + saga-based checkout flow'. Introduce the outbox pattern and Kafka event publishing before the saga orchestration layer. Validate event delivery reliability before building compensating transaction logic on top of it.

Saga implementation requires designing and testing all compensation paths: untested compensation logic fails exactly when it is most needed; Kafka adds operational complexity that small teams may not be ready to operate

Moderate

PostgreSQL full-text search for listing discovery → Elasticsearch for listing search with CDC-based indexing

migration_planning

Trigger: Listing search p99 > 1s; faceted navigation (category + price + location + rating) not supportable in PostgreSQL without full-table scans; ranking algorithm requiring feature vectors that PostgreSQL cannot efficiently support. Migrate from 'PostgreSQL full-text search for listing discovery' to 'Elasticsearch for listing search with CDC-based indexing'. Run the Elasticsearch index in shadow mode (populated but not serving traffic) for 2 weeks before cutting over search traffic. Validate that listing updates propagate within the expected SLA window during the shadow period.

Elasticsearch index must be initially populated from PostgreSQL before CDC takes over: initial sync must complete without data loss; Search index staleness during CDC consumer lag must be explicitly communicated in the search UX

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: OLTP Analytics Queries → OLTP + OLAP Separation

evolution_planning

Evolution from Unified OLTP + Analytics on PostgreSQL → Separated OLTP (PostgreSQL) + OLAP (ClickHouse/Snowflake)

Migration complexity: medium. Rollback: always.

oltp-analytics-to-separated
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
Low

Monitor threshold: Tier 1: Viral Listing Thundering Herd

scaling_monitoring

Signal: Redis cache miss spike visible in monitoring; PostgreSQL query rate spiking for listing reads despite stable write volume; p99 listing API latency > 500ms during traffic spike events

Bottleneck: Cache TTL expiry on hot listings during peak traffic: all concurrent requests bypass cache simultaneously. Evolution: Implement staggered TTL jitter on listing cache entries; use probabilistic early refresh (refresh before TTL expiry when remaining TTL < 20% and request rate is high); implement single-flight/request coalescing at the application layer to collapse concurrent cache misses into a single database read

Low

Monitor threshold: Tier 2: Checkout Saga Contention

scaling_monitoring

Signal: Saga compensation events appearing in order event log; checkout p99 > 2s; pg_locks showing contended rows on inventory_reservations table; idempotency key conflicts increasing in payment service logs

Bottleneck: Concurrent checkout transactions competing for the same inventory rows; saga timeout thresholds too aggressive. Evolution: Increase inventory reservation table partition count; tune saga step timeout to 2x the observed p99 for each step under load; implement a per-listing checkout serialization queue to prevent N concurrent sagas competing for the same inventory

Scaling Pressure Signals

8

Redis cache miss spike visible in monitoring; PostgreSQL query rate spiking for listing reads despite stable write volume; p99 listing API latency > 500ms during traffic spike events

Threshold

Tier 1: Viral Listing Thundering Herd

Likely Bottleneck

Cache TTL expiry on hot listings during peak traffic: all concurrent requests bypass cache simultaneously

Recommended Evolution

Implement staggered TTL jitter on listing cache entries; use probabilistic early refresh (refresh before TTL expiry when remaining TTL < 20% and request rate is high); implement single-flight/request coalescing at the application layer to collapse concurrent cache misses into a single database read

Saga compensation events appearing in order event log; checkout p99 > 2s; pg_locks showing contended rows on inventory_reservations table; idempotency key conflicts increasing in payment service logs

Threshold

Tier 2: Checkout Saga Contention

Likely Bottleneck

Concurrent checkout transactions competing for the same inventory rows; saga timeout thresholds too aggressive

Recommended Evolution

Increase inventory reservation table partition count; tune saga step timeout to 2x the observed p99 for each step under load; implement a per-listing checkout serialization queue to prevent N concurrent sagas competing for the same inventory

RabbitMQ queue depth > 100k messages; notification delivery latency > 5 minutes; downstream notification provider (SendGrid, FCM) rate limit errors in consumer logs; dead-letter queue receiving messages from retry exhaustion

Threshold

Tier 3: Notification Queue Backlog

Likely Bottleneck

Notification consumer throughput insufficient for event fanout rate; or downstream provider rate limiting

Recommended Evolution

Add notification consumer replicas; implement consumer-side rate limiting against downstream provider quotas; tune RabbitMQ prefetch count to prevent consumer overload on recovery; implement dead-letter queue with manual review tooling

Evidence:elasticsearch-reindexing-pressurekafka-consumer-lag-cascade

Database connection pool exhausted by combination of checkout + search + listing writes all competing for the same PostgreSQL pool; single PostgreSQL primary CPU > 80% sustained; domain boundaries in code becoming unclear as direct table access crosses service lines

Threshold

Tier 4: Domain Service Decomposition Pressure

Likely Bottleneck

Shared PostgreSQL primary unable to serve multiple domain workloads simultaneously without resource contention

Recommended Evolution

Decompose into separate PostgreSQL databases per domain (listings, orders, payments, users) using the database-per-service pattern; each domain has its own connection pool; cross-domain data access goes through events, not direct database queries

Evidence:elasticsearch-reindexing-pressurekafka-consumer-lag-cascade

Redis cache miss spike visible in monitoring; PostgreSQL query rate spiking for listing reads despite stable write volume; p99 listing API latency > 500ms during traffic spike events

Threshold

Escalation trigger: Cache TTL expiry on hot listings during peak traffic: all concurrent requests bypass cache simultaneously

Likely Bottleneck

Tier 1: Viral Listing Thundering Herd

Recommended Evolution

Monitor: partition_qps, p99_latency_ms, cache_hit_rate

Saga compensation events appearing in order event log; checkout p99 > 2s; pg_locks showing contended rows on inventory_reservations table; idempotency key conflicts increasing in payment service logs

Threshold

Escalation trigger: Concurrent checkout transactions competing for the same inventory rows; saga timeout thresholds too aggressive

Likely Bottleneck

Tier 2: Checkout Saga Contention

Recommended Evolution

Monitor: partition_qps, p99_latency_ms, cache_hit_rate

RabbitMQ queue depth > 100k messages; notification delivery latency > 5 minutes; downstream notification provider (SendGrid, FCM) rate limit errors in consumer logs; dead-letter queue receiving messages from retry exhaustion

Threshold

Escalation trigger: Notification consumer throughput insufficient for event fanout rate; or downstream provider rate limiting

Likely Bottleneck

Tier 3: Notification Queue Backlog

Recommended Evolution

Monitor: partition_qps, p99_latency_ms, cache_hit_rate

Database connection pool exhausted by combination of checkout + search + listing writes all competing for the same PostgreSQL pool; single PostgreSQL primary CPU > 80% sustained; domain boundaries in code becoming unclear as direct table access crosses service lines

Threshold

Escalation trigger: Shared PostgreSQL primary unable to serve multiple domain workloads simultaneously without resource contention

Likely Bottleneck

Tier 4: Domain Service Decomposition Pressure

Recommended Evolution

Monitor: partition_qps, p99_latency_ms, cache_hit_rate

Migration Readiness

12

Migration Stages

3
Stage

Monolithic marketplace application with single database → Event-driven marketplace with Kafka + saga-based checkout flow

info

Migration trigger: Checkout failures from payment provider unavailability causing full transaction rollback and user-facing errors; need for asynchronous notification delivery; listing search performance insufficient from PostgreSQL full-text search

Stage

PostgreSQL full-text search for listing discovery → Elasticsearch for listing search with CDC-based indexing

info

Migration trigger: Listing search p99 > 1s; faceted navigation (category + price + location + rating) not supportable in PostgreSQL without full-table scans; ranking algorithm requiring feature vectors that PostgreSQL cannot efficiently support

Stage

Monolithic PostgreSQL serving all domain writes → Domain-separated databases with event-based cross-domain data propagation

info

Migration trigger: Domain teams stepping on each other's schema migrations; database resource contention across domains (listing writes vs checkout transactions vs analytics); need to independently scale checkout volume without scaling listing read capacity

!

Risks

9
Risk

Saga implementation requires designing and testing all compe

warning

Saga implementation requires designing and testing all compensation paths: untested compensation logic fails exactly when it is most needed

Risk

Kafka adds operational complexity that small teams may not b

warning

Kafka adds operational complexity that small teams may not be ready to operate

Risk

Elasticsearch index must be initially populated from Postgre

warning

Elasticsearch index must be initially populated from PostgreSQL before CDC takes over: initial sync must complete without data loss

Risk

Search index staleness during CDC consumer lag must be expli

warning

Search index staleness during CDC consumer lag must be explicitly communicated in the search UX

Risk

Cross-domain queries that were previously JOIN operations mu

warning

Cross-domain queries that were previously JOIN operations must become event-driven denormalized data or API calls: significant application refactoring required

Risk

Domain event schema contracts must be versioned and maintain

warning

Domain event schema contracts must be versioned and maintained: breaking changes require coordinated multi-service deployment

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

Cross-service workflows that previously used database transa

critical

Cross-service workflows that previously used database transactions now require Saga orchestration. Mitigation: Design idempotent event handlers; implement compensating transactions for every multi-step workflow; test failure injection in staging

modular-monolith-to-event-driven

Review Sections

6

Referenced Intelligence

elasticsearchkafkapostgresqlrabbitmqredisburst-traffic-cold-cache-stampedeconnection-pool-growth-with-user-scalecqrs-projection-lag-expansioncross-region-stale-read-windowdistributed-cache-invalidation-failureelasticsearch-reindexing-pressureevent-replay-storm-recoverykafka-consumer-lag-cascademulti-tenant-noisy-neighborpartition-hotspot-amplificationpostgresql-replication-lag-surgequery-cost-without-indexesrabbitmq-queue-backlog-saturationread-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-cqrsmodular-monolith-to-event-drivenoltp-analytics-to-separatedpostgresql-to-partitionedrabbitmq-to-kafkasingle-cache-to-distributedsingle-region-to-multi-regionarchitecture-evolutionauditabilitybtree-indexingcache-invalidationcap-theoremconsistency-modelscqrs-operationalevent-sourcingeventual-consistencykafka-consumer-lagmulti-tenancynormalizationoltp-vs-olappartition-hotspotsquery-planningqueue-backlogreplication-lagsearch-systemsvector-databaseswrite-amplification