I have a fast producer (client) and slow subscriber (server) due to slow Internet connection. How to decouple the connection such that server won't affect client performance?
- The server will not send any data back to client once the TCP connection is established. In my case, it is a data sink.
In order to avoid drag down client IO, e.g. waiting for ACK from server, there are a few solutions:
- Leverage a message queue (Redis, RabbitMQ)
- Pure socket programming. The high level idea is to quickly send
ACK
back to client "I got your message", then forward packets to server later. This ensures to reduce IO cost on client side.
- I host a server on my laptop and a cloud service on AWS. I need a way to stream the data to my server without affect the service on the cloud.
client -----> Extra TCP Server (middleman)-------- Packet Handler with non-blocking IO (separate thread) ------> server
Can't be happier! The client is no longer blocked by server :)