Question #7 of 60•Databases•Hard• ~3 min read

Which database should you choose for User Data, Transactions, Logs, and Analytics?

Executive Takeaway

Analyze the database trade-offs of PostgreSQL, MongoDB, Cassandra, Druid, and Elasticsearch against real-world enterprise data flows.

Architectural Breakdown & AnalysisFAANG Aligned

No single database engine fits all data patterns. High-scale architecture decouples storage based on throughput, query model, and consistency needs:

Data DomainPreferred DatabaseKey Technical Reason
User Profiles / SettingsMongoDB / PostgreSQLFlexible JSON document nesting, fast indexed lookups, easy schema evolution.
Payments / LedgerPostgreSQL (WAL enabled)Strict ACID compliance, multi-table transactions, zero loss guarantees.
App Logs / TelemetryCassandra / ClickHouseLSM-tree append-only write engine handles millions of writes/sec without locking.
Real-Time AnalyticsApache Druid / PinocchioColumnar aggregation layout for sub-second slicing/dicing across billions of events.
Product Catalog SearchElasticsearchInverted index algorithm enables fuzzy matching, full-text search, and facet scoring.
NOTE — Polyglot Persistence Architecture

Do not force a single database for everything. Route payments to PostgreSQL, session state to Redis, stream logs to Cassandra, and replicate catalogs to Elasticsearch via Change Data Capture (CDC).

Previous QuestionHow does Amazon DynamoDB implement Partition Keys, LSIs, and GSIs?Next Question How do you achieve consistency across multiple microservices (Sagas vs. 2PC)?

Continue Learning on Being SDE

Explore deep-dive system architecture modules, low-level object-oriented designs, and interview cheat sheets.