gpt4 book ai didi

c# - Azure Linux ASP 上运行的 .net core 与 Azure SQL 数据库之间的连接池问题

转载 作者:行者123 更新时间:2023-12-03 03:51:11 25 4
gpt4 key购买 nike

因此,我们希望将我们的解决方案从 Windows 迁移到 Linux ASP。该应用程序位于 Azure Front Door 后面,相同的代码在使用所有默认值的 Windows ASP 上运行得非常好。然而,当部署到 Linux 时,ASP 会导致非常长的响应时间。尝试更改运行状况检查协议(protocol)(HEAD 到 Get),但没有成功(检查路径只是/)。当我们从 AFD 中删除该应用程序时,它工作得很好,但我想我们无法重现高负载。数据库根本没有加载,它是S2。日志显示以下内容:

*

    Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database 'blabla' on server 'blablabla.database.windows.net'.
Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'blablabla'.
System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at Microsoft.Data.SqlClient.SqlConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.InitializeReader(DbContext _, Boolean result)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
[40m[1m[33mwarn[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[22]
Heartbeat took longer than "00:00:01" at ***. This could be caused by thread pool starvation.
[40m[1m[33mwarn[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[22]
Heartbeat took longer than "00:00:01" at ***. This could be caused by thread pool starvation.
[40m[1m[33mwarn[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[22]
Heartbeat took longer than "00:00:01" at ***. This could be caused by thread pool starvation.

想知道我们是否必须使用不同的 SQL 连接驱动程序?这是应用服务,我相信这是由平台本身处理的。

谢谢!

最佳答案

似乎您没有正确处理连接或者您正在执行弹性查询。由于跨“分片”的弹性查询,我们遇到了类似的问题。

这因您的数据库设置而异,因此请尝试引用此链接以了解弹性查询是什么。 https://learn.microsoft.com/en-us/azure/azure-sql/database/elastic-query-overview本质上不应该从一个数据库内跨多个分片进行查询,因为它会打开跨所有其他分片的连接。

关于c# - Azure Linux ASP 上运行的 .net core 与 Azure SQL 数据库之间的连接池问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66657610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com