TCP/IP stream will control most of the stuff you are worried about.
"Sending request faster than the server can't handle"
No you will never send anything to the server faster than it can receive when using a TCP session. The transmission flow is guided and impossible to send faster than the server can handle.
"What is network buffer"
There are two queue buffers envolved in the TCP/IP communication, a send buffer and a receive buffer.
When you make a send()
call, it doesn't really send anything, it will just queue the data in the send buffer, and will return to you how many of the bytes you were trying to send were actually put into the queue for sending. If it return less than you were trying to send, it means you have to wait before sending the rest because the buffer is full.
This is how you control the traffic, it is your cue to know if you are trying to send stuff too fast. Try to keep the buffer full as long as you have data to send, but don't ignore the fact that not everything will fit in the buffer and you have to retry later.
The recv()
also has its own buffer. This command is not actually to receive anything, the data is already received, recv()
will only read it from the receive buffer. When using a blocking socket (default), recv()
will hang if the buffer is empty, waiting for new data to arrive. recv()
will only return 0 if the connection was terminated or if you try to use it with a non-blocking socket.
If you forget to recv()
and the receive buffer becomes full, it is okay too. The peer will be unable to continue sending, as send()
will start to return 0 to them, but as long you pay attention to the send()
return value no data is lost at any time.
As far as I know, the buffer size is 64KB in all systems by default, both for sending or receiving. There are commands to adjust this buffer size, but it is not interesting to mess with. If you need a bigger buffer, make it in your application.
"What are alternative way to improve performance if we are at client end and no control on server"
Its not exactly a valid question, you cannot do that. I think you might be doing some mistake with the HTTP requests, specially considering you are doing POST requests.
When doing a POST request, your HTTP header will contain two headers that are usually only seen on server HTTP response headers: The Content-Type and Content-Length. They are very important when doing a POST, and if one of them is missing or wrong, the HTTP session may hang for a couple seconds or not succeed at all.
Another important aspect of HTTP, is the most essential difference between HTTP 1.0 and HTTP 1.1: HTTP 1.0 does not support Keep-Alive. It is easier for a beginner to deal with HTTP 1.0, because with HTTP 1.0, you connect, send your request, the server answers and the connection is terminated, meaning you finished downloading the server response. With HTTP 1.1 it will not happen by default. The connection remains open until it times out. You have to pay attention to the HTTP response header Content-Length and count bytes in order to know if the server concluded sending the stuff you requested.
It is also important to observe that not all servers support HTTP 1.0. You may make a HTTP 1.0 request, but it will respond with 1.1 anyway, with Keep-Alives and all stuff you wasn't expecting. On a perfect world it shouldn't happen, but it does.
Your mistake might be around in this area. Sinse you said your request is taking exactly 60 seconds, I suspect it is because its timing out. You probably already received everything you had to, but the application is not handling that properly and than hangs until the connection is terminated by the server.