-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Huge performance problem with async #1562
Comments
Hi @equist Thank you for sharing here.
|
.NET 6 on Windows. The App Service, SQL Azure and VNET are all in the same Azure region (North Europe). We see simlar problems when running locally (on a dev box) even though not with same load. I've read those, but #1206 seemed to only happen intermitent, but we reproduce this all the time and never with acceptable results for async method. |
Having the same issue here... It's an async issue with the SQL client for large fields - Changing the nvarchar(max) to nvarchar(255) for example helped alot. |
Large fields is an identified issue since earlier, but we get slow performance for small fields too. |
I removed all async db calls but can’t in the identity which is causing me issues. Seems like sqlclient is just broken for async. |
When switching to Linux App Service the problems disappeared. We haven't tested the downscaled example used in this issue, but the full application is scaling very well on Linux. |
Chiming in with, we are seeing this issue as well and can see it reported within our APM tool. Rolling back to sync call cuts the time in half. |
Async performance is completely unacceptable. In one particular instance changing from |
We are trying to scale an application that uses ASP.NET Identity (which is all async) and we have huge performance issues with all async work against SqlClient (we believe it has boiled down to this). We have investigated and tried many different things for a couple of weeks, and we now have very little isolated code that performs more or less equally bad all the time. The code has implementation of both sync and async calls with huge differences between them. We have read about the issues for big fields, but we see the problem on all our queries (without any big fields) and the reproduced slow calls below has no large fields.
We run in Azure with an App Service plan of P1V2 scaled to two instances and an SQL Azure Premium P1: 125 DTUs. We don't see any performance problems at all in SQL Azure. We have a VNET with a private link between the App Service and SQL Azure. We use Azure Load test to run the tests (and we can share the tests too if needed). We also get similar results when testing locally.
We use Stackify Retrace for monitoring and have enabled that through their extension.
Sync code performance when running 10 instances with 250 threads:
90%: 4,69 sek
Average: 1,417 sek
Open Connection: <0,001 sek
Select Logins: 0,002 sek
Async code performance when running 10 instances with 250 threads:
90%: 5,38 sek
Average: 2,235 sek
Open Connection: 1,624 sek
Select Logins: 0,298 sek
Sync code performance when running 45 instances with 250 threads, each thread making 10 calls after each other:
90%: 40,21 sek
Average: 17,502 sek
Open Connection: <0,001 sek
Select Logins: 0,006 sek
Async code performance when running 45 instances with 250 threads, each thread making 10 calls after each other:
90%: 80,97 sek
Average: 35,080 sek
Open Connection: 19,634 sek
Select Logins: 7,975 sek
Table script:
`
CREATE TABLE [security].[AspNetUserLogin](
[LoginProvider] [nvarchar] (100) NOT NULL,
[ProviderKey] [nvarchar] (100) NOT NULL,
[TenantId] [uniqueidentifier] NOT NULL,
[ProviderDisplayName] [nvarchar] (450) NULL,
[UserId] [uniqueidentifier] NOT NULL,
CONSTRAINT [PK_AspNetUserLogin] PRIMARY KEY CLUSTERED
(
[LoginProvider] ASC,
[ProviderKey] ASC,
[TenantId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [security].[AspNetUserLogin] WITH CHECK ADD CONSTRAINT [FK_AspNetUserLogin_AspNetUser_UserId] FOREIGN KEY([UserId])
REFERENCES [security].[AspNetUser] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [security].[AspNetUserLogin] CHECK CONSTRAINT [FK_AspNetUserLogin_AspNetUser_UserId]
GO
`
Data: The table is empty
ASP.NET Code (.NET 6 and Microsoft.Data.SqlClient 4.1.0 (we have tried with version 5 too). We started with a default .NET 6 template, added support for controllers and removed authorization, https redirection and exception handler.
The controller:
`
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
namespace SyncAsyncPerf.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class LoadTestController : ControllerBase
{
private const string _connectionString =
"Server=tcp:ourserver.database.windows.net;Authentication=Active Directory Managed Identity;Initial Catalog=oursqldb;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Max Pool Size=5000;Min Pool Size=100";
}
`
Finally, some notes on the connection string. We have tried many different configurations without effecting the underlying problem. If we use defaults for connection pooling the number of errors increases rapidly, especially for async code because of connection timeouts.
The text was updated successfully, but these errors were encountered: