From a DBMS point of view, the client connection is a valuable resource that must be carefully managed to control the use of system resources. In practice, all DBMS set the connection inactivity timeout, after which the given connection is closed unilaterally. Usually, applications will find out about this fact after the connection is broken.
In the case of MySQL, the client receives the message The MySQL server has gone away (error 2006)
. In this article, we will look at approaches that allow applications with long-lived connections to keep them alive as long as necessary. Examples will be provided for the standard MySQL database connection interface – mysql.connector
. Sample Language is Python3, as an application example, microservice will be used, implemented on the Tornado
framework.