1---2name: tech-matrix3description: Reference document for monopoly tech-matrix.4---56# MONOPOLY — Technology Decision Matrix78## Table of Contents91. Database Selection102. Cache Selection113. Message Queue / Event Streaming124. API Protocol135. Search Engine146. Object Storage157. Container Orchestration168. Load Balancer179. Observability Stack1810. CDN1920---2122## 1. Database Selection2324### Relational (SQL)2526| Database | Best For | Avoid When | Scale Ceiling |27|----------|----------|------------|---------------|28| **PostgreSQL** | Complex queries, JSONB, GIS, strong consistency, most default use cases | Ultra-high write throughput (>100K writes/s) | ~10TB single node; use Citus for horizontal |29| **MySQL / MariaDB** | Read-heavy apps, legacy systems, WordPress/Drupal ecosystem | Complex queries, full ACID at scale | ~10TB; use Vitess for sharding |30| **CockroachDB** | Global distributed SQL, geo-partitioning, multi-region | Simple single-region apps (overkill) | Petabyte-scale |31| **PlanetScale** | MySQL-compatible, serverless, branch-based workflow | Complex JOINs (foreign keys removed by design) | Very high — Vitess based |32| **Amazon Aurora** | AWS-native apps, managed PostgreSQL/MySQL, high availability | Non-AWS enprojectnments | Up to 128TB, 15 replicas |3334### NoSQL3536| Database | Best For | Avoid When | Scale Ceiling |37|----------|----------|------------|---------------|38| **MongoDB** | Flexible schema, document model, prototyping | Financial transactions requiring ACID | Petabyte-scale with sharding |39| **DynamoDB** | Key-value at massive scale, AWS-native, serverless, predictable latency | Complex queries, ad-hoc analytics, JOINs | Unlimited (AWS-managed) |40| **Cassandra** | Write-heavy, time-series, wide-column, geographically distributed | Read-heavy with complex queries | Petabyte-scale; used at Apple, Netflix |41| **Redis** | Cache, sessions, leaderboards, pub/sub, rate limiting | Primary data store for complex models | ~1TB per node; cluster for more |42| **Elasticsearch** | Full-text search, log aggregation, analytics | Primary database (durability risk) | Petabyte-scale with clusters |43| **InfluxDB** | Time-series metrics, IoT, monitoring data | General-purpose data | Very high write throughput |44| **Neo4j** | Graph data, social networks, recommendation engines, fraud detection | Non-graph data (overhead not worth it) | Billions of nodes |4546### Decision Framework4748```49Is your data relational (joins, foreign keys, transactions)?50 YES → Start with PostgreSQL51 NO → Continue below5253Is your primary access pattern key-value?54 YES, need extreme scale → DynamoDB or Cassandra55 YES, need speed/cache → Redis5657Is your data document-shaped (nested, flexible schema)?58 YES → MongoDB5960Is it time-series (metrics, logs, IoT)?61 YES → InfluxDB or TimescaleDB6263Is it graph (relationships are the data)?64 YES → Neo4j6566Is it search?67 YES → Elasticsearch / OpenSearch68```6970---7172## 2. Cache Selection7374| Technology | Best For | Max Single Node | Cluster Support |75|------------|----------|----------------|----------------|76| **Redis** | Sessions, leaderboards, pub/sub, complex data structures, Lua scripting | ~1TB RAM | Yes (Redis Cluster, Redis Sentinel) |77| **Memcached** | Simple key-value, multi-threaded, large object cache | ~64GB RAM | Yes (client-side sharding) |78| **Varnish** | HTTP reverse proxy cache, full-page caching | RAM bound | Limited |79| **CloudFront / CDN** | Static assets, edge caching globally | N/A (distributed) | Built-in global distribution |8081**Default recommendation: Redis** — more features, better ecosystem, active development.8283Use **Memcached** only when: you need multi-threading for CPU-bound caching workloads and don't need data structures beyond string.8485---8687## 3. Message Queue / Event Streaming8889| Technology | Model | Best For | Throughput | Retention |90|------------|-------|----------|------------|-----------|91| **Apache Kafka** | Log-based streaming | Event sourcing, high-throughput pipelines, replay, audit | Millions msg/s | Days to forever |92| **RabbitMQ** | AMQP message broker | Task queues, RPC, routing, fanout | 50K–100K msg/s | Until consumed |93| **AWS SQS** | Managed queue | AWS-native, simple task queue, serverless | Very high (managed) | Up to 14 days |94| **AWS SNS** | Pub/sub notification | Fan-out to many subscribers (email, SMS, Lambda, SQS) | Very high (managed) | No retention |95| **Google Pub/Sub** | Managed streaming | GCP-native, global, serverless | Very high (managed) | Up to 7 days |96| **Redis Pub/Sub** | In-memory pub/sub | Real-time notifications, low latency, fire-and-forget | Very high | None (no retention) |97| **NATS** | Lightweight messaging | IoT, microservices, low latency | Very high | JetStream adds retention |9899### Decision Matrix100101```102Need event replay / audit trail?103 YES → Kafka or Kinesis104105Need simple task queue with retries and DLQ?106 AWS shop → SQS107 Self-hosted → RabbitMQ108109Need real-time pub/sub with no persistence?110 Redis Pub/Sub or NATS111112Need fan-out to multiple consumers?113 Kafka (consumer groups) or SNS → SQS fan-out114115Need < 5 minutes guaranteed delivery, AWS-native, zero ops?116 SQS117118Volume > 1 million messages/second?119 Kafka (self-hosted) or Kinesis (managed)120```121122---123124## 4. API Protocol125126| Protocol | Best For | Avoid When |127|----------|----------|------------|128| **REST (HTTP/JSON)** | Public APIs, CRUD, browser clients, simplicity | Strict typing required; high-performance internal services |129| **GraphQL** | Complex client data requirements, mobile (reduce over-fetching), BFF pattern | Simple CRUD; not worth the complexity |130| **gRPC (HTTP/2 + Protobuf)** | Internal microservice communication, low latency, strict contracts, streaming | Public browser APIs (needs gRPC-web) |131| **WebSocket** | Real-time bidirectional (chat, live dashboards, multiplayer games) | One-way server push (use SSE instead) |132| **SSE (Server-Sent Events)** | Server → client push (notifications, live feeds) | Bidirectional communication |133| **GraphQL Subscriptions** | Real-time with GraphQL schema consistency | Simple push scenarios |134135**Default recommendation:**136- External / public: **REST**137- Internal service-to-service: **gRPC**138- Real-time features: **WebSocket** or **SSE**139140---141142## 5. Search Engine143144| Technology | Best For | Avoid When |145|------------|----------|------------|146| **Elasticsearch** | Full-text search, log analytics (ELK), complex aggregations | Simple lookups; operational overhead is high |147| **OpenSearch** | AWS-native Elasticsearch alternative | Non-AWS preferred setups |148| **Typesense** | Simple, fast full-text search, typo tolerance, easy ops | Complex aggregations at massive scale |149| **Algolia** | Managed search-as-a-service, fast setup, great UI | High volume (expensive); self-hosted preference |150| **Meilisearch** | Self-hosted, developer-friendly, fast relevancy | Enterprise-scale analytics |151| **PostgreSQL FTS** | Basic full-text search, already using PostgreSQL | High relevancy requirements or large datasets |152153**Rule of thumb:** Use PostgreSQL FTS under 1M documents. Move to Typesense or Elasticsearch above that.154155---156157## 6. Object Storage158159| Service | Best For | Egress Cost |160|---------|----------|------------|161| **AWS S3** | AWS-native apps, de facto standard, massive ecosystem | $0.09/GB (expensive) |162| **Cloudflare R2** | S3-compatible, **zero egress cost**, global | $0.00 egress |163| **GCS** | GCP-native | $0.12/GB |164| **Azure Blob** | Azure-native | $0.087/GB |165| **Backblaze B2** | Cost-sensitive, S3-compatible | Free with Cloudflare |166| **MinIO** | Self-hosted S3-compatible | Self-managed |167168**Cost optimization tip:** Use **Cloudflare R2** for user-facing media delivery (zero egress). Use **S3** for internal/AWS-integrated storage.169170---171172## 7. Container Orchestration173174| Technology | Best For | Avoid When |175|------------|----------|------------|176| **Kubernetes (K8s)** | Large teams, complex deployments, multi-cloud, full control | Small teams (ops overhead is very high) |177| **AWS ECS + Fargate** | AWS-native, serverless containers, simpler than K8s | Multi-cloud or K8s ecosystem tools needed |178| **AWS EKS** | Managed K8s on AWS, best of both | Small teams; Fargate may be enough |179| **GKE (Google)** | Best managed K8s, GCP-native, Autopilot mode | Non-GCP enprojectnments |180| **Docker Compose** | Local dev, small single-server deployments | Production at any meaningful scale |181| **Nomad** | HashiCorp ecosystem, simpler than K8s, multi-workload | K8s ecosystem tools required |182183**Startup default:** ECS + Fargate (zero cluster management).184**Scale default:** EKS or GKE once team > 5 engineers or services > 10.185186---187188## 8. Load Balancer189190| Technology | Layer | Best For |191|------------|-------|----------|192| **AWS ALB** | L7 (HTTP/HTTPS) | AWS apps, path-based routing, WebSocket, HTTP/2 |193| **AWS NLB** | L4 (TCP/UDP) | Ultra-low latency, static IP, non-HTTP protocols |194| **GCP GLB** | L7 global | GCP apps, global anycast, single IP worldwide |195| **Nginx** | L4/L7 | Self-hosted, reverse proxy, flexible config |196| **HAProxy** | L4/L7 | High performance self-hosted, advanced routing |197| **Cloudflare** | L7 global + DDoS | DDoS protection + CDN + load balancing combined |198| **Traefik** | L7 | Kubernetes-native, automatic SSL, service discovery |199200---201202## 9. Observability Stack203204### Metrics205| Tool | Best For |206|------|----------|207| **Prometheus + Grafana** | Self-hosted, open-source, Kubernetes-native |208| **Datadog** | Managed, APM + infra + logs unified, expensive |209| **CloudWatch** | AWS-native, zero setup, integrated with AWS services |210| **New Relic** | APM-focused, good for application-level insights |211212### Logging213| Tool | Best For |214|------|----------|215| **ELK Stack** (Elasticsearch + Logstash + Kibana) | Self-hosted, powerful, high volume |216| **Loki + Grafana** | Lightweight, Kubernetes-native, cheap |217| **Splunk** | Enterprise, compliance, expensive |218| **AWS CloudWatch Logs** | AWS-native, zero setup |219| **Datadog Logs** | Unified with metrics, expensive |220221### Distributed Tracing222| Tool | Best For |223|------|----------|224| **Jaeger** | Open-source, Kubernetes-native, OpenTelemetry |225| **Zipkin** | Simple, lightweight, good integrations |226| **AWS X-Ray** | AWS-native, integrates with Lambda, ECS |227| **Datadog APM** | Managed, unified with metrics and logs |228| **Honeycomb** | High-cardinality event-based observability |229230**Recommended open-source stack:** Prometheus + Grafana + Loki + Jaeger (all integrate via OpenTelemetry)231**Recommended managed stack:** Datadog (expensive but unified) or Grafana Cloud232233---234235## 10. CDN236237| Technology | Best For | Edge Locations |238|------------|----------|----------------|239| **Cloudflare** | DDoS protection + CDN + DNS, best free tier, edge workers | 300+ |240| **AWS CloudFront** | AWS-native, deep S3 and API GW integration | 450+ |241| **Akamai** | Enterprise, highest performance, expensive | 4000+ |242| **Fastly** | Real-time purging, streaming, VCL customization | 90+ |243| **Vercel Edge / Netlify** | Jamstack, frontend-first, zero config | 100+ |244245**Default recommendation:** Cloudflare for most use cases (best value, DDoS included, free SSL, Workers for edge compute).246247---248249## Scale Benchmarks Quick Reference250251| Technology | Write Throughput | Read Throughput | Notes |252|------------|-----------------|----------------|-------|253| PostgreSQL (single) | ~10K writes/s | ~50K reads/s | With connection pooling |254| PostgreSQL (replicas) | ~10K writes/s | ~200K reads/s | 4 replicas |255| MySQL (single) | ~15K writes/s | ~60K reads/s | |256| Cassandra | ~1M writes/s | ~500K reads/s | 10-node cluster |257| Redis | ~1M ops/s | ~1M ops/s | Single node in-memory |258| Kafka | ~1M msgs/s | ~1M msgs/s | Per partition |259| Elasticsearch | ~50K docs/s | ~10K queries/s | Per node |260| MongoDB | ~50K writes/s | ~100K reads/s | Per replica set |261262*All benchmarks are approximate and depend heavily on hardware, payload size, and query complexity.*263264265## Limitations266- This is a reference document and may not cover all edge cases. Always verify architectures before production.