SQL在负载测试中拒绝连接 [英] SQL refusing connection in load test

查看:59
本文介绍了SQL在负载测试中拒绝连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在系统上进行负载测试.在一定的负载水平下,我开始在日志中收到SQL错误:

I'm running a load test on my system. At a certain level of load, I start getting SQL errors in my log:

System.Data.SqlClient.SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接. (提供者:命名管道Prprovidererror:40-无法对SQL Server进行错误连接)---> System.ComponentModel.Win32Exception(0x80004005):找不到网络路径

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Prprovidererror: 40 - Could not operrorconnection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found

通过在有问题的SQL服务器上运行性能监视器,我发现了以下内容:

By running performance monitor on the SQL server in question, I found the following:

  • CPU级别很少超过50%. (在以前的迭代中,我看到它已达到100%的最大值,因此我增加了VM的规格,这有助于将问题推高到更高的负载水平.)
  • 用户连接数量已超过8,000. Sql Server的默认设置为32,767个最大连接数.
  • 连接字符串指定到每个数据库的1000个连接的最大池大小,并且服务器上有100个数据库.负载测试是随机分布在100个数据库之间的,因此应该有一个相当均匀的分布,即每个数据库大约80个连接.距离1k的限制还远.

还有哪些其他因素可能导致Sql Server停止接受连接?

What other factors might cause Sql Server to stop being able to accept connections?

更新:更多信息:我正在使用Entity Framework Core(EF7)进行数据库连接,如果有帮助的话.

UPDATE: extra info: I'm using Entity Framework Core (EF7) for my DB connections, if that helps any.

推荐答案

事实证明问题根本不在SQL上.问题出在我们的API服务器上,其中一些API分解了数百个并行线程,每个线程都与数据库建立了自己的连接.对于API服务器来说,负载实在太大了,它开始返回访问被拒绝"异常,甚至没有真正尝试连接到数据库.

It turns out the problem wasn't on SQL at all. The problem was on our API server, where some of the APIs were spinning off hundreds of parallel threads, each making its own connection to the database. The load was simply too much for the API server, and it started returning "Access Denied" exceptions without even really attempting to connect to the database.

解决方案:我们使用此答案中显示的模式,限制了被剥离的线程数量.

Solution: we throttled the number of threads being spun off, using the pattern shown in this answer.

这篇关于SQL在负载测试中拒绝连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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