4
votes

I was wondering,

1st question What are the pros and cons of using one socket (full duplex) vs. two socket (simplex) per peer: one for read and other write? Specially in terms of performance and resource utilization.

2nd question In case, if i choose to use more than 1 sockets per peer, on all i do read and write. Then will it helps me scale out in handling no of messages handled?

3rd question: what should help me determine the number of sockets per peer? Network Bandwidth? No. of message in and out?

All questions are different and do not have any inter-relation.

2
What's kind of application uses that socket(s)? If you need different kinds of communications in parallel, you had to use two sockets like FTP.Fumu 7
Some proprietary protocol sending and receiving messages over TCP sockets.Abhishek Jain
One drawback of using two sockets is the added complexity. With a single socket, the socket is either connected or it isn't. With two sockets, now you have to figure out how to handle it when one of the two socket connections has been broken (or failed to connect) while the other is still connected. It's extra hassle, for no clear benefit.Jeremy Friesner

2 Answers

4
votes

What are the pros and cons of using one socket (full duplex) vs. two socket one for read and other write? Specially in terms of performance and resource utilization.

Pro one socket: resource utilization. Contra one socket: nil. Performance: identical, except that you save on connect and close handshakes if you only use one socket.

In case, I choose to take two socket approach, then will not be useful to use both of them full duplex, that way it helps me scale out in terms of data flowing in and out?

Now you're comparing apples and oranges. You can't compare one full-duplex socket with two full-duplex sockets. I don't know why you think you might need two inbound and two outbound flows, but you don't. Every protocol I can think of except FTP uses only one.

what impact does network bandwidth has on it?

Nil.

or it has on network utilization?

Nil, apart from the connect and close handshakes. But it wastes resources at both ends.

1
votes

We've added --full-duplex to iperf 2.0.14 which will test a full-duplex socket. One can dompare it to two sockets per the -d or --dualtest option. We've found "your mileage will vary" and there is no universal to answer of having equal performance or not. In theory, it seems they should be equal but, in practice, maybe not.

   -d, --dualtest
          Do a bidirectional test simultanous test using two unidirectional sockets

       --fq-rate n[kmgKMG]
          Set a rate to be used with fair-queueing based socket-level pacing, in bytes or bits per second. Only available on  platforms  supporting  the  SO_MAX_PACING_RATE  socket  option.
          (Note: Here the suffixes indicate bytes/sec or bits/sec per use of uppercase or lowercase, respectively)

       --full-duplex
          run a full duplex test, i.e. traffic in both transmit and receive directions using the same socket

Bob