The Wayback Machine - https://web.archive.org/web/20200608044221/https://github.com/JackyChiu/pool
Skip to content
Simple worker pool example πŸŠβ€β™‚οΈ
Go
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.gitignore
LICENSE
README.md
balancer.go
main.go
pool.go
pool_test.go
request.go
worker.go

README.md

Worker Pool

The worker pool distributes work across the workers to the least loaded worker.

Demo

The pool was tested by a load generator that produces tasks at a inconsistent interval, faster than the time it takes to complete the tasks itself. The tasks also take an inconsistent amount of time to finish. In this example the tasks were just sleeps.

The gif below shows values for:

  • Workers: Pending requests for worker
  • Avg Load: Average pending requests for worker pool
  • Std Dev: Standard deviation of pending requests

gif

Design

diagram

The design was based off the talk concurrency is not parallelism by Rob Pike, the diagram is also from there

  1. Requests are made by a requester
  2. The Balancer dispatch's requests to a select worker in the worker pool
  3. The Worker will execute the task specified by the request
You can’t perform that action at this time.