Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 10 / SQL Server 2017 / very slow connections with classic ASP

Tags:

sql-server

iis

I've been running classic ASP / SQL Server 2008 R2 / Windows Server 2012 R2 / IIS 8 for about 10-15 years; no problem. But I'm trying to get these same scripts to run on a new machine with Windows Server 2016 (IIS 10) and SQL Server 2017, and am having problems with connections to the databases. (And rewriting them in ASP.NET isn't an option for right now).

For example, I'll create a connection to the database:

set conn = server.CreateObject("ADODB.Connection")  
conn.ConnectionTimeout=120  
conn.Open("Provider=sqloledb;Data Source=(local);Initial Catalog=myDatabase;Integrated Security=SSPI")

First problem, it takes two seconds (exactly two seconds, for every connection) to create the connection. And even though the connection is supposed to stay open, subsequent connections (same db; same connection string) on that page or another page take exactly two seconds (even though I've set the ConnectionTimeout to 120 seconds).

Second problem (more serious), it then takes two seconds (almost exactly two seconds) to do any operation on that connection, even if it's just one row, e.g.:

sql = "update myTable set zipCode = 91839 where ID = 12345"  
conn.execute(sql)

And then if I do another update (for example) on just one row, it takes another two seconds (almost exactly two seconds):

sql = "update myTable set zipCode = 02930 where ID = 67890"  
conn.execute(sql)

With the previous setup (SQL Server 2008 R2 / Windows Server 2012 R2 / IIS 8), it took a couple of milliseconds to create a connection, and then simple updates like those above would take 1-2 ms. But now every connection and every operation on that connection takes two seconds + the amount of time that it should take (e.g. 2 ms).

I'm guessing that somehow the default settings for SQL Server connections in IIS 10 have changed and that's what's causing the problem, but I'm not sure. BTW, I'm using the default IUSR account in IIS to connect to SQL Server (both in the old setup and now).

like image 859
CorpusProf Avatar asked Nov 07 '22 20:11

CorpusProf


1 Answers

As per my comment on the question was correct, I will just make it as an answer for everyone else:

Please try the following (each one or a combination of) change on your connection string:


    Integrated Security=True
    Provider=SQLNCLI11

The SSPI works well with both SQLClient & OleDB that is why it is usually preferred but maybe the compatibility portion makes it slower as it tries to gracefully make everything correct. The provider portion change from sqloledb to SQLNCLI11 forces the engine to use SQLClient as most likely you are using SQL Server, no need to go for compatibility again (let us say switching to Oracle). Compatibility takes a performance hit sometimes.

Reference(s):

What is the difference between Integrated Security = True and Integrated Security = SSPI?

Difference between Sql Connection and OLEDB Connection

like image 85
Earl Avatar answered Nov 12 '22 16:11

Earl