Skip to content
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

Remove the need to use MARS for SQL Server #1417

Closed
emleder opened this issue Dec 3, 2020 · 9 comments
Closed

Remove the need to use MARS for SQL Server #1417

emleder opened this issue Dec 3, 2020 · 9 comments

Comments

@emleder
Copy link

emleder commented Dec 3, 2020

We have 120+ sites hosted in Azure. Most of the time they run fine but they've been crashing and looking into it, there are database queries that sometimes take sub-second to run but otherwise can take almost 3 mins before it comes back. The site will crash when it does. And when it does, will sometimes also crash other apps within the same App Service. Feel free to directly contact me for more detailed info or if you want to walk through this over chat/zoom/etc.

Piranha long running query text
Piranha long running query lengths
Piranha long running queries

@tidyui
Copy link
Member

tidyui commented Dec 3, 2020

Hi there! We also run a lot of sites in Azure, and given the error description have you double checked that your Database Server isn’t running out of DTU’s at the same time as these errors occur, this is something that could happen if you run a lot of databases on the same server. The same goes for the App Service Plan, but this sounds more like a database performance issue.

Regarding the length of the queries this is simply how EF formats and creates them. In 9.0 we’re using a new feature in EF 5.0 where you split a query in multiple small ones instead of these large joined queries for better performance, but this is a completely new feature released with .net 5.

Please start by double checking DTU usage on all Azure instances before we proceed as it’s not logical that it’s code related when the same query performs badly every once in a while.

Best regards

Håkan

@emleder
Copy link
Author

emleder commented Dec 3, 2020

Thanks, I'll look into it. But question for you on Azure configuration. How many sites do you run per App Service Plan? How many databases per SQL server? Trying to strike a balance between performance and costs.

@firedog
Copy link

firedog commented Dec 10, 2020

I don't know if this applicable to the Azure environment...but I have experienced the same problems on a linux server (VPS) with SQL Server installed and Piranha sites running on the same server. I get sudden slowdowns for even the simplest queries and eventually the site will crash and require a restart.

There is an issue with MARS for the combo linux + SQL Server (dotnet/SqlClient#422). Maybe this could have something to do with it as Piranha requires MARS in the connection string when SQL Server is used.

I guess it should be possible to modify Piranha so that MARS wouldn't be required (or possibly support configurations both with MARS and without)?

@tidyui
Copy link
Member

tidyui commented Dec 12, 2020

@emleder We run about 25 web apps in the same plan & sql server. We could probably go higher as it’s cheaper to scale up than creating a new plan. It is however crucial that you use blob storage for the assets in all of the apps, otherwise your app service plan will run out of disc storage.

@tidyui
Copy link
Member

tidyui commented Dec 12, 2020

@firedog Good points. I’ll investigate what needs to be done to the application to eliminate MARS. We will also look into integrating the new connection pool functionality from EF Core 3.1 in the upcoming version. https://www.google.se/amp/s/neelbhatt.com/2018/02/27/use-dbcontextpooling-to-improve-the-performance-net-core-2-1-feature/amp/

@tidyui
Copy link
Member

tidyui commented Dec 12, 2020

I see now the functionality was actually introduced in 2.1, but I totally missed its existence 😁

@tidyui
Copy link
Member

tidyui commented Dec 12, 2020

@emleder Of course this all depends on what service level you have for your App Service Plan 😁

@tidyui
Copy link
Member

tidyui commented Dec 15, 2020

I'll go ahead and change the title of this issue and then create another one since it's really a combination of two things.

@tidyui tidyui changed the title Long running queries breaking sites in Azure Remove the need to use MARS for SQL Server Dec 15, 2020
@tidyui tidyui added this to the Version 9.1 milestone Dec 22, 2020
@tidyui tidyui modified the milestones: Version 9.1, Version 9.2 Mar 29, 2021
@tidyui tidyui modified the milestones: Version 9.2, Version 10.0 Jun 18, 2021
@tidyui tidyui self-assigned this Oct 11, 2021
@tidyui
Copy link
Member

tidyui commented Oct 11, 2021

All integration test have been verified and are running successful on SqlServer with MultipleActiveResultsets=false.

@tidyui tidyui closed this as completed Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants