The ASYNC_NETWORK_IO wait type is one of those wait types that can be seen very often by DBAs, and it can be worrisome when excessive values occur, as it is one of the most difficult wait types to fix.

ASYNC_NETWORK_IO等待类型是DBA经常看到的那些等待类型之一,当出现过多的值时,它可能会令人担忧,因为它是最难解决的等待类型之一。

It is important to know that ASYNC_NETWORK_IO name is adopted starting from SQL Server 2005, while in SQL Server 2000 this wait type is known as NETWORKIO. The original name of this wait type originates from the period of the slow Ethernet speeds of 10 Megabits and 100 Megabits that are commonly in use until the mid-2000s

重要的是要知道从SQL Server 2005开始采用ASYNC_NETWORK_IO名称,而在SQL Server 2000中,此等待类型称为NETWORKIO。 此等待类型的原始名称起源于2000年代中期之前通常使用的10兆位和100兆位的慢速以太网速度。

In most cases excessive values for this wait type are not actually related to any network issues (or it is a very rare case), especially in today’s very fast Ethernet speeds of 40 Gigabit or 100 Gigabit, and those of 200 Gigabit and 400 Gigabit speed that are under development at the moment.

在大多数情况下,这种等待类型的值实际上与任何网络问题都不相关(或者是非常罕见的情况),尤其是在当今非常快速的以太网速度(40 Gigabit或100 Gigabit,以及200 Gigabit和400 Gigabit速度)下目前正在开发中。

Excessive ASYNC_NETWORK_IO waits could occur under two scenarios:

在两种情况下,可能会发生过多的ASYNC_NETWORK_IO等待:

The session must wait for the client application to process the data received from SQL Server in order to send the signal to SQL Server that it can accept new data for processing. This is a common scenario that may reflect bad application design, and is the most often cause of excessive ASYNC_NETWORK_IO wait type values

会话必须等待客户端应用程序处理从SQL Server接收的数据,才能向SQL Server发送信号,表明它可以接受新数据进行处理。 这是常见的情况,可能反映了错误的应用程序设计,并且最常见的原因是过多的ASYNC_NETWORK_IO等待类型值

Network bandwidth is maxed out. A clogged Ethernet will cause the slow data transmission back and forth from the application. This, in and of itself, will degrade the efficiency of the application.

网络带宽已用尽。 以太网阻塞将导致从应用程序来回传输数据的速度变慢。 这本身将降低应用程序的效率。

客户端应用程序有问题 (A problem with the client application)

The most common reason for excessive SQL Server ASYNC_NETWORK_IO wait types is that the application cannot process the data that arrives from SQL Server fast enough. When an application requests large data result sets, slow data processing will cause data buffers to be filled, thus preventing SQL Server from sending new data to the client. Row by Agonizing Row (RBAR) processing is often the cause of such behavior and high ASYNC_NETWORK_IO wait type values. In RBAR application programming, only one row at a time is processed from the result set sent by SQL Server. In such a scenario, the complete result set, available for processing, is cached and then SQL Server is notified that the data set has been “processed”. This will allow SQL Server to send a new data set while the application is processing the data from the cached results set

过多SQL Server ASYNC_NETWORK_IO等待类型的最常见原因是应用程序无法足够快地处理从SQL Server到达的数据。 当应用程序请求大数据结果集时,缓慢的数据处理将导致数据缓冲区被填充,从而阻止SQL Server向客户端发送新数据。 逐行逐行(RBAR)处理通常是这种行为和较高的ASYNC_NETWORK_IO等待类型值的原因。 在RBAR应用程序编程中,一次仅从SQL Server发送的结果集中处理一行。 在这种情况下,将缓存可处理的完整结果集,然后通知SQL Server该数据集已被“处理​​”。 这将允许SQL Server在应用程序处理缓存结果集中的数据时发送新数据集

When an application that is using the RBAR processing is forced to work with a very large database environment (VLDB), it will often encounter issues in processing data. The server process (SPID) that is executes the batch will be forced to wait until the application manages to start processing the data stored in the buffer allowing SQL Server to send the new result set to the client (via buffer). And while waiting to send a new data requested by the application to a buffer for further processing it generates the ASYNC_NETWORK_IO wait type.

当使用RBAR处理的应用程序被迫与非常大的数据库环境(VLDB)一起使用时,它通常会在处理数据时遇到问题。 执行批处理的服务器进程(SPID)将被迫等待,直到应用程序设法开始处理存储在缓冲区中的数据为止,从而允许SQL Server通过缓冲区将新结果集发送到客户端。 在等待将应用程序请求的新数据发送到缓冲区以进行进一步处理时,它会生成ASYNC_NETWORK_IO等待类型。

So what DBAs can do when they encounter high ASYNC_NETWORK_IO wait type values on SQL Server? This involves investigating the application that is causing the excessive ASYNC_NETWORK_IO wait type values and often the coordinating with the application developers who created it. While investigating the excessive ASYNC_NETWORK_IO wait type values, the following should be checked

那么,当DBA在SQL Server上遇到较高的ASYNC_NETWORK_IO等待类型值时,该怎么办? 这涉及调查导致过多ASYNC_NETWORK_IO等待类型值的应用程序,并经常与创建它的应用程序开发人员进行协调。 在调查过多的ASYNC_NETWORK_IO等待类型值时,应检查以下内容

  1. Check whether the application is requesting large data sets from a SQL Server instance, and then if it filters those data on the client side. Pay attention to third-party applications like Microsoft Access or ORM software (aka Object relational mapping) for example, that may be requesting the large data sets that they are filtering on the client side. Using the read immediately and process afterwards programing method may often save users from excessive ASYNC_NETWORK_IO wait type values

    检查应用程序是否正在从SQL Server实例请求大数据集,然后检查它是否在客户端筛选这些数据。 请注意第三方应用程序,例如Microsoft Access或ORM软件(也称为对象关系映射 ),它们可能正在请求在客户端过滤的大型数据集。 使用立即读取和后续处理编程方法通常可以使用户避免过多的ASYNC_NETWORK_IO等待类型值

  2. Make sure that appropriate views are created for the client application, as this can ensure that data filtering is done by the SQL Server instance and therefore the significantly lower amount of data will be send to the client application

    确保为客户端应用程序创建了适当的视图,因为这可以确保由SQL Server实例完成数据筛选,因此将大量数据发送给客户端应用程序

  3. Make sure that the application is committing the opened transactions and that it committing them in a timely manner

    确保应用程序正在提交已打开的事务,并及时提交它们

  4. Check if there is the way to reduce the requested dataset in a way to perform data filtering on the SQL Server directly

    检查是否有一种方法可以减少请求的数据集,从而可以直接在SQL Server上执行数据筛选

  5. In case of individual or ad-hock queries, make sure that WHERE clause is added wherever it is possible and that query is properly optimized in a way to restrict the requested data set to only the required data

    如果是单个查询或ad-hock查询,请确保在可能的地方添加WHERE子句,并且已对查询进行了适当的优化,以将请求的数据集限制为仅所需的数据

  6. Check if it possible to use “TOP n” in the query to decrease the row number that will be returned by the query

    检查是否可以在查询中使用“ TOP n”来减少查询将返回的行号

  7. Scalar-Valued User Defined Functions (UDF) are often the cause of the high ASYNC_NETWORK_IO wait type due to RBAR, so look for any instances of these objects that may be affecting performance

    标量值用户定义函数(UDF)通常是由于RBAR而导致ASYNC_NETWORK_IO等待类型过多的原因,因此请查找这些对象的任何实例,这些实例可能会影响性能。

  8. Using a Computed Column Defined with a User Defined Function (UDF) with a large database is another frequent reason for the high ASYNC_NETWORK_IO wait type due to RBAR

    将具有用户定义函数(UDF)定义的计算列与大型数据库一起使用是由于RBAR而导致ASYNC_NETWORK_IO等待类型较高的另一个常见原因

  9. In case of SQL Server 2016, it is possible to use natively compiled UDFs that can significantly lower RBAR in most cases and to improve the execution speed up to 100%. This can be particularly useful in situations when refactoring UDF to a Table-Valued Function is not an option

    对于SQL Server 2016,可以使用在大多数情况下可以显着降低RBAR的本机编译UDF,并将执行速度提高到100%。 这在无法将UDF重构为表值函数的情况下特别有用

