Session Reuse

MySQL client programs may elect to resume a prior SSL session. Each full TLS exchange can be costly both in terms of computation and network overhead, less costly if TLSv1.3 is used. By extracting a session ticket from an established session and then submitting that ticket while establishing the next connection, the overall cost is reduced if the session can be reused — for example, web pages that open multiple connections benefit from faster connection setup.

Server-side

The SSL session cache can be reconfigured at runtime with the system variables ssl_session_cache_mode and ssl_session_cache_timeout, followed by ALTER INSTANCE RELOAD TLS.

ALTER INSTANCE RELOAD TLS reconfigures the active TLS context from the current values of the cache-related system variables. It also sets the cache-related status variables to reflect the new active cache values. New connections established after its execution use the new TLS context; existing connections remain unaffected.


Client-side

All MySQL client programs can reuse a prior session for new encrypted connections made to the same server, provided that the session data was stored while the original connection was still active. Session data is stored to a file, and that file is specified when the client is invoked again.

SET GLOBAL ssl_session_cache_mode=On;
SET GLOBAL ssl_session_cache_timeout=600; -- 10 minutes
SELECT @@ssl_session_cache_mode, @@ssl_session_cache_timeout;
ALTER INSTANCE RELOAD TLS;

@@ssl_session_cache_mode@@ssl_session_cache_timeout
1600

> mysql -u sgroot -p -P 3306 -h SG-prod5725-908-master.servers.mongodirector.com \
       --ssl-mode=VERIFY_CA --ssl_ca=<Path to ca.pem file>

mysql> ssl_session_data_print ~/private-dir/session.txt
......

> mysql -u admin -p --ssl-session-data=~/private-dir/session.txt