{"id":20491181,"url":"https://github.com/bgadrian/go-worker-thread-pool","last_synced_at":"2025-09-12T19:37:36.829Z","repository":{"id":50712748,"uuid":"104678174","full_name":"bgadrian/go-worker-thread-pool","owner":"bgadrian","description":"A visual working example of a Thread Pool pattern, based on a known blog article.","archived":false,"fork":false,"pushed_at":"2017-10-17T08:51:58.000Z","size":160,"stargazers_count":27,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-08T10:54:48.805Z","etag":null,"topics":["concurrency","example","golang","parallel","thread","workers"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bgadrian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-24T21:40:09.000Z","updated_at":"2024-07-07T09:07:13.000Z","dependencies_parsed_at":"2022-09-10T00:50:34.599Z","dependency_job_id":null,"html_url":"https://github.com/bgadrian/go-worker-thread-pool","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bgadrian/go-worker-thread-pool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fgo-worker-thread-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fgo-worker-thread-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fgo-worker-thread-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fgo-worker-thread-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bgadrian","download_url":"https://codeload.github.com/bgadrian/go-worker-thread-pool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fgo-worker-thread-pool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274864466,"owners_count":25364232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","example","golang","parallel","thread","workers"],"created_at":"2024-11-15T17:20:20.143Z","updated_at":"2025-09-12T19:37:36.782Z","avatar_url":"https://github.com/bgadrian.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go workers thread pool\n\nVisual implementation of a Concurrent Pattern more exactly a [Thread Pool](https://en.wikipedia.org/wiki/Thread_pool). It is based on [Marcio Castilho\n blog article \"Handling 1M requests per minute\"](https://medium.com/smsjunk/handling-1-million-requests-per-minute-with-golang-f70ac505fcaa). The differences from the article code \u0026 this repo:\n \n * extracted the process function (for testing and clarity)\n * removed the JOB_QUEUE global variable\n * added unit test \u0026 web server for a better understanding on how it works\n * split the algorithm to different files\n * added a dummy Client \u0026 waiting times\n\n### Thread pool (workers)\n\n\u003e In computer programming, a thread pool is a software design pattern for achieving concurrency of execution in a computer program. Often also called a replicated workers or worker-crew model, a thread pool maintains multiple threads waiting for tasks to be allocated for concurrent execution by the supervising program. By maintaining a pool of threads, the model increases performance and avoids latency in execution due to frequent creation and destruction of threads for short-lived tasks.\n\n### Why?\n\nI want to get a better grasp of the pattern so I made a dummy  running example, with a few alternations. I also added a visual representation using a HTML basic client \u0026 websockets. The user can send fake jobs to process, and everything is slowed down (to seconds) so the user can observe the worker behaviours.\n\n![diagram](./diagram.png)\n\n### Demo \n\n![alt text](./demo.gif)\n\n### Usage\n\n```bash\ngo get github.com/bgadrian/go-worker-thread-pool\n\n#make sure you have port 8080 free\n#for windows \ncd %GOPATH%/src/github.com/bgadrian/go-worker-thread-pool/\ngo build -o server.exe \u0026 server.exe -MAX_WORKERS=5\n#for Linux/MacOS\ngo build -o webserver \u0026\u0026 chmod +x ./webserver \u0026\u0026 ./webserver -MAX_WORKERS=5\n\n#open http://localhost:8080 in your browser \u0026 keep this process open.\n```\n\n\n\n#### Copyright\nB.G.Adrian 2017\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgadrian%2Fgo-worker-thread-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbgadrian%2Fgo-worker-thread-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgadrian%2Fgo-worker-thread-pool/lists"}