Note:
SQL Server Management Studio is an infamous client application for its reputation of generating ASYNC_NETWORK_IO wait type. SSMS reads the data stream in one row at a time and dealing with each row before retrieving the next row

注意:
SQL Server Management Studio是一个臭名昭著的客户端应用程序,以其生成ASYNC_NETWORK_IO等待类型的声誉而闻名。 SSMS一次读取一行数据流,并在检索下一行之前处理每一行

In addition, there are some other things that can be done by tweaking of SQL Server directly when it is needed to deal with situations when excessive ASYNC_NETWORK_IO waits values are encountered even when during the huge data loads processing on SQL Server side:

另外,当需要处理过多的ASYNC_NETWORK_IO等待值的情况时,甚至在SQL Server端处理大量数据时,也可以通过直接调整SQL Server来完成其他一些事情:

  • Enable Shared memory protocol for that SQL Server instance if it is not already done
    Use the following query to determine the protocol used for the current connection:

    如果尚未为该SQL Server实例启用共享内存协议
    使用以下查询来确定当前连接所使用的协议:

    
    SELECT net_transport
    FROM sys.dm_exec_connections
    WHERE session_id = @@SPID;
  • Make sure that client is connected using net_transport=’Shared memory’

    确保使用net_transport ='Shared memory'连接了客户端

If everything above is checked and SQL Server is still hit by high ASYNC_NETWORK_IO wait values, then it is the time to check potential network related issues that might cause such behavior. There are different causes that are generally caused by physical network limitation, malfunction or simple because of wrong network setup. The following should be carefully inspected in order to troubleshoot the network caused ASYNC_NETWORK_IO waits

如果检查了以上所有内容,并且SQL Server仍然受到较高的ASYNC_NETWORK_IO等待值的攻击,那么现在该是检查可能引起此类行为的与网络相关的潜在问题的时候了。 通常有不同的原因是由于物理网络限制,故障或由于错误的网络设置而导致的简单原因。 为了对由ASYNC_NETWORK_IO等待引起的网络进行故障排除,应仔细检查以下内容

