locked
Slow on azure ... help? RRS feed

  • Question

  • User-2033772850 posted

    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:

    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()
    

    And this is my connection string:

     <add name="MyConnectionString"
       providerName="System.Data.SqlClient"        
       connectionString="Data Source=tcp:xxxx.database.windows.net,1433;Initial Catalog=xxxx;User ID=xxxx;Password=xxxxxx;"  />

     

    Thursday, March 10, 2016 1:37 AM

Answers

  • User-646145796 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 11, 2016 2:34 AM

All replies

  • User-821857111 posted

    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.

    Thursday, March 10, 2016 7:41 AM
  • User-646145796 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 11, 2016 2:34 AM