3 ms·
Just send the message immediately using UDP, preferably multicast, but unicast works too if you're stuck with a web-centric cloud environment.
by mgaunard 3y ago
Just send the message immediately using UDP, preferably multicast, but unicast works too if you're stuck with a web-centric cloud environment.
- chasd00 3y agoi'm not an expert here but each message is pretty important right? What happens if you put a UDP datagram on the wire and it never shows up? Wouldn't you have to come up with some kind of signal to indicate the message made it to the receiver? After that you'll probably start signaling delivery of groups of messages instead of individually and then ordering them on the receiver by when they were sent and then maybe some validation of integrity and sender backoff mechanism for network congestion... and then you've made TCP.
- mgaunard 3y agoTCP means that all bytes must be copied to a local buffer in order to be re-sent in the case the other end didn't receive them (even though by that time they're probably old and irrelevant). Once the buffer is full you cannot send more data and must wait for the other end to ack them (potentially indefinitely, though most implementations will eventually time out after long enough). This means that if you wanted to send 10Gbps unthrottled to another continent, you'd need a buffer of 500MB per TCP session, assuming no data loss, and consumer keeping up at line rate. TCP is just not a good fit for anything that needs high-performance or bounded sending times. What it's good for is giving you a simple high-level abstraction for streaming bytes when you'd rather not design your networked application around networking. Building the right logic for your application is not difficult (most often, just let the requester resend, which you needs to do anyway in the age of fault-tolerant REST services, or just wait for more recent data to be pushed) and easier than tweaking TCP to have the right performance characteristics.
- kiitos 3y agoUDP doesn't provide reliable delivery, so you would need to implement some kind of delivery assurance in your application. UDP also has very small message (datagram) size limits, so you would also need to implement some way to fragment and re-combine messages in your application. At this point you've built an ad-hoc re-implementation of 80% of TCP.