Home Database Mysql Tutorial 转载:有关SQL server connection KeepAlive 的FAQ

转载:有关SQL server connection KeepAlive 的FAQ

Jun 07, 2016 pm 05:40 PM
connection server

转载:有关SQL server connection KeepAlive 的FAQ 转: 1、什么是SQL server TCP连接的keep Alive? 简单说,keep alive 是SQL server在建立每一个TCP 连接的时候,指定了TCP 协议的keepaliveinterval 和keepalivetime参数。这样对每个TCP连接,如果该连接

转载:有关SQL server connection KeepAlive 的FAQ

   

转:

 

1、什么是SQL server TCP连接的keep Alive?

简单说,keep alive 是SQL server在建立每一个TCP 连接的时候,指定了TCP 协议的keepaliveinterval 和keepalivetime参数。这样对每个TCP连接,如果该连接空闲时间(没有任何数据交互)超过keepalivetime,TCP协议会自动发出keepalive 包检测连接存活与否。如果keepalive 检测次数超过注册表TcpMaxDataRetransmissions定义的值而对方还是没有回应,那么TCP就认为该连接有问题而关闭它。通过这样的机制SQL server能够检测出orphaned connection等问题。

   

SQL  server 对每个TCP连接缺省指定keep alive 为30秒,keepaliveinterval为1秒。Windows TCP配置的TcpMaxDataRetransmissions缺省是5次。就是说,如果TCP连接idle了30秒,那么TCP会发送第一个keepalive检查。如果失败,那么TCP会每隔1秒重发keepalive 包,香港虚拟主机,直到重发5次。如果第五次检测依然失败,则该连接就被close。所以,一个TCP连接如果出现异常问题,大概在35秒的时候就会被close。

   

2、在那里可以配置SQL server 的keep alive 配置?

SQL server 2000代码里面也有对TCP连接指定keep alive属性,但没有提供用户界面给用户定制修改。SQL server2005使用configuration manager可以修改keep alive值,但是不能修改keepalive interval。 Keepaliveinterval是hardcoded的1秒。

Configuration manager的界面如下:

   

该值保存在注册表如下位置:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.?\MSSQLServer\SuperSocketNetLib\Tcp

注意SQL server的Native client也有类似配置,不要和server side 的TCP配置搞混了:

   

Native client的 keep alive 配置保存在如下位置:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SNI9.0\tcp

   

3、SQL server的keepalive 和Windows的TCP协议里面的keepalive 是一样的吗?

原理一样,但不相互干扰。

Windows 的TCP协议也有keep alive 配置,香港服务器,位置如下:

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

OS的TCP协议的keep alive 和SQL server 的keep alive 工作原理一样的,香港虚拟主机,就是在建立TCP连接的时候指定TCP连接的keepalive属性(参见后面描述)。但是SQL server读取自己注册表的keep alive来设置TCP连接属性,不理会windows OS的注册表里面的keepalivetime和keepaliveinterval的值。

如果一个应用程序没有显式调用函数设置TCP连接的keepalive属性,那么他的TCP连接默认使用OS 的TCP配置。OSkeep alive配置默认是关闭的。

有关OS 的TCP配置参考如下文档:

   

 

   

KeepAliveInterval

Key: Tcpip\Parameters

Value Type: REG_DWORD - Time in milliseconds

Valid Range: 1 - 0xFFFFFFFF

Default: 1000 (one second)

Description: This parameter determines the interval that separates keepalive retransmissions until a response is received. After a response is received, KeepAliveTime again controls the delay until the next keepalive transmission. The connection is aborted after the number of retransmissions that are specified by TcpMaxDataRetransmissions are unanswered.

KeepAliveTime

Key: Tcpip\Parameters

Value Type: REG_DWORD - Time in milliseconds

Valid Range: 1 - 0xFFFFFFFF

Default: 7,200,000 (two hours)

Description: The parameter controls how frequently TCP tries to verify that an idle connection is still intact by sending a keepalive packet. If the remote computer is still reachable and functioning, the remote computer acknowledges the keepalive transmission. By default, keepalive packets are not sent. A program can turn on this feature on a connection

   

