RepositoryGoCNTrung Quốc
Yiming1997

Yiming1997/agilePool

A golang goroutine pool with high-performance and elegance

324sao
50fork
1issue
2lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: worker-pool

#1 Repository của tuần

1
TINIX TRENDING·Chủ đề: pool

#1 Repository của tuần

1
TINIX TRENDING·Chủ đề: goroutine-pool

#1 Repository của tuần

🏊 agilePool — Goroutine Pool hiệu năng cao cho Go với adaptive scaling

Một goroutine pool cho Go không chỉ giới hạn worker — mà tự động điều chỉnh số worker dựa trên tải thực tế.

agilePool là thư viện goroutine pool cho Go, giải quyết bài toán quản lý hàng triệu tác vụ bất đồng bộ nhỏ mà không để goroutine phát triển mất kiểm soát. Thư viện tự động điều chỉnh số worker dựa trên thống kê rate theo sliding window, hỗ trợ retry với exponential backoff, submission có context và deadline, cùng graceful shutdown — tất cả với khả năng mở rộng cấu hình qua functional options.

✨ Điểm nổi bật

  • Adaptive scaler: theo dõi median rate qua histogram sliding-window, tự động spawn/scale worker theo tải thực tế, có configurable backlog decay để xử lý burst.
  • Bounded workers: giới hạn số worker chạy tối đa qua WithWorkerNumCapacity.
  • Unbounded task buffering: internal handoff channel (10.000 slot) + chunked linked-list buffer với backpressure qua maxChunkLen.
  • Pluggable idle containers: LinkedList (FIFO), MinHeap (LRU), Slice (FIFO), RingQueue (circular buffer, O(1) Pop).
  • Retryable tasks: tự động retry khi task trả về error, mặc định exponential backoff, hỗ trợ custom backoff strategy.
  • Context-aware submission: SubmitCtx hỗ trợ cooperative cancellation trước và sau khi queue.
  • Deadline-bound submission: SubmitBefore bỏ qua task nếu deadline hết trước khi worker pick up.
  • Graceful shutdown: Wait đợi tất cả in-flight tasks hoàn thành, Close dừng nhận task mới.
  • Custom logger: plug bất kỳ implementation Printf/Println nào (ví dụ zap.SugaredLogger).

💡 Vì sao đáng chú ý

Khác với phần lớn goroutine pool chỉ cung cấp fixed worker count, agilePool sử dụng sliding-window rate statistics để tự động điều chỉnh số worker — nghĩa là khi tải tăng, pool tự mở rộng; khi tải giảm, idle worker bị cleanup tự động theo idle timeout. Cơ chế backlog decay factor cho phép tinh chỉnh mức độ aggressive của scaler khi xử lý burst.

Cấu trúc buffer kết hợp handoff channel nhỏ + linked-list chunked giúp vừa giữ latency thấp cho task nhanh, vừa xử lý được backlog lớn mà không cấp phát quá mức. Với nhiều tùy chọn idle container (RingQueue O(1) Pop, MinHeap LRU), người dùng có thể tối ưu cho từng trường hợp sử dụng cụ thể — từ latency-sensitive đến throughput-focused.


#Go #GoroutinePool #WorkerPool #Concurrency #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryGo
panjf2000/ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.

14.5k
Sep 19, 2026
RepositoryGo
neilotoole/errgroup

errgroup with goroutine worker limits

163
Jan 10, 2023
RepositoryGo
alphadose/itogami

Fastest and most efficient goroutine pool (experimental)

141
Oct 16, 2022
RepositoryGo
alitto/pond

🔘 Minimalistic and High-performance goroutine worker pool written in Go

2.2k
Oct 24, 2026
RepositoryGo
ivpusic/grpool

Lightweight Goroutine pool

731
Jan 27, 2019
RepositoryGo
goptics/varmq

A Simplest in-memory and Distributed Storage-Agnostic Message Queue for Your Concurrent Go Program

210
Dec 1, 2026
RepositoryGo
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

197.2k
Dec 2, 2026
RepositoryGo
ollama/ollama

Get up and running with Inkling, Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

188.9k
Dec 2, 2026
RepositoryGo
golang/go

The Go programming language

140.0k
Dec 1, 2026