We are moving our site to azure, and I am noticing a significant speed difference -- the site is very slow on azure. The database is an azure SQL. I am a beginner. I am hoping someone can point me to some basic troubleshooting steps to find the source
of the slowness.
In case it's relevant, right now I open and close database connections several times on one page, rather than leaving the connection open a long time. So the database connection may open and close several times as the page loads. This is my basic code
and connectionstring:
Dim sql
Dim connectionString As String
Dim dbconn As System.Data.SqlClient.SqlConnection
Dim dbcomm As System.Data.SqlClient.SqlCommand
Dim dbread As System.Data.SqlClient.SqlDataReader
sql = "SELECT * FROM table"
connectionString = ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
dbconn = New System.Data.SqlClient.SqlConnection(connectionString)
dbconn.Open()
dbcomm = New System.Data.SqlClient.SqlCommand(sql)
dbcomm.Connection = dbconn
dbread = dbcomm.ExecuteReader()
If dbread.HasRows Then
Do While dbread.Read()
'do stuff
Loop
End If
dbread.Close()
dbconn.Close()
right now I open and close database connections several times on one page, rather than leaving the connection open a long time. So the database connection may open and close several times as the page loads.
While your code appears to close the connection, it probably doesn't. It marks the connection as not being used. Then it is returned to the connection pool where it is available for the next request. Having a pool of available open connections actually improves
performance.
If the performance declined dramatically only after the application was deployed to a new environment, then it would be reasonable to assume that the issue is environment-related, not code-related.
If you mean the initial request takes long and then any subsequent requests are fast, then that would be because you are hitting .NET apps cold start. Many .NET apps are slow to JIT and
load all their .NET requirements, but once everything is loaded, they are fast. If you want to avoid this problem, please try to enable "always on", Enabling Always On essentially causes Azure to automatically ping your site periodically to ensure that it
remains in a running state. Please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/ for more information.
If it is not a problem that I describe above. I would suggest you choose Azure web app and Azure SQL Database in the same region. It is the easiest way to increase the performance.
Best Regards,
Jambor
Jambor
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
Member
13 Points
68 Posts
Slow on azure ... help?
Mar 10, 2016 01:37 AM|geog272|LINK
Hi there,
We are moving our site to azure, and I am noticing a significant speed difference -- the site is very slow on azure. The database is an azure SQL. I am a beginner. I am hoping someone can point me to some basic troubleshooting steps to find the source of the slowness.
In case it's relevant, right now I open and close database connections several times on one page, rather than leaving the connection open a long time. So the database connection may open and close several times as the page loads. This is my basic code and connectionstring:
And this is my connection string:
All-Star
194531 Points
28084 Posts
Moderator
Re: Slow on azure ... help?
Mar 10, 2016 07:41 AM|Mikesdotnetting|LINK
If the performance declined dramatically only after the application was deployed to a new environment, then it would be reasonable to assume that the issue is environment-related, not code-related.
Contributor
3325 Points
403 Posts
Re: Slow on azure ... help?
Mar 11, 2016 02:34 AM|Jamobor yao - MSFT|LINK
Hi,
If you mean the initial request takes long and then any subsequent requests are fast, then that would be because you are hitting .NET apps cold start. Many .NET apps are slow to JIT and load all their .NET requirements, but once everything is loaded, they are fast. If you want to avoid this problem, please try to enable "always on", Enabling Always On essentially causes Azure to automatically ping your site periodically to ensure that it remains in a running state. Please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/ for more information.
If it is not a problem that I describe above. I would suggest you choose Azure web app and Azure SQL Database in the same region. It is the easiest way to increase the performance.
Best Regards,
Jambor
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.