连接超时和套接字超时建议 [英] Connection timeout and socket timeout advice

查看:92
本文介绍了连接超时和套接字超时建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在对连接和套接字超时设置进行一些研究,但是我对这些东西还很陌生.

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

在黑暗中,我们想通过对另一台服务器的http调用来运行json时,将连接和套接字超时增加40秒.

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.

我正在寻找的建议类似于... 40秒太长了,因为它可能会引起另一个问题....或...设置的值越高,您获得的机会就越大导致另一个问题...或者40秒根本不算高...或者得出一个理想的数字,将Y乘以T

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

谢谢

添加服务器调用的Firebug跟踪.

Adding firebug trace of server call.

推荐答案

没有任何理由使它们相等.分别考虑每个条件,您希望将其设置得足够高,以使超时将表明是真正的问题,而不仅仅是暂时的过载,并且应将其设置得足够低,以保持应用程序的响应能力.

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.

通常,40秒对于连接超时来说太长了.我会怀疑地以双重数字看待任何事情.服务器应该能够每秒接受数十或数百个连接.

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.

读取超时是完全不同的事情.如果存在这种情况,正确"值完全取决于请求的平均服务时间及其方差.首先,您可能希望将其设置为预期服务时间的两倍,或平均服务时间加上两个或三个标准偏差,这完全取决于您的服务级别要求以及服务器的性能及其差异.对此没有硬性规定.许多合同服务级别协议(SLA)指定正常"响应时间为2秒,这可能会为您的审议提供依据.但这是您的决定.

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.

这篇关于连接超时和套接字超时建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