Search code examples
sql-serverdatabase-connectionazure-functionsconnection-pool

SQL Connections in Azure functions


Making a SQL connection is expensive and slow, so we use concepts like Connection Pools in 3-tier applications.

When using an Azure function that accesses a SQL database, we have to connect to the database and then execute our logic. Doesn't this make azure functions really slow? Doesn't this kill database performance by overusing connections?

Is there a way to use a reusable connection pool in Azure functions?


Solution

  • No, you will get the connection pooling on Azure Functions, similar to what you get in a "normal" App Service. Function instances are not recreated for each call; instead, multiple subsequent invocations may be served by the same instance. Each App Service Plan Instance will have its own connection pool.

    Of course, if you are under very high load and numerous instances are running in parallel, they will all hit your database at the same time. I.e. there is no cross-instance pooling.