MVC App extremly slow entity-framework-6 iis


I have build a web application in using EF-6 and MVC.

Recently, I setup this website on a new IIS Server, namely a Windows Server 2012 R2 with IIS8 and SQL Server 2016.

Now, I have abysmal load times. I think, this has to do something with the IIS. Because when I start the website on my developer laptop and configure it to use the production database, the load time is 220ms with 48ms spent on the SQL. That's ok, because the SQL-Server is on the other side of the VPN.

But when I execute the same code on the (production) IIS Server (database on the same server) I get consistent timing of around 1808ms for the code in the using Block - with 1.7ms spent on the SQL-Connection.

The code is really simple:

public ActionResult Index()
    List<User> users;
    using (MiniProfiler.Current.Step("DB-Query"))
        users = db.Users.OrderByDescending(u => u.IsActive).ThenBy(u => u.ShortName).ToList();
    return View("Index", users);

I tried remote debugging, but single-stepping just has the same delay of 1800ms between the db.Users() and the } brace.

Please note, that this is one of the simplest controller methods and the production database is empty. With actual data in the database, the controller methods take approximately 100x the time. As in 60-90 seconds for something my laptop does in .6-.9 seconds.

Things I have tried:

  • I thought, this could be because I renamed the database. Therefore I let the code-first migration rebuid the db from scratch. Still very slow.
  • I reinstalled in IIS on the webserver. Nothing changed.
  • Remote debugging, but it's just one step that takes 1800ms
  • Different browsers
2/21/2017 11:30:22 AM

Accepted Answer

The problem was solved by changing the connection string from "localhost" to "". Previously, the string was:

Data Source=localhost;Initial Catalog=...;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True

and now it is:

Data Source=;Initial Catalog=...;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True

This is mentioned in

5/23/2017 12:00:17 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow