Connection Pooling with Azure MySQL

HitenBhavsar-MSFT 281 Reputation points Microsoft Employee
2020-05-06T16:45:21.493+00:00

I am working on an application where I am using azure functions with Java and azure mysql db.

I want to manage connection pooling and for that i have used Hikari CP to manage the connections on the client/application end.

The problem is azure functions will be destroyed after some inactive time duration and it destroys the container so there is no point of connection pooling on client end?

Is there any other approaches or feature which provides server side connection pooling proxies?  AWS RDS provides db proxy which manages connection pooling.

I don't want to use separate proxy as it requires to configure another VM.

Thanks in advance.

[Note: As we migrate from MSDN, this question has been posted by an Azure Cloud Engineer as a frequently asked question] Source: MSDN

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
443 questions
No comments
{count} votes

Accepted answer
  1. Mike Ubezzi 2,771 Reputation points
    2020-05-06T16:52:14.55+00:00

    Please take a look at the following information, which basically details the methods available to implement connection pooling with Azure Functions along with a specific example of Connection Pooling with Azure Database for MySQL in Java. This logic needs to be written into your function app.

    Manage connections in Azure Functions

    To avoid holding more connections than necessary, reuse client instances rather than creating new ones with each function invocation. We recommend reusing client connections for any language that you might write your function in. For example, .NET clients like the HttpClient, DocumentClient, and Azure Storage clients can manage connections if you use a single, static client.

    Here are some guidelines to follow when you're using a service-specific client in an Azure Functions application:

    • Do not create a new client with every function invocation.
    • Do create a single, static client that every function invocation can use.
    • Consider creating a single, static client in a shared helper class if different functions use the same service.

    Java sample to illustrate connection pooling

    Provides a code sample for implementing Connection Pooling in Java for Azure Database for MySQL.

    No comments

0 additional answers

Sort by: Most helpful