Configure ProxySQL

Sometimes you will need to set custom variables in ProxySQL configuration or you will want to cache some queries. This is possible using this tutorial.

Because we have the MySQL cluster horizontally scalable, we use ProxySQL to route queries to the right MySQL node.

Add custom configuration

NOTE

For now this feature is only available from the command line, but future releases will also include a graphical interface for it.

We added two hooks to insert your configs. Before setting up any config, have a look at the official documentation . The ProxySQL config looks like this:

admin_variables= { }

mysql_variables=
{
    // sane defaults set by us

    // hook to insert your extra MySQL variables using 'PROXYSQL_EXTRA_MYSQL_VARIABLES'
}

mysql_servers = ()

mysql_replication_hostgroups = ()

mysql_users =()

mysql_query_rules =
(
    // defaults rules set by us

    // hook to insert your extra MySQL query rules using 'PROXYSQL_EXTRA_QUERY_RULES'
)

To make things easier, let's define some helpful constants that will simplify our commands: the project namespace and the site name. Both can be found on the overview page of the site.

PROJECT_NS=<Site's Project Namespace>
SITE_NAME=<Site's Name>

Set MySQL global variables

To configure some extra MySQL variables, you have to set the PROXYSQL_EXTRA_MYSQL_VARIABLES key into the <Site Name>-proxysql secret. Don't forget your value should be base64 encoded.

First create a proxysql_extra_mysql_variables.txt file, that will contain your code, for example :

mysql_set_query_lock_on_hostgroup=0

For examples of extra configurations for the MySQL variables, a comprehensive list can be found here .

To apply it, patch the secret with the new key base64 encoded:

kubectl -n $PROJECT_NS patch secret $SITE_NAME-proxysql -p "{\"data\": {\"PROXYSQL_EXTRA_MYSQL_VARIABLES\": \"$(cat proxysql_extra_mysql_variables.txt | base64 -w0)\"}}"

Set query rules

The same steps should be done to set MySQL query rules. After creating the file proxysql_extra_query_rules.txt containing your rules, set PROXYSQL_EXTRA_QUERY_RULES using the following command:

{rule_id=10010, active=1, digest='0xBF001A0C13781C1D', cache_ttl=5000, apply=1},

You can find more details about ProxySQL query rules here .

NOTE

Don't forget the , (comma) at the end of each rule.

To apply it, patch the secret with the new key base64 encoded:

kubectl -n $PROJECT_NS patch secret $SITE_NAME-proxysql -p "{\"data\": {\"PROXYSQL_EXTRA_QUERY_RULES\": \"$(cat proxysql_extra_query_rules.txt | base64 -w0)\"}}"

See Also

Add a preemptible node

To reduce the costs, you can run PHP pods on cheaper nodes.

Invite a user to your organization

You can invite users to your organization, which will give them access to all the projects and sites [...]

Setup custom certificates for a site

We already take care of the certificate management, but if you want to use your own certificates you [...]