1. Asynchronous Communication Pattern
| Aspect | Detail |
| Benefit | Caller does not block; throughput improves |
| Use For | Non-immediate work (notifications, indexing) |
| Watchout | Eventual consistency UX |
2. Response Compression Pattern
| Algo | When |
| gzip | Universal default |
| br (Brotli) | Static text; better ratio |
| zstd | Large dynamic payloads; fastest decompress |
| No compression | Already-compressed (images, video) |
3. Connection Pooling Pattern
| Param | Detail |
| maxConnections | Bounded by upstream capacity |
| minIdle | Warm pool to avoid cold-start |
| connectionTimeout | Wait time for free connection |
| maxLifetime | Recycle to avoid stale connections |
| idleTimeout | Close unused connections |
| Tools | HikariCP (JDBC), c3p0, pgbouncer |
4. Request Batching Pattern
| Aspect | Detail |
| Mechanism | Combine N small requests into one |
| Trigger | Time window OR batch size threshold |
| Use Cases | DB writes, API calls, log shipping, GraphQL DataLoader |
| Trade-off | Latency (wait) vs throughput |
Example: GraphQL DataLoader
const userLoader = new DataLoader(async (ids) => {
const users = await db.users.findByIds(ids);
return ids.map(id => users.find(u => u.id === id));
});
// 100 calls to userLoader.load(id) within tick → 1 SQL query for all 100
5. Lazy Loading Pattern
| Aspect | Detail |
| Definition | Defer loading data until accessed |
| Examples | JPA lazy fetch, lazy initialization, lazy import |
| Pitfall | N+1 query problem; LazyInitializationException |
6. Prefetching Pattern
| Aspect | Detail |
| Mechanism | Load data before it's actually requested (predicted) |
| Examples | Page prefetch, JOIN FETCH, Kafka consumer prefetch |
| Risk | Wasted bandwidth/memory if prediction wrong |
7. Resource Pooling Pattern
| Resource | Pool Type |
| DB Connections | HikariCP, pgbouncer |
| HTTP Clients | OkHttp, Apache HttpClient |
| Threads | ThreadPoolExecutor; virtual threads (Java 21+) |
| Buffers | Netty PooledByteBufAllocator |
| Object Pools | Apache Commons Pool |
8. Denormalization Pattern
| Aspect | Detail |
| Definition | Duplicate data to avoid joins |
| When | Read-heavy, latency-sensitive workloads |
| Cost | Sync complexity on writes; eventual consistency |
| Implementation | Materialized views, embedded documents (Mongo), CQRS read models |
9. Index Optimization Pattern
| Index Type | Use |
| B-Tree | Equality + range; default |
| Hash | Equality only; faster for large cardinality |
| GIN / GiST (Postgres) | Full-text, JSONB, geo |
| Composite | Multi-column WHERE; left-prefix rule |
| Covering | INCLUDE columns for index-only scans |
| Partial | WHERE clause limits index size |
Warning: Every index slows writes. Audit unused indexes (pg_stat_user_indexes.idx_scan = 0).
10. Parallel Processing Pattern
| Approach | Detail |
| Fork-Join | Split task; combine results (Java ForkJoinPool) |
| MapReduce | Distribute across nodes |
| Parallel Streams | Java stream().parallel() (CPU-bound only) |
| Async Pipelines | CompletableFuture chains |
| Virtual Threads | Java 21+ for I/O-heavy concurrency |