Apex fully implements the messaging engine RabbitMQ allowing for easy and efficient horizontal scaling, ensuring your operations can easily scale to any volume. If you are unfamiliar with RabbitMQ, please view this RabbitMQ PHP Tutorial. Simply put, it provides messaging functionality to the software, and evenly distributes the messages to the back-end application servers to handle the heavy lifting of the software. This way, if and when the volume gets too high, you can easily add a new server into the cluster to help handle the load.
The setup is quite simplistic:
There are two types of messages available -- one-way messages where the web servers only require an acknowledgement that the message has been accepted, and two-way RPC commands where the web server has to wait for a response from RabbitMQ / back-end application servers before providing output to the web browser. Developers should aim that 90% of all requests only use one-way messages, and only use two-way RPC commands if necessary as two-way RPC commands take longer to process, hence may slow down the overall operation and cause bottlenecks.
For example, when a user registers, the web servers only communicate with the redis database, send one message to RabbitMQ containing the registration information, then outputs the "thank you" page to the web browser, and closes the connection. RabbitMQ then picks up the message, and relays it to one of the back-end application servers, which then performs the actual registration and commits it to the mySQL database.
However, since redis is an in-memory database, it does come with storage limitations, meaning sometimes information from the mySQL database is needed requiring a two-way RPC call. For example, when a user is viewing their transaction history, due to storage limitations that data can not be stored in redis. Instead, the web server will make a two-way RPC call to RabbitMQ, which then relays the message to one of the back-end application servers, which then gathers the necessary information from the mySQL database, returns it to RabbitMQ, which then relays it back to the web server. This process can take several seconds, so best to avoid two-way RPC calls unless required.
For further information on how messaging works within Apex, please use the below links.