Run Multiple Servers

Learn how to run multiple servers.

To deal with the large scale of Sneakers23’s online operation, we’ll need to run multiple servers simultaneously. Running multiple servers can be difficult when in-memory data structures are used because updates are not automatically sent across the cluster. However, the scalability is undoubtedly worth it. We have already discussed how Phoenix deals with this by broadcasting messages to all connected nodes, and we’ll use a similar solution to broadcast our inventory changes across the cluster. Let’s start by demonstrating the particular problem we’re facing.

The challenge of distribution

Running multiple servers exposes a problem. The current Inventory.Server process only knows about its own transactions. This means that if an item is released or sold on another node, it won’t update until the server reboots. We can discover this ourselves by running a local test with two nodes.

Get hands-on with 1400+ tech skills courses.