I am writing a server daemon (in C) to run under Linux and I need to make a choice for the algorithm to use to deliver notification messages to my users. I have 2 choices:
- Push. Establish a connection for all registered users and keep it alive. When message arrives, push it to the client through the established TCP connection.
- Poll. Make a connect() every 60 seconds from the client side, check if there any message and disconnect. The disadvantage is that messages will not arrive instantly to the client.
To decide which method to use I need to know how much memory does an established connection take , on the kernel side. I can calculate how much memory do I need in the userspace myself, but I don't know how the networking stuff works in Linux kernel. So, I have 2 questions: which method would you recommend me to implement and how much resources does an established TCP connection (which is not transmitting data at the moment) take? The daemon will be serving data to thousands of users, some of them frequently using the service, some of them not.