💻 Scalable application for simulating sending emails with Docker workers 🐳 and Pyhton with the Bottle micro-framework 🐍
🏠 Homepage
- docker
Observe the architectural model used in the application below:
With the docker started, perform the following steps:
To run the application with a single worker, run the following command:
docker-compose up -d
Initially, when using the command above, the application will start with just 1 email message processor (worker), queuing requests and working synchronously, that is, only one message request is processed at a time.
See the following example:
To run the application with multiple workers, run the following command:
docker-compose up -d --scale worker=3
That way, when using the command above, the application will start with 3 email message processors (workers), allocating messages among the available workers and queuing in each worker when everyone is busy. Thus, the application will work asynchronously between 3 workers.
See the following example:
To send the messages, after starting the application, access http://localhost:80
You will see this screen:
In the first situation, each message sent needs to wait for the previous message to be processed, since there is only one worker.
Watch:
Message 1 was processed initially. Message 2 had to wait for message 1 to finish processing. Message 3 had to wait for message 2 to finish processing.
In the second situation, each message sent checked which worker was available to process it, thus occupying the 3 available workers and making the processing of the 3 messages independent.
Watch:
Message 1 was initially processed at worker 1. Message 2 was processed on worker 3 (fetched one of the other available workers) Message 3 was processed on worker 2 (fetched the last available worker)
If a 4th message were sent to be processed, it would be queued in one of the workers, since everyone is busy.
👤 Pedro Lucas
- Twitter: @PedroLucasOM
- Github: @PedroLucasOM
- LinkedIn: @PedroLucasOM
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Copyright © 2020 Pedro Lucas.