What is max life time for a SQL connection in Azure SQL database?

Vipin Sharma 116 Reputation points
2022-04-06T08:37:04.127+00:00

I am trying to set maxLifetime property of HikariCP pool for my spring boot application. For this I need database specific max life time for a SQL connection, could not find any documentation on this. Most of the documentations talk about application level timeout we can set on a connection, what is exactly max life time for a SQL connection in Azure SQL database?

Can we say once created a connection remains there forever, until we don't restart database server?

I am following MS blog to use HikariCP: https://devblogs.microsoft.com/azure-sql/improve-jdbc-application-reliability-with-azure-sql-and-connection-pooling/

Azure SQL Database
0 comments No comments
{count} vote

Accepted answer
  1. Alberto Morillo 32,806 Reputation points MVP
    2022-04-06T10:10:49.493+00:00

    "When you connect to an Azure SQL Database, idle connections may be terminated by a network component (such as a firewall) after a period of inactivity. There are two types of idle connections, in this context:

    (1) Idle at the TCP layer, where connections can be dropped by any number of network devices.

    (2) Idle by the Azure SQL Gateway, where TCP keepalive messages might be occurring (which makes the connection not idle from a TCP perspective), but not had an active query in 30 minutes. In this scenario, the Gateway will determine that the TDS connection is idle at 30 minutes and terminates the connection.

    To address the second point and avoid the Gateway terminating idle connections, you can:

    (1) Use the Redirect connection policy to configure your Azure SQL data source.

    (2) Keep connections active via lightweight activity. This method isn’t recommended and should only be used if there are no other possible options."

    For more information, please read here.


0 additional answers

Sort by: Most helpful