Lowest latency pub sub

What is the lowest latency pub sub server in Rust ?

The application here is: I am trying to see if we van build something with sufficiently low latency so that multiple people can play musical instruments together over the web synchronously.

If you're doing this over the internet, the overwhelming cause of latency will likely be out of your control.

1 Like

So the setup is: there are n people, x_1, x_2, ..., x_n

x_i opens up a web browser, it runs some Rust/WASM code I control
x_i/rust/wasm, over commercial residential internet, talks to some AWS EC2 machine
AWS EC2 machine runs Rust code I control, mixes the inputs from x_1, x_2, ..., x_n and blasts it back to everyone


Given the above, are you saying the lag in the commercial/residential internet likely dwars any latency I can remove by writing optimized software?

Light is slow. Electrical signal transmission is slower. Each router nodes between the browser machine and the machine hosting the EC2 instance adds up extra latency. Assuming reasonably clear implementation, latency within the pubsub process can hardly be significant.


For a real-world example, even if you found a perfect zero-delay pub/sub mechanism, you'd have to swallow a 100ms latency due to network round-trips over internet. That's way more than what a human ear is sensible to (a few ms) - which means you'll be able to tell there's too much delay.

That said, look at techniques used in online game servers, there are ways to mitigate this. Roughly, you're measuring everyone's RTT (round-trip time) then delay everybody by this duration. That means that local keypresses will make sound with a noticeable 100ms delay, but everybody will be on the same foot and will be able to play sort-of-synchronized.

Yes, it's not ideal.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.