All Projects → bgadrian → go-worker-thread-pool

bgadrian / go-worker-thread-pool

Licence: MIT license
A visual working example of a Thread Pool pattern, based on a known blog article.

Programming Languages

go
31211 projects - #10 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to go-worker-thread-pool

noroutine
Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
Stars: ✭ 86 (+258.33%)
Mutual labels:  concurrency, parallel, workers
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (+704.17%)
Mutual labels:  thread, concurrency, parallel
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+2054.17%)
Mutual labels:  thread, concurrency, parallel
Rxjava Android Samples
Learning RxJava for Android by example
Stars: ✭ 7,520 (+31233.33%)
Mutual labels:  example, thread, concurrency
bascomtask
Lightweight parallel Java tasks
Stars: ✭ 49 (+104.17%)
Mutual labels:  thread, concurrency, parallel
React Native Threads
Create new JS processes for CPU intensive work
Stars: ✭ 527 (+2095.83%)
Mutual labels:  thread, concurrency, workers
React Native Workers
Do heavy data process outside of your UI JS thread.
Stars: ✭ 114 (+375%)
Mutual labels:  thread, parallel, workers
Example.v2
An example project for book 'Go Programming & Concurrency in Practice, 2nd edition' (《Go并发编程实战》第2版).
Stars: ✭ 722 (+2908.33%)
Mutual labels:  example, concurrency
Sobjectizer
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
Stars: ✭ 172 (+616.67%)
Mutual labels:  thread, concurrency
Three Chat Servers
Example code to go with the talk of the same name and the Ruby Magic concurrency series of blog posts.
Stars: ✭ 46 (+91.67%)
Mutual labels:  example, concurrency
Kommander Ios
A lightweight, pure-Swift library for manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.
Stars: ✭ 167 (+595.83%)
Mutual labels:  thread, concurrency
IPpy
🚀 Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.
Stars: ✭ 54 (+125%)
Mutual labels:  parallel, workers
Linux-Kernel-Driver-Programming
Implementation of PCI drivers, kprobe, sysfs, devfs, sensor driver, miscdevices, synchronization
Stars: ✭ 43 (+79.17%)
Mutual labels:  concurrency, parallel
Preact Worker Demo
Demo of preact rendering an entire app in a Web Worker.
Stars: ✭ 204 (+750%)
Mutual labels:  thread, workers
Java Concurrency Examples
Java Concurrency/Multithreading Tutorial with Examples for Dummies
Stars: ✭ 173 (+620.83%)
Mutual labels:  thread, concurrency
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (+0%)
Mutual labels:  concurrency, parallel
ComposableAsync
Create, compose and inject asynchronous behaviors in .Net Framework and .Net Core.
Stars: ✭ 28 (+16.67%)
Mutual labels:  thread, concurrency
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-16.67%)
Mutual labels:  concurrency, parallel
wasm-bindgen-rayon
An adapter for enabling Rayon-based concurrency on the Web with WebAssembly.
Stars: ✭ 257 (+970.83%)
Mutual labels:  concurrency, parallel
Java Concurrent Programming
📓 《实战Java 高并发程序设计》笔记和源码整理
Stars: ✭ 162 (+575%)
Mutual labels:  thread, concurrency

Go workers thread pool

Visual implementation of a Concurrent Pattern more exactly a Thread Pool. It is based on Marcio Castilho blog article "Handling 1M requests per minute". The differences from the article code & this repo:

  • extracted the process function (for testing and clarity)
  • removed the JOB_QUEUE global variable
  • added unit test & web server for a better understanding on how it works
  • split the algorithm to different files
  • added a dummy Client & waiting times

Thread pool (workers)

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.

Why?

I 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 & websockets. The user can send fake jobs to process, and everything is slowed down (to seconds) so the user can observe the worker behaviours.

diagram

Demo

alt text

Usage

go get github.com/bgadrian/go-worker-thread-pool

#make sure you have port 8080 free
#for windows 
cd %GOPATH%/src/github.com/bgadrian/go-worker-thread-pool/
go build -o server.exe & server.exe -MAX_WORKERS=5
#for Linux/MacOS
go build -o webserver && chmod +x ./webserver && ./webserver -MAX_WORKERS=5

#open http://localhost:8080 in your browser & keep this process open.

Copyright

B.G.Adrian 2017

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].