I need to push 1000 small objects per second from a server program to 100 clients 开发者_如何学Goon a gigibit LAN so I need the fastest approach thanks.
I know the different between usp and TCP - I have a layer on top of udp to make it reliable and ordered.
Which should I use and why? Udp unicast or TCP. For router reason I can't use Udp multicast.
Thanks
Can the Clients communicate with each other? Ultimately you only have a limited number of wires out of your server, which limits your speed. Getting the clients to do some of the work of distribution gives you more wires and hence multiplies your speed more than any protocol change will.
TCP is essentially UDP with a reliability layer - exactly what you have. However TCP is implemented in hardware and is proven. Your reliability layer is in software (slower) and unproven (risky).
if you have a custom layer on top of UDP, then the performance of this will also need to be taken into account, when comparing against TCP - so I don't think anyone on SO will be able to give you a definitive answer.
I think the only way you'll be sure is to test both solutions thoroughly in the most realistic environment possible
Definitively, UDP unicast, as you have a reliable layer on top of it. the problem with TCP, is that you can not control it's speed from the PUSH server. It depends on many algorithms coded in the stack. With UDP, you can send as fast as the server can. That is the client that should cope with that speed.
This of course let apart the standard 'UDP is not reliable' part as it seems you have solved that :)
my2c.
PS: UDP multicast rules, what a pity network hardware is so badly configured ;)
The performance depends on your layer on top of UDP. If your layer reinvents TCP with three-way handshakes, congestion windows, sequence numbers and so on, then the performance could be worse.
Otherwise UDP should be faster.
(1000 small objects per second to 100 clients is not that much, IMHO)
精彩评论