网络问题 (Problems with the network)

  • Check network bandwidth between the SQL Server and client. Slow network adapters with bandwidth that does not correspond to the estimated amount of data that should be processed on the client side is the often reason for high ASYNC_NETWORK_IO waits values. 100 Megabits adapters are still present and they often cannot answer to demands of modern SQL Server databases and the amount of data processed. Even switching to 1 Gigabit adapters still leaves the system below current requirements in many environments. Using 10 Gigabits network adapters is something that is considered as a minimum for most environments, while 200 Gigabits and 400 Gigabits are something that many enterprises will have to switch in the near future, if they didn’t do that already

    检查SQL Server和客户端之间的网络带宽。 带宽不符合客户端应处理的估计数据量的带宽的慢速网络适配器是ASYNC_NETWORK_IO等待值较高的常见原因。 仍然存在100兆位适配器,它们通常无法满足现代SQL Server数据库的需求和处理的数据量。 即使在许多环境中,即使切换到1 Gigabit适配器,仍会使系统低于当前要求。 在大多数环境中,使用10 Gigabit网络适配器是一种最低要求,而在不久的将来,许多企业将不得不转换200 Gigabit和400 Gigabit,如果他们还没有这样做的话

  • Make sure that all network components between the SQL Server instance and the client, such as routers, switches, cables are properly configured, fully functional and dimensioned according to required bandwidth

    确保在SQL Server实例和客户端之间的所有网络组件(如路由器,交换机,电缆)均已正确配置,功能齐全且根据所需带宽确定了尺寸

  • Review the Batch requests per second counter values, as this could often indicate the reason for high ASYNC_NETWORK_IO waits. When Batch Requests are examined, what has to be examined is the number of T-SQL batches processed by SQL server since this is what will determine the number of batches SQL Server is processing per second. Servers with Batch Requests per second value larger than 1000 are considered as “busy”. The recommended value could be heavily dependent on the actual system configuration, activity level, and number of transactions being processed. It is not uncommon that this value can be significantly higher during peak hours

    查看“每秒批处理请求”计数器的值,因为这通常可以表明ASYNC_NETWORK_IO等待时间过长的原因。 检查批处理请求时,必须检查的是SQL Server处理的T-SQL批处理的数量,因为这将确定SQL Server每秒处理的批处理数量。 每秒“批处理请求”值大于1000的服务器被视为“忙”。 推荐值可能在很大程度上取决于实际的系统配置,活动级别以及正在处理的事务数量。 在高峰时段,该值可能会更高,这并不罕见

    When the Batch requests per second counter value is close or larger than 3,000 is encountered on a 100 Megabits network, this is almost certainly an indication that network speed is the bottleneck and resulting in the high ASYNC_NETWORK_IO waits values. With servers hitting easily over 20,000 Batch requests per seconds in these days, it is smart to consider upgrading 1 Gigabits or lower networks to 10 Gigabits to meet the increasing demands for SQL Server data processing

    当在100兆位网络上遇到“每秒批处理请求”计数器值接近或大于3,000时,这几乎可以肯定地表明网络速度是瓶颈,并导致高ASYNC_NETWORK_IO等待值。 如今,随着服务器每秒轻松处理超过20,000个批处理请求,考虑将1 G或更低的网络升级到10 G来满足对SQL Server数据处理不断增长的需求是明智的。

  • Checking the NIC bandwidth utilization is prudent, even often overlooked.

    谨慎检查NIC带宽利用率,甚至经常被忽略。

    Using Perfmon it is easy to calculate the network utilization via the formula:
    Network utilization %= ((Total Bytes\Sec * 8)/current bandwidth) * 100

    使用Perfmon,可以通过以下公式轻松计算网络利用率:
    网络利用率%=((总字节数\秒* 8)/当前带宽)* 100

    If values are larger than 60% on regular basis, switching to a faster network adapter/network bandwidth is highly advisable in order to ensure that enough bandwidth can be allocated when needed for data processing

    如果值通常大于60%,则强烈建议切换到更快的网络适配器/网络带宽,以确保在需要进行数据处理时可以分配足够的带宽。

  • Make sure that Auto Negotiate of the NIC is detecting the network bandwidth properly

    确保NIC的自动协商正确检测到网络带宽

    To check the current speed of all active network connection, use the following CLI command

    要检查所有活动网络连接的当前速度,请使用以下CLI命令

    wmic NIC where NetEnabled=true get Name, Speed

    Wmic NIC,其中NetEnabled = true获取名称,速度

    In case that Auto negotiation for a specific adapter is not picking the correct network speed, it is possible to set up the NIC speed manually in the NIS properties

    如果针对特定适配器的自动协商未选择正确的网络速度,则可以在NIS属性中手动设置NIC速度

翻译自: https://www.sqlshack.com/reducing-sql-server-async_network_io-wait-type/

