tencent cloud

Feedback

Configuring Automatic Application Reconnection

Last updated: 2023-07-31 16:14:14

    This document describes the impact of seconds-level disconnection during instance switch and how to configure automatic reconnection.

    Background

    In case of adjusting database instance specification or upgrading database engine, the source instance is overloaded and hanging, hardware fails, etc., the instance may need to switch, causing disconnection for few seconds.

    If automatic reconnection is not configured, the application will disconnect after the source-replica switch and normal business access will be affected.

    We recommend that you configure automatic reconnection for applications and switch instances during the maintenance window.

    Configuring Automatic Reconnection

    To avoid application connection exceptions due to source-replica switch, we recommend that you configure automatic reconnection for TencentDB for MySQL applications by configuring the connection pool parameters, i.e., connectTimeOut and socketTimeOut.
    Configure parameter values according to business scenarios. For OLTP (Online Transaction Processing) business scenarios, both parameters should be configured as 20 seconds.

    Note:

    • connectTimeOut: Timeout period for the application to establish a TCP connection with the database server. We recommend that you configure this parameter with a value greater than the response time between the application and the database server.
    • socketTimeOut: Timeout period while waiting for a response after packets are sent over the TCP connection. We recommend that you configure this parameter to the maximum execution time for a single SQL statement.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support