question

Hiten004 avatar image
Hiten004 asked ·

Connection Pooling with Azure MySQL

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-mysql
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Mike-Ubezzi-MSFT avatar image
Mike-Ubezzi-MSFT answered ·

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.





Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.