Skip to content

Các trường hợp sử dụng

Tìm pattern theo loại hệ thống bạn đang xây.

Web API & Microservice

Đang xây service REST/gRPC? Các pattern này giúp nó tin cậy dưới tải.

Kịch bảnPatternVí dụ thực tế
Bảo vệ khi downstream gặp sự cốCircuit Breaker + Retry with BackoffNetflix Hystrix bọc mọi cuộc gọi HTTP client
Rate limit APIRate LimiterStripe cho phép burst 25, refill ở 25/giây
Middleware request (auth, log, tracing)Middleware ChainInterceptor gRPC, mô hình hành tây Koa.js
Khám phá serviceRegistryĐăng ký service Consul, etcd
Phân tán tải qua các nodeConsistent HashingHAProxy, phân tán key groupcache
Tránh quá tảiBackpressure + Batch ProcessingPipe stream Node.js, consumer group Kafka

Database & lưu trữ

Các pattern đằng sau PostgreSQL, Redis, LevelDB và mọi storage engine nghiêm túc.

Kịch bảnPatternVí dụ thực tế
Khôi phục sau crashWAL + CheckpointingPostgreSQL: WAL + checkpoint định kỳ
Tải nặng ghiLSM Tree + Bloom FilterLevelDB/RocksDB: memtable → SSTable + bloom bỏ qua
Truy vấn khoảng trên đĩaB+ TreeChỉ mục btree PostgreSQL, SQLite
Đọc/ghi đồng thờiMVCCVersioning tuple PostgreSQL, revision etcd
Xác minh toàn vẹn dữ liệuMerkle TreeChecksum block ZFS, kho object Git
Gộp key đã sắp xếpMerge Iterator + Min HeapCompaction LevelDB
Xoá không xoá ngayTombstoneTombstone Cassandra, marker xoá LevelDB
Sorted set trong bộ nhớSkip ListSorted set ZADD/ZRANGE Redis
Cache trong bộ nhớLRU CacheLRU eviction Redis, Go groupcache
Sắp xếp sự kiện không có đồng hồLogical ClockRaft log etcd, version vector DynamoDB

Frontend & framework UI

React, Vue và browser engine dùng các pattern này mỗi frame.

Kịch bảnPatternVí dụ thực tế
Diff virtual DOMDiff / Patch + BitmaskReconciler React: diff cây, áp patch tối thiểu
Render phản hồi nhanhCooperative SchedulingReact Scheduler: yield mỗi 5ms để giữ dưới 16ms
Update state an toàn theo frameDouble BufferingReact Fiber: hoán đổi workInProgress ↔ current tree
Tránh re-render không cầnDirty FlagshouldComponentUpdate React, layout Chromium
Quản lý stateObserver + State Machinesubscribe Redux, trạng thái hữu hạn XState
Lập lịch task theo ưu tiênMin HeapQueue ưu tiên React Scheduler

Hệ phân tán

Pattern cho hệ thống trải qua nhiều máy.

Kịch bảnPatternVí dụ thực tế
Log đồng thuậnWAL + Logical ClockRaft etcd: log append-only với term/index
Định tuyến chịu phân vùngConsistent HashingAmazon DynamoDB, vòng Cassandra
State replicatedState Machine + WALRaft: replicated state machine qua log
Replication không xung độtLogical Clock + TombstoneCRDT, last-write-wins kiểu Dynamo
Đồng bộ dữ liệuMerkle TreeAnti-entropy repair Cassandra
Kiến trúc hướng thông điệpActor Model + BackpressureCluster Akka, Erlang/OTP
Pipeline build/deployDependency Graph + Batch ProcessingĐồ thị build Cargo, workspace pnpm

Runtime & quản lý bộ nhớ

Cách Go, CPython, V8 và game engine quản lý bộ nhớ và thực thi.

Kịch bảnPatternVí dụ thực tế
Giảm áp lực GCObject Pool + Free ListGo sync.Pool, allocator SLUB Linux
Cấp phát theo phaArena AllocatorRust bumpalo, Go arena (thử nghiệm)
Dọn dẹp xác địnhReference Countingrefcount CPython, Rust Rc/Arc
Khử trùng lặp chuỗiInterning + FlyweightSymbol interning của Rust compiler, cache số nguyên nhỏ Python
Clone hiệu quảCopy-on-WriteLinux fork(), Rust Cow<T>
Phân tán việc qua các coreWork StealingScheduler P/M/G Go runtime, Tokio
Ghép kênh I/OEvent Loop + Ring Bufferlibuv (Node.js), Redis single-thread
Counter thread-safeSemaphoreSemaphore kernel Linux, Go x/sync

Compiler & công cụ ngôn ngữ

Pattern dùng trong LLVM, V8, rustc và compiler Vue/React.

Kịch bảnPatternVí dụ thực tế
Duyệt ASTVisitorLLVM InstVisitor, biến đổi compiler Vue
Dispatch độngVtableSlot tp_* CPython, Rust dyn Trait
Bảng symbolInterning + TrieSymbol interning rustc
Biến đổi IRIterator + Diff / PatchAdapter Iterator Rust, edit tree-sitter
Biểu diễn kiểuTagged UnionCon trỏ có tag V8, TensorImpl PyTorch
Hệ thống pluginRegistry + Middleware ChainPlugin Babel, loader webpack

Mạng & giao thức

Kịch bảnPatternVí dụ thực tế
Theo dõi trạng thái kết nốiState MachineState machine TCP Linux (SYN_SENT → ESTABLISHED → ...)
Định tuyến IPTrieLC-trie cho FIB IPv4 Linux
Đệm gói tinRing Buffersk_buff Linux, ring DPDK
Kiểm soát luồngBackpressure + Rate LimiterFlow control TCP, Nginx limit_req
Phân giải DNSTrie + LRU CacheTra cứu tên miền + cache response

Released under the MIT License.