How does fault tolerance work in Google Cloud SQL?

I intend to connect a PHP application (from a server outside the Googel cloud platform) to Google Cloud SQL. I want to know how I can create an application to properly restore my database.

According to the manual :

If a zone failure occurs and your wizard proceeds to your replica failure, any existing connections to the instance are closed. However, your application can reconnect using the same connection string or IP address; You do not need to update the application after failure.

Everything seems to happen automatically behind the scenes, but what if the database IP address is missing or expires?

+5
source share
1 answer

Google does not disclose here that it uses a server to provide a database service, but my guess is:

  • It uses a virtual IP address that routes traffic to the main connector, so when the wizard fails, the backup will advertise the virtual IP address, this will lead to a TCP connection failure.

The comment means that your mysqli.reconnect in php.ini must be enabled so that your PHP code automatically connects to the backup MySQL connector when a failure occurs. read here

If your mysqli.reconnect is enabled, you have nothing to worry about.

Edit: in response to a question raised regarding an SQL transaction. Of course, there will be a mess if the SQL transaction code is not written with the caution that the connection may disconnect at any time during the transaction, such a script should be processed by the code, and when automatic commit is turned on and you are not in the transaction, a simple auto-connection can solve practically any other scenario.

0
source

Source: https://habr.com/ru/post/1268991/


All Articles