Nowadays every system tries to be a real-time system, or at least a soft real-time system. To achieve this, most systems overuse the pull approach. This causes a lot of useless requests that lead to overloading. Why are they useless? Because this approach tries to catch changes by requesting over and over again, but there will always be a delay: the new data has to already be there when the request is made.
Today we have languages like Erlang or Elixir (I am very excited about Elixir and you will see some posts about it in the future), or frameworks like Akka. But what can we do when we have a lot of complex algorithms written in a language like Python, or our team does not know Erlang?
For this reason I decided to build a proof of concept of a reactive architecture using Python. The PoC is a system that tracks the CPU usage of a machine, although it is (almost) ready to measure the resource usage of many machines.
To build a complete system, I chose Tornado Web Framework, RabbitMQ and AngularJS for the different modules.
The first module, resources-tracker, is in charge of measuring the CPU and sending the measurements through the RabbitMQ broker using a topic exchange. The topic will be <name-of-the-machine>.measure.

The next module, resources-analyzer, receives all the measurements (topic: #.measure), determines the CPU usage level of the machine (HIGH, MEDIUM, LOW) and sends it through the RabbitMQ broker using the topic <machine’s-name-of-received-measure>.analysis.
The last module, resources-web, shows the results of the previous module. For this task I use the Tornado web framework, which is connected to RabbitMQ using the TornadoConnection of Pika, and to a simple AngularJS client through a WebSocket.
Therefore, each time a CPU measurement is taken, the final result is shown in the browser without making any request.
This approach makes the system very scalable. Everything can be built as a module that listens to the right topics and sends its result on another topic, so that it can be used by other modules. The final picture may remind us of a neural network.
All the code can be found on github. Each module contains a Dockerfile, which will help you a lot to run the entire system using Docker.