4、SQL server 和OS里面 的TCP的keep alive是如何实现的?

详见如下文档:

 

SQL server也是调用如下API,把keepalive参数(lpvInBuffer)pass给这个API:

   

int WSAIoctl(

  __in   SOCKET s,

  __in   DWORD dwIoControlCode,

  __in   LPVOID lpvInBuffer,

  __in   DWORD cbInBuffer,

  __out  LPVOID lpvOutBuffer,

  __in   DWORD cbOutBuffer,

  __out  LPDWORD lpcbBytesReturned,

  __in   LPWSAOVERLAPPED lpOverlapped,

  __in   LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine

);

   

该文章里面有如下描述:

SIO_KEEPALIVE_VALS (opcode setting: I, T==3)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install, uninstall, and reset Windows server backup How to install, uninstall, and reset Windows server backup Mar 06, 2024 am 10:37 AM

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

What does CONNECTION_REFUSED mean? What does CONNECTION_REFUSED mean? Jul 31, 2023 pm 02:48 PM

CONNECTION_REFUSED is a network connection error that usually occurs when trying to connect to a remote server. When a client device attempts to establish a network connection with a server, and the server rejects the connection request, a CONNECTION_REFUSED error is returned. Common reasons include: the server is not started, the server cannot accept more connection requests, the server firewall blocks the connection, etc.

How to solve connection error How to solve connection error Nov 07, 2023 am 10:44 AM

Solution: 1. Check the network connection; 2. Check the server status; 3. Clear the cache and cookies; 4. Check the firewall and security software settings; 5. Try to use other networks, etc.

Windows Server 2025 preview version welcomes update, Microsoft improves Insiders testing experience Windows Server 2025 preview version welcomes update, Microsoft improves Insiders testing experience Feb 19, 2024 pm 02:36 PM

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,

PHP Warning: mysqli_connect(): (HY000/2002): Solution to Connection refused PHP Warning: mysqli_connect(): (HY000/2002): Solution to Connection refused Jun 23, 2023 am 08:54 AM

If you encounter the following error message when using PHP to connect to a MySQL database: PHPWarning:mysqli_connect():(HY000/2002):Connectionrefused, then you can try to solve this problem by following the steps below. To confirm whether the MySQL service is running normally, you should first check whether the MySQL service is running normally. If the service is not running or fails to start, it may cause a connection refused error. you can

How to modify the Nginx version name to disguise any web server How to modify the Nginx version name to disguise any web server May 14, 2023 pm 09:19 PM

How to modify the default name of nginx, you can disguise it a little, or you can install Tip: Generally, modifications are made before nginx is compiled. After modification, the code needs to be recompiled as follows: scr/core/nginx.conf#definenginx_version"1.4.7"#definenginx_ver"nginx/"n

Microsoft releases Windows Server vNext preview version 25335 Microsoft releases Windows Server vNext preview version 25335 Jan 10, 2024 am 08:49 AM

While Microsoft released the Win11 preview update for the desktop, today it also released the Windows Server Long Term Service Channel (LTSC) preview Build 25335. As usual, Microsoft did not publish a complete change log, or even provide a corresponding blog post. Microsoft has adjusted the Windows Server preview version update log to make it the same as the Canary channel version. If no new content is introduced, the official blog post will not be posted. Note from IT Home: The server brand has not been updated and is still Windows Server 2022 in the preview version. In addition, Microsoft calls these versions Windows Server vNext instead of the Windows version that is already on the market.

Steps to install GNOME 3 on Ubuntu Server 11.04 Steps to install GNOME 3 on Ubuntu Server 11.04 Dec 31, 2023 pm 03:59 PM

If you think there is no need to install a graphical interface when installing Ubuntu Server 11.04, let alone GNOME 3, which is not yet complete. . Or it should be built with ARCH+GNOME3. So please don't waste your time reading any more. It took 2 nights and a day and reinstalled N times. Finally something has come of it. It's not easy. Without further ado, let’s get to the point: Hardware: One ThinkPad (For X61) 2. Enter the boot options interface, select USB boot, and then choose to install Ubu

See all articles