Re: Ideas required for usage of sockets API for efficient network programs



On Jun 6, 1:49 pm, saurabhth <saurab...@xxxxxxxxx> wrote:
Hi all,

I am evaluating various methods of using sockets API for a network
program to make it efficient. Your ideas are most welcome. (reference:
rstevens book)

For the purpose of our discussion lets take reference the following
definition of the programs:

1) The server handles multiple connections, the connections can be
many in no. (~20-50)
2) The server reads data from clients and writes data to clients.
3) The clients too read data from server and write data to it. This
and the point 2 imply there is a protocol between the server and
clients. The protocol mandates exchange of data in form of buffers
where each buffer has a fixed size header(X bytes) followed by
variable length payload(N bytes).
4) Both servers/clients are high bandwidth applications.
5) There exists some latency while processing data in servers and
clients (Z units of time)
6) The performance metric is low CPU consumption for Y no. of messages
in the system.

In my opinion such programs must use :

1) epoll API instead of select.

2) non blocking sockets for read/write. Non blocking for write
necessitates use of some efficient buffering mechanism of saving
partial writes. We must avoid memcopy here. Please suggest some
algorithms here.

3) Reduce the no. of reads of messages by using scatter read API.
However it is complicated as the data is always processed as header
+payload. How a read vector has to be setup I am unable to understand.

4) Reduce the no. of writes of messages by using gather write API. The
implementation becomes difficult if it is combined with non blocking
sockets and one has to handle partial writes.

Lets have a discussion on each of the above 4 points. Your algorithms
and ideas and any new points are welcome.

One thing I forgot to add: The client/server programs use TCP/IP
.



Relevant Pages

  • Ideas required for usage of sockets API for efficient network programs
    ... I am evaluating various methods of using sockets API for a network ... The server reads data from clients and writes data to clients. ...
    (comp.os.linux.development.apps)
  • sockets, closing and TIME_WAIT
    ... During heavy load the server can't follow anymore because the sockets ... my server should be able to handle 10 clients connecting ... This gets a free position in the array of connections, ...
    (comp.unix.programmer)
  • Re: blocking non blocking
    ... not connected to incoming data on the same thread, async sockets have to be ... somehow a server with 50K threads, ... or overlapped I/O servicing 50K clients. ... read and learnt about blocking and non blocking, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Socket programming: Command and Data socket
    ... example of how one could implement a program that uses two sockets for ... this working for a long time, but I guess my design is wrong. ... multiple clients connecting from the same or different machines. ... clients asks for a list of files and the server returns this. ...
    (comp.unix.programmer)
  • Re: Moving files from clients to the server
    ... I'm not very familiar with sockets but I'll look into that, ... >> files should be passed to the server. ... the fastest way to create them is on the clients' machines. ... >> Another solution is to steam the files over the network. ...
    (microsoft.public.vc.atl)