Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection timeout and socket timeout advice

I'm currently doing some research into connection and socket timeout settings but I'm fairly new to this stuff.

As a stab in the dark we are thinking of adding 40 seconds as a connection and sockettimeout when we run json over http calls to another server.

    httpConnectionManagerParams.setConnectionTimeout(40000);
    httpConnectionManagerParams.setSoTimeout(40000);

But really I don't know about how to understand what the ideal settings or best practices to use are. I would appreciate it if someone could give me some pointers on what to consider when or tips on how to come up with a good gestimate on these settings.

The sort of advice I'm looking for is something like ... 40 seconds is far too long because it might cause another issue.... or ... the higher you set this value the more chance you have of causing another isssue... or 40 seconds is not to high at all... or to work out an ideal figure multiply Y by T

thanks


EDIT

Adding firebug trace of server call. enter image description here

like image 535
Richie Avatar asked Jul 09 '15 10:07

Richie


People also ask

What is difference between socket timeout and connection timeout?

connection timeout — a time period in which a client should establish a connection with a server. socket timeout — a maximum time of inactivity between two data packets when exchanging data with a server.

What is a good socket timeout?

Best Answer. Given that on Policy server the default idle timeout for socket is 10min, I think 10 min is good vlaue for it.

Is socket timeout and read timeout same?

The connection timeout is the timeout in making the initial connection; i.e. completing the TCP connection handshake. The read timeout is the timeout on waiting to read data1.

How long should a connection timeout be?

The default value of connection timeout property ( 3 seconds) has been found to be largely adequate for most backend servers. You should increase the value of this property only if you have deemed it necessary after performing all the possible checks/optimizations on the network and your backend server.


1 Answers

There's no reason whatsoever why they should be equal. Considering each condition separately, you want to set it high enough that a timeout will indicate a genuine problem rather than just a temporary overload, and low enough that you maintain responsiveness of the application.

As a rule, 40 seconds is far too long for a connect timeout. I would view anything in double figures with suspicion. A server should be able to accept tens or hundreds of connections per second.

Read timeouts are a completely different matter. The 'correct' value, if there is such a thing, depends entirely on the average service time for the request and on its variance. As a starting point, you might want to set it to double the expected service time, or the average service time plus two or three standard deviations, depending entirely on your service level requirements and the performance of your server and its variance. There is no hard and fast rule about this. Many contractual service level agreements (SLAs) specify a 'normal' response time of two seconds, which may inform your deliberations. But it's your decision.

like image 161
user207421 Avatar answered Sep 24 '22 11:09

user207421