High-Performance Backend Service Development
This skill provides battle-tested patterns, architecture guidance, and implementation best practices
for building production-grade, high-performance backend services in Java, Rust, and Go.
It includes a 技术选型决策矩阵 (tech stack decision matrix) covering 40+ real-world business scenarios,
and an interactive workflow to help users land on the right technology combination for their specific needs.
Workflow: How to Use This Skill
Phase 1: Gather Context (Ask the User)
Before making any technology recommendation, collect the following information from the user.
Use clear, structured questions. If the user has already provided some of this info in their message,
skip those questions and confirm what you understood.
Required questions (ask all that are not already answered):
业务场景 (Business Scenario)
- What kind of service are you building? (e.g., e-commerce order service, chat system, API gateway, IoT device gateway, trading engine)
- What is the core business problem this service solves?
规模与性能要求 (Scale & Performance)
- Expected QPS / concurrent connections? (low: <1K, medium: 1K-10K, high: 10K-100K, very-high: >100K)
- Latency requirements? (high-tolerance: >500ms, medium: 100-500ms, low: 10-100ms, ultra-low: <10ms)
- Data consistency model? (strong consistency / eventual consistency / mix)
技术偏好与约束 (Tech Preferences & Constraints)
- Do you have a language preference? (Java / Rust / Go / open to suggestions)
- Any existing infrastructure or tech stack constraints? (e.g., already using Kafka, must deploy on K8s, team only knows Java)
- Is this a greenfield project or adding to an existing system?
特殊需求 (Special Requirements)
- Real-time communication needs? (WebSocket, SSE, gRPC streaming)
- Multi-tenancy requirements?
- Compliance / audit trail needs?
- Edge deployment or resource-constrained environments?
Phase 2: Match Against the Tech Stack Matrix
After gathering user input, search the tech stack decision matrix CSV for matching scenarios.
Step 1: Read the CSV
Read references/tech-stack-matrix.csv and parse it.
Step 2: Score and rank rows
For each row in the CSV, calculate a relevance score based on how many user-provided keywords
appear in these columns: scenario, tags, notes, scale, latency_req, consistency_req, language.
Scoring rules:
- Exact tag match in
tags column: +3 points
- Keyword found in
scenario or notes: +2 points
- Match on
scale level: +2 points
- Match on
latency_req: +2 points
- Match on
consistency_req: +1 point
- Match on
language (if user specified): +3 points
- Partial keyword overlap: +1 point
Step 3: Select top matches
Take the top 1-3 rows by score. These are the reference architectures to present to the user.
Phase 3: Generate the Recommendation
Based on the matched rows, synthesize a technology recommendation structured as follows:
## 推荐技术方案 (Recommended Tech Stack)
### 方案概述 (Overview)
- 参考场景: [matched scenario name(s)]
- 推荐语言/框架: [language + framework]
- 核心理由: [why this combination fits]
### 技术选型详情 (Stack Details)
| 层级 | 选择 | 理由 |
|------|------|------|
| 语言/框架 | ... | ... |
| 通信协议 | ... | ... |
| 主数据库 | ... | ... |
| 辅助存储 | ... | ... |
| 缓存方案 | ... | ... |
| 消息中间件 | ... | ... |
| 搜索引擎 | ... | ... |
| API风格 | ... | ... |
| 认证方案 | ... | ... |
| 可观测性 | ... | ... |
| 部署方案 | ... | ... |
### 架构模式 (Architecture Pattern)
[Describe the recommended architecture pattern and why]
### 弹性设计 (Resilience)
[Circuit breaker, retry, bulkhead, etc. specific to this scenario]
### 关键库/依赖 (Key Libraries)
[List with brief explanation of each]
### 潜在风险与权衡 (Risks & Trade-offs)
[Be honest about what you're trading off with this choice]
### 如果规模增长... (Scaling Path)
[How to evolve this architecture as load grows 10x]
Phase 4: Deep Dive with Reference Files
After presenting the recommendation, offer to go deeper. Read the relevant reference file
based on the recommended language:
- Java + Spring Boot 3 + Microservices → read
references/java-springboot.md
- Rust (Axum, Actix-web, Tokio) → read
references/rust.md
- Go (Gin, stdlib, gRPC) → read
references/go.md
Then provide:
- Production-ready code scaffolding for the recommended architecture
- Specific configuration templates (application.yml, Cargo.toml, etc.)
- Testing strategy tailored to the scenario
- Dockerfile and deployment manifests
Handling Ambiguous or Multi-Language Requests
If the user's scenario maps to multiple languages (e.g., a polyglot microservice system), present
multiple matched rows and explain the trade-offs. For example, a trading platform might use:
- Rust for the matching engine (ultra-low latency)
- Go for the API gateway (high throughput, fast development)
- Java for the clearing/settlement service (complex business logic, strong framework support)
Read all relevant reference files and provide guidance for each component.
Handling "I Just Want to Code" Requests
If the user skips the Q&A and says something like "help me write a REST API in Go" or
"set up a Spring Boot microservice", respect that:
- Skip Phase 1-2, go directly to the reference file for the specified language
- Read the relevant
references/*.md file
- Provide production-quality code following the patterns in that reference
- Still apply the universal principles below
Universal High-Performance Principles
These apply across all three languages. Language-specific implementation details are in the reference files.
Architecture Patterns
Service Decomposition
- Decompose by business capability, not by technical layer
- Each service owns its data (Database-per-Service pattern)
- Prefer asynchronous communication (event-driven) over synchronous RPC for cross-service calls
when eventual consistency is acceptable
- Use API Gateway as the single entry point for external clients
Communication Patterns
- Synchronous: REST (OpenAPI 3.x) for external APIs, gRPC (protobuf) for internal service-to-service
- Asynchronous: Event-driven via message brokers (Kafka, RabbitMQ, NATS)
- Use the Outbox Pattern to guarantee at-least-once delivery without distributed transactions
- Implement idempotency keys for all write operations
Resilience
- Circuit Breaker: prevent cascade failures (fail-fast when downstream is unhealthy)
- Bulkhead: isolate failure domains (separate thread pools / connection pools per dependency)
- Retry with exponential backoff + jitter for transient failures
- Timeout every external call — no unbounded waits
- Graceful degradation: serve partial/cached results when non-critical dependencies fail
Data Layer
Database Selection
- OLTP with strong consistency → PostgreSQL (preferred), MySQL
- High-throughput key-value → Redis, DragonflyDB
- Document store → MongoDB (when schema flexibility outweighs join needs)
- Time-series → TimescaleDB, ClickHouse
- Search → Elasticsearch, Meilisearch
Connection Pooling
- Always use connection pools; never create connections per-request
- Size the pool based on:
pool_size ≈ (core_count * 2) + effective_spindle_count
- Monitor pool saturation; alert when wait time exceeds P95 threshold
Caching Strategy
- L1 (in-process): small, hot data with short TTL — Caffeine (Java), moka (Rust), freecache (Go)
- L2 (distributed): Redis/Valkey with consistent hashing
- Cache invalidation: prefer event-driven invalidation over TTL-only
- Protect against cache stampede with request coalescing (singleflight in Go, similar elsewhere)
Observability (The Three Pillars)
- Logging: JSON-formatted, correlation IDs, never log PII
- Metrics: RED (Rate/Errors/Duration) for services, USE (Utilization/Saturation/Errors) for resources
- Tracing: OpenTelemetry SDK, W3C Trace Context propagation, strategic sampling
Performance Engineering
Common Bottlenecks (check in this order)
- N+1 queries / missing indexes → check query plans
- Serialization overhead → consider binary formats (protobuf, MessagePack)
- Connection pool exhaustion → monitor wait times
- GC pressure (Java/Go) → tune GC, reduce allocations
- Lock contention → use lock-free data structures or sharding
- Inefficient I/O → batch operations, use async I/O
Concurrency Models
- Java: Virtual Threads (Project Loom, JDK 21+) for I/O-bound; ForkJoinPool for CPU-bound
- Rust: Tokio async runtime for I/O-bound; Rayon for CPU-bound parallelism
- Go: Goroutines + channels; errgroup for structured concurrency
API Design
- OpenAPI 3.1 spec as the contract for REST APIs
- Cursor-based pagination (not offset) for large datasets
- Token bucket or sliding window rate limiting; return
429 with Retry-After
- Consistent error response format with error code, message, details, and request_id
Security Baseline
- AuthN: JWT (short-lived) or OAuth2/OIDC; AuthZ: RBAC or ABAC at middleware
- TLS everywhere, mTLS for internal service-to-service
- Input validation on every boundary; dependency scanning in CI
Deployment
- Container-first: multi-stage Dockerfiles for minimal images
- Health endpoints:
/health/live + /health/ready
- Graceful shutdown: drain in-flight requests before termination
- 12-Factor App configuration principles
Language Selection Quick Reference
| Criteria |
Java + Spring Boot 3 |
Rust |
Go |
| Best for |
Complex business logic, enterprise |
Ultra-low-latency, safety-critical |
Infra, cloud-native, network services |
| Dev speed |
Fast (rich frameworks) |
Slower (borrow checker) |
Fast (simple language) |
| Memory |
Higher (JVM) |
Lowest |
Low |
| Latency |
Good (Virtual Threads) |
Best |
Very good |
| Ecosystem |
Massive |
Growing fast |
Strong for infra/cloud |
Source: GChenSi-2/high-perf-backend-skill — distributed by TomeVault.
1---2name: gchensi-2-high-perf-backend-skill-high-perf-backend3description: High-Performance Backend Service Development4---56# High-Performance Backend Service Development78This skill provides battle-tested patterns, architecture guidance, and implementation best practices9for building production-grade, high-performance backend services in **Java**, **Rust**, and **Go**.1011It includes a **技术选型决策矩阵** (tech stack decision matrix) covering 40+ real-world business scenarios,12and an interactive workflow to help users land on the right technology combination for their specific needs.1314---1516## Workflow: How to Use This Skill1718### Phase 1: Gather Context (Ask the User)1920Before making any technology recommendation, collect the following information from the user.21Use clear, structured questions. If the user has already provided some of this info in their message,22skip those questions and confirm what you understood.2324**Required questions** (ask all that are not already answered):25261. **业务场景 (Business Scenario)**27 - What kind of service are you building? (e.g., e-commerce order service, chat system, API gateway, IoT device gateway, trading engine)28 - What is the core business problem this service solves?29302. **规模与性能要求 (Scale & Performance)**31 - Expected QPS / concurrent connections? (low: <1K, medium: 1K-10K, high: 10K-100K, very-high: >100K)32 - Latency requirements? (high-tolerance: >500ms, medium: 100-500ms, low: 10-100ms, ultra-low: <10ms)33 - Data consistency model? (strong consistency / eventual consistency / mix)34353. **技术偏好与约束 (Tech Preferences & Constraints)**36 - Do you have a language preference? (Java / Rust / Go / open to suggestions)37 - Any existing infrastructure or tech stack constraints? (e.g., already using Kafka, must deploy on K8s, team only knows Java)38 - Is this a greenfield project or adding to an existing system?39404. **特殊需求 (Special Requirements)**41 - Real-time communication needs? (WebSocket, SSE, gRPC streaming)42 - Multi-tenancy requirements?43 - Compliance / audit trail needs?44 - Edge deployment or resource-constrained environments?4546### Phase 2: Match Against the Tech Stack Matrix4748After gathering user input, search the tech stack decision matrix CSV for matching scenarios.4950**Step 1: Read the CSV**51Read `references/tech-stack-matrix.csv` and parse it.5253**Step 2: Score and rank rows**54For each row in the CSV, calculate a relevance score based on how many user-provided keywords55appear in these columns: `scenario`, `tags`, `notes`, `scale`, `latency_req`, `consistency_req`, `language`.5657Scoring rules:58- Exact tag match in `tags` column: +3 points59- Keyword found in `scenario` or `notes`: +2 points60- Match on `scale` level: +2 points61- Match on `latency_req`: +2 points62- Match on `consistency_req`: +1 point63- Match on `language` (if user specified): +3 points64- Partial keyword overlap: +1 point6566**Step 3: Select top matches**67Take the top 1-3 rows by score. These are the **reference architectures** to present to the user.6869### Phase 3: Generate the Recommendation7071Based on the matched rows, synthesize a technology recommendation structured as follows:7273```74## 推荐技术方案 (Recommended Tech Stack)7576### 方案概述 (Overview)77- 参考场景: [matched scenario name(s)]78- 推荐语言/框架: [language + framework]79- 核心理由: [why this combination fits]8081### 技术选型详情 (Stack Details)82| 层级 | 选择 | 理由 |83|------|------|------|84| 语言/框架 | ... | ... |85| 通信协议 | ... | ... |86| 主数据库 | ... | ... |87| 辅助存储 | ... | ... |88| 缓存方案 | ... | ... |89| 消息中间件 | ... | ... |90| 搜索引擎 | ... | ... |91| API风格 | ... | ... |92| 认证方案 | ... | ... |93| 可观测性 | ... | ... |94| 部署方案 | ... | ... |9596### 架构模式 (Architecture Pattern)97[Describe the recommended architecture pattern and why]9899### 弹性设计 (Resilience)100[Circuit breaker, retry, bulkhead, etc. specific to this scenario]101102### 关键库/依赖 (Key Libraries)103[List with brief explanation of each]104105### 潜在风险与权衡 (Risks & Trade-offs)106[Be honest about what you're trading off with this choice]107108### 如果规模增长... (Scaling Path)109[How to evolve this architecture as load grows 10x]110```111112### Phase 4: Deep Dive with Reference Files113114After presenting the recommendation, offer to go deeper. Read the relevant reference file115based on the recommended language:116117- Java + Spring Boot 3 + Microservices → read `references/java-springboot.md`118- Rust (Axum, Actix-web, Tokio) → read `references/rust.md`119- Go (Gin, stdlib, gRPC) → read `references/go.md`120121Then provide:122- Production-ready code scaffolding for the recommended architecture123- Specific configuration templates (application.yml, Cargo.toml, etc.)124- Testing strategy tailored to the scenario125- Dockerfile and deployment manifests126127---128129## Handling Ambiguous or Multi-Language Requests130131If the user's scenario maps to multiple languages (e.g., a polyglot microservice system), present132multiple matched rows and explain the trade-offs. For example, a trading platform might use:133- Rust for the matching engine (ultra-low latency)134- Go for the API gateway (high throughput, fast development)135- Java for the clearing/settlement service (complex business logic, strong framework support)136137Read all relevant reference files and provide guidance for each component.138139---140141## Handling "I Just Want to Code" Requests142143If the user skips the Q&A and says something like "help me write a REST API in Go" or144"set up a Spring Boot microservice", respect that:1451461. Skip Phase 1-2, go directly to the reference file for the specified language1472. Read the relevant `references/*.md` file1483. Provide production-quality code following the patterns in that reference1494. Still apply the universal principles below150151---152153## Universal High-Performance Principles154155These apply across all three languages. Language-specific implementation details are in the reference files.156157### Architecture Patterns158159**Service Decomposition**160- Decompose by business capability, not by technical layer161- Each service owns its data (Database-per-Service pattern)162- Prefer asynchronous communication (event-driven) over synchronous RPC for cross-service calls163 when eventual consistency is acceptable164- Use API Gateway as the single entry point for external clients165166**Communication Patterns**167- Synchronous: REST (OpenAPI 3.x) for external APIs, gRPC (protobuf) for internal service-to-service168- Asynchronous: Event-driven via message brokers (Kafka, RabbitMQ, NATS)169- Use the Outbox Pattern to guarantee at-least-once delivery without distributed transactions170- Implement idempotency keys for all write operations171172**Resilience**173- Circuit Breaker: prevent cascade failures (fail-fast when downstream is unhealthy)174- Bulkhead: isolate failure domains (separate thread pools / connection pools per dependency)175- Retry with exponential backoff + jitter for transient failures176- Timeout every external call — no unbounded waits177- Graceful degradation: serve partial/cached results when non-critical dependencies fail178179### Data Layer180181**Database Selection**182- OLTP with strong consistency → PostgreSQL (preferred), MySQL183- High-throughput key-value → Redis, DragonflyDB184- Document store → MongoDB (when schema flexibility outweighs join needs)185- Time-series → TimescaleDB, ClickHouse186- Search → Elasticsearch, Meilisearch187188**Connection Pooling**189- Always use connection pools; never create connections per-request190- Size the pool based on: `pool_size ≈ (core_count * 2) + effective_spindle_count`191- Monitor pool saturation; alert when wait time exceeds P95 threshold192193**Caching Strategy**194- L1 (in-process): small, hot data with short TTL — Caffeine (Java), moka (Rust), freecache (Go)195- L2 (distributed): Redis/Valkey with consistent hashing196- Cache invalidation: prefer event-driven invalidation over TTL-only197- Protect against cache stampede with request coalescing (singleflight in Go, similar elsewhere)198199### Observability (The Three Pillars)200201- **Logging**: JSON-formatted, correlation IDs, never log PII202- **Metrics**: RED (Rate/Errors/Duration) for services, USE (Utilization/Saturation/Errors) for resources203- **Tracing**: OpenTelemetry SDK, W3C Trace Context propagation, strategic sampling204205### Performance Engineering206207**Common Bottlenecks (check in this order)**2081. N+1 queries / missing indexes → check query plans2092. Serialization overhead → consider binary formats (protobuf, MessagePack)2103. Connection pool exhaustion → monitor wait times2114. GC pressure (Java/Go) → tune GC, reduce allocations2125. Lock contention → use lock-free data structures or sharding2136. Inefficient I/O → batch operations, use async I/O214215**Concurrency Models**216- Java: Virtual Threads (Project Loom, JDK 21+) for I/O-bound; ForkJoinPool for CPU-bound217- Rust: Tokio async runtime for I/O-bound; Rayon for CPU-bound parallelism218- Go: Goroutines + channels; errgroup for structured concurrency219220### API Design221222- OpenAPI 3.1 spec as the contract for REST APIs223- Cursor-based pagination (not offset) for large datasets224- Token bucket or sliding window rate limiting; return `429` with `Retry-After`225- Consistent error response format with error code, message, details, and request_id226227### Security Baseline228229- AuthN: JWT (short-lived) or OAuth2/OIDC; AuthZ: RBAC or ABAC at middleware230- TLS everywhere, mTLS for internal service-to-service231- Input validation on every boundary; dependency scanning in CI232233### Deployment234235- Container-first: multi-stage Dockerfiles for minimal images236- Health endpoints: `/health/live` + `/health/ready`237- Graceful shutdown: drain in-flight requests before termination238- 12-Factor App configuration principles239240### Language Selection Quick Reference241242| Criteria | Java + Spring Boot 3 | Rust | Go |243|---|---|---|---|244| Best for | Complex business logic, enterprise | Ultra-low-latency, safety-critical | Infra, cloud-native, network services |245| Dev speed | Fast (rich frameworks) | Slower (borrow checker) | Fast (simple language) |246| Memory | Higher (JVM) | Lowest | Low |247| Latency | Good (Virtual Threads) | Best | Very good |248| Ecosystem | Massive | Growing fast | Strong for infra/cloud |249250---251> Source: [GChenSi-2/high-perf-backend-skill](https://github.com/GChenSi-2/high-perf-backend-skill) — distributed by [TomeVault](https://tomevault.io).252<!-- tomevault:4.0:skill_md:2026-06-15 -->