Replacing RPC calls with PubSub calls to reduce message throughput

My WAMP setup is unstable due to the number of browser clients (~40k concurrent and growing) and messages being sent (~300msg/sec), so I’ve been looking for ways to optimize it. I’ve already added proxy workers which greatly improved connection stability, but I still have issues.

The browser clients are sending messages to 1 backend client. My backend client doesn’t return a response, it inserts the message into a database.

My idea is to replace the browser clients’ RPC calls with PubSub calls, where the backend client is the only subscriber for the PubSub call.

RPC calls always involve 2 messages. 1 for the call, 1 for the response, even if the response is just null. PubSub calls only involve 1 message in my case, since there’s only 1 subscriber and no response.

The message size of the null response is tiny, only ~135 bytes, but why spend bandwidth/cpu on sending a message that doesn’t need to be sent? Replacing these RPC calls with PubSub would essentially cut the number of messages in half. This should save the router a lot of work in the aggregate, right?

For example, if the browser clients send 500k messages/hr, that’s actually 1 million messages being sent through the router every hour, because every call receives a response. Cutting that number in half sounds very appealing.

Does this idea sound reasonable? I’m interested in hearing your thoughts. I want to pull the trigger on this change but want to be sure I’m not doing anything stupid.

EDIT: I noticed that PubSub calls are received faster than RPC calls. On my machine, I tested 1 client sending 100k messages to another client. The receiving client tracks the duration between the first and last call.

100k RPC calls took 122 seconds, 100k PubSub calls took 93 seconds, so about 25% faster. I guess it’s because the router sends half as many messages for PubSub?

EDIT: Thought it’d be helpful to provide a visualization

browser-client -> router -> backend-client -> router -> browser-client

browser-client -> router -> backend-client