减少SQL Server ASYNC_NETWORK_IO等待类型相关推荐

  1. sql server 各种等待类型-转

    等待的类型 资源等待 当某个工作线程请求访问某个不可用的资源(因为该资源正在由其他某个工作线程使用,或者该资源尚不可用)时,便会发生资源等待.资源等待的示例包括锁等待.闩锁等待.网络等待以及磁盘 I/ ...

  2. sql server线程等待信息

    返回执行的线程所遇到的所有等待的相关信息. 可以使用此聚合视图来诊断 SQL Server 以及特定查询和批处理的性能问题. 来自微软官方 https://msdn.microsoft.com/zh- ...

  3. SQL 各种锁等待类型 wait type--sys.dm_os_wait_stats 表

    返回执行的线程所遇到的所有等待的相关信息.可以使用该聚合视图来诊断 SQL Server 以及特定查询和批处理的性能问题. 列名 数据类型 说明 wait_type nvarchar(60) 等待类型 ...

  4. sql server 的 money类型

    sql server的 money 类型其实就是小数类型 decimal ,我不喜欢用它,因为有一次什么工具生成,发现它自动把money类型转换成了decimal类型了,与其让它转,还不如自己设计数据 ...

  5. sql server 中将datetime类型转换为date,或者time

    sql server 中将datetime类型转换为date,或者time 2008年01月14日 星期一 14:46 这个转换总是记不住,用到的时候就找,现贴上来,以备查用. datetime类型转 ...

  6. SQL SERVER的字段类型说明

    SQL SERVER的字段类型说明 1.SQL SERVER的数据类型 数据类型是数据的一种属性,表示数据所表示信息的类型.任何一种计算机语言都定义了自己的数据类型.当然,不同的程序语言都具有不同的特 ...

  7. SQL Server中TEXT类型操作

    SQL Server中TEXT类型字段值在数据库中追加字符串方法 对text类型字段值进行追加更新的操作,一开始用了简单的update语句试了试,有错误,原来text.ntext类型的字段不能和 va ...

  8. server sql 中类型为bit应该插入什么值_关于SQL Server中bit类型字段增删查改的一些事...

    前言 本文主要给大家介绍了关于SQL Server中bit类型字段增删查改的一些事,话说BIT类型字段之前,先看"诡异"的一幕,执行Update成功,但是查询出来的结果依然是1,而 ...

  9. oracle 图片 显示不出,Sql Server 中image类型迁移到Oracle 中Blob类型出现图片显示不出来,why????请博客们帮忙 | 学步园...

    我现在在一项目中碰到这么一个问题 Sql Server 中image类型迁移到Oracle Blob类型出现图片显示不出来,我在Sql Server 中看了一条image数据 如下: 1.Sql Se ...

最新文章

  1. 【怎样写代码】确保对象的唯一性 -- 单例模式(一):问题案例
  2. “决胜算力时代 ”AI算力高端闭门分享会(7月21日)
  3. 热点:3个故事概览突飞猛进的肠道病毒组研究
  4. mysql中文乱码的一点理解
  5. 内容分析在用户反馈分析中的应用
  6. Redis源码分析(一)redis.c //redis-server.c
  7. 用java编写圆锥_求java大神帮忙 求大神帮助!Java
  8. MySql常用语句 转
  9. 【深度学习】基于TextCNN实现文本分类
  10. 南海滩饮食法——不饿的情况下快速减肥的法宝
  11. 【资料整理】高精地图
  12. uTorrent设置,防止出现磁盘负荷100%
  13. A hybrid CNN-LSTM model for typhoon formation
  14. 淘宝双十一喵糖总动员玩法攻略 双11扔喵糖占领格子战队怎么玩
  15. 制作WIN10U盘启动盘
  16. Linux 压缩、解压工具
  17. Golang 获取今天和昨天零点的时间
  18. 编程世界,我的世界。
  19. Python:王者荣耀壁纸爬取
  20. 2022年校招互联网大厂薪酬状况如何?“白菜”总包接近40W是真是假?

热门文章

  1. cout不明确什么意思_王源吸烟粉丝说不袒护,让他谨慎交友是什么意思?
  2. python语言的变量特点随时_python程序设计——基本语言特性
  3. 深入理解Android(二):Java虚拟机Dalvik
  4. JavaWeb——Servlet开发3
  5. Core Animation 文档翻译 (第二篇)—核心动画基础要素
  6. 爬虫下载百度贴吧图片
  7. chrome调试技巧
  8. windows里面的批处理命令不停地处理同一条命令
  9. Servlet(2) ---2004
  10. 句句真研—每日长难句打卡Day12