I have been thinking a lot about scaling out the WAMP router onto multiple machines. Especially because relying on one system without having a backup-system seems a bit tough in a live scenario.
To not have a complicated master node election and all that comes with it, I had the following idea and I would love to get some feedback.
Routers would need to share some information, i.e.:
Authentication
- session ids
RPC
- check if a client has already registered for an uri when using simple registration
- forward calls for pattern based registration
- meta api information
PUB/SUB
- provide event messages to all clients in the network
- meta api information
There must be a connection between all routers. To keep the connections and traffic low, the Idea is to have a ring infrastructure:
+----------------+ +-----------------+ +--------------+
| | | | | |
+--> First Router +----> Second Router +----> Nth Router +--+
| | | | | | | |
| +----------------+ +-----------------+ +--------------+ |
| |
+-----------------------------------------------------------------+
Every router would have it's own client that is connected to the next router. By storing the incoming message id for a CALL or PUBLISH that came from a client the router could identify a round trip. Incoming calls coming from another router would be handled as is. Yields would have the correct INVOCATION.Request|id and could be forwarded to the correct router.
LOOSING A ROUTER
This infrastructure forces to have some static and identical configuration for all routers. This means dynamic scaling would not work, but therefor no leader election is necessary. If a routers is killed the next router will be connected from the list of routers. A constant polling could check for the router to be back online.
I have not done any deep research on this. So I would be happy to get some input for that.
nginx can work as a reverse proxy to accomplish this.
ip_hash
on the upstream list will make sure a client IP get's the same server every time. You may or may not need this depending on your situation.Essentially, you want a "Load Balancer" to stand in front of WAMP servers, and delegate connections as needed.