Scalable Worker Pool is a dynamically scalable worker pool management system. This application utilizes workers to process incoming requests, providing high efficiency and flexibility. The application automatically increases and decreases the number of workers to optimize system load.
- Dynamic worker management
- Load monitoring and automatic scaling
- Request processing logic
- Graceful shutdown support
The project is structured according to Clean Architecture principles. Below is the main components of the project along with the flow diagram.
+---------------------+
| main.go |
+---------------------+
|
| Initializes context, sets max procs, and creates request handler
|
v
+---------------------+
| NewDispatcher |
| (workerpool) |
+---------------------+
|
| Creates WorkerManager and Scaler
|
v
+---------------------+
| WorkerManager |
+---------------------+
|
| Manages workers and their lifecycle
|
v
+---------------------+
| Worker |
+---------------------+
|
| Launches worker to process requests
|
v
+---------------------+
| Request |
+---------------------+
|
| Contains request data and processing logic
|
v
+---------------------+
| RequestHandler |
+---------------------+
|
| Handles specific request types
|
v
+---------------------+
| Scaler |
+---------------------+
|
| Monitors load and scales workers up/down
|
v
+---------------------+
| Dispatcher |
+---------------------+
|
| Manages the overall worker pool and request distribution
|
v
+---------------------+
| Graceful Shutdown |
+---------------------+
|
| Ensures all requests are processed before exiting
|
v
+---------------------+
| Exit |
+---------------------+
- Ensure that Go is installed on your machine. You can download it from the official Go website: golang.org.
- Clone the repository to your local machine:
git clone https://github.com/cembdc/scalable-worker-pool
- Navigate to the project directory:
cd scalable-worker-pool
- Install the necessary dependencies using Go modules:
go mod tidy
To start the application, run the following command:
go run main.go
We welcome contributions to this project! If you have suggestions or improvements, please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for more details.