一键导入
system-design-decisions
Scalability patterns, CAP theorem, database selection, caching
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scalability patterns, CAP theorem, database selection, caching
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
MADR format, decision log best practices, superseding decisions
AWS service selection, well-architected lens, cost patterns
Managed vs self-hosted, multi-cloud, egress costs
Docker, Kubernetes, ECS, Fly.io, Railway — when to use each
You are a senior backend engineer operating production-grade services under strict architectural and reliability constraints. Use when routes, controllers, services, repositories, express middleware, or prisma database access.
Use when the user wants to design a mobile app, create screens, build UI, or interact with their Sleek projects. Covers high-level requests ("design an app that does X") and specific ones ("list my projects", "create a new project", "screenshot that screen").
| name | system-design-decisions |
| description | Scalability patterns, CAP theorem, database selection, caching |
Define your access patterns FIRST. Every database decision flows from this.
| Pattern | Right DB type |
|---|---|
| Look up by primary key, high throughput | Key-value (DynamoDB, Redis) |
| Complex queries, joins, ACID transactions | Relational (PostgreSQL, MySQL) |
| Flexible schema, document storage | Document (MongoDB, Firestore) |
| Full-text search | Search engine (Elasticsearch, Typesense, Meilisearch) |
| Time-series metrics | Time-series (InfluxDB, TimescaleDB, Prometheus) |
| Graph relationships | Graph (Neo4j, Amazon Neptune) |
| Analytics / OLAP | Columnar (ClickHouse, BigQuery, Redshift) |
Default to PostgreSQL unless you have a specific reason not to. It handles relational, JSON (JSONB), full-text search, and time-series adequately at most scales.
In real systems, the choice is usually CP vs AP, not about ignoring partition tolerance:
Eventual consistency is fine for most read-heavy features. Use strong consistency only where the business actually requires it.
Design services to be stateless from day 1. Move state to Redis/DB. This makes horizontal scaling trivial later.
| Use sync when | Use async (queues) when |
|---|---|
| Response needed immediately | Response can be delivered later |
| Operation is fast (< 1s) | Operation is slow (email, ML inference, video processing) |
| Strong consistency required | Eventual consistency is acceptable |
Queue everything that doesn't need an immediate response. This decouples services and absorbs load spikes.
Modular Monolith first — keep modules decoupled inside one deployment. Extract to services only when you have a concrete reason.
| Need | Approach |
|---|---|
| Standard CRUD / REST | REST + OpenAPI spec |
| Complex queries / flexible client needs | GraphQL |
| Real-time, bidirectional | WebSockets or SSE |
| High-throughput internal services | gRPC |
| Event-driven between services | AsyncAPI + message broker |
REST is the right default. GraphQL has real value for product APIs with many consumers. gRPC shines for internal service-to-service calls.