Version 0.3.0 of dbdeployer has gained the ability of deploying multiple sandboxes concurrently. Whenever we deploy a group of sandboxes (replication, multiple) we can use the
--concurrent flag, telling dbdeployer that it should run operations concurrently.
What happens when a single sandbox gets deployed? There are six sets of operations:
- Create the sandbox directory and write down its scripts;
- Run the initialisation script;
- Start the database server;
- Run the pre-grants SQL commands (if any;)
- Load the grants;
- Run the post-grants SQL commands (if any;)
When several sandboxes are deployed concurrently, dbdeployer runs only the first step, and then creates a list of commands with an associated priority index. These commands are assembled for every sandbox, and then executed concurrently for every step.
The sequence of events for a deployment of three sandboxes in replication would be like this:
- Create the sandbox skeleton for every sandbox;
- Initialise all database servers;
- start all the servers;
- run the pre-grants, grants, post-grants scripts.
- Runs the group initialisation script (start master and slaves, or setup group replication).
Depending on the computer architecture, the server version, and the number of nodes, the speed of deployment can increase from 2 to 5 times.
Let's see an example:
$ time dbdeployer deploy replication 5.7.21
$ time dbdeployer deploy replication 5.7.21 --concurrent
There is a significant speed increase. The gain rises sharply if we use an higher number of nodes.
$ time dbdeployer deploy replication 5.7.21 --nodes=5
$ time dbdeployer deploy replication 5.7.21 \
As we can see, the time for deploying 5 nodes is roughly the same used for 3 nodes. While the sequential operations take time proportionally with the number of nodes, the concurrent task stays almost constant.
Things a re a bit different for group replication, as the group initialisation (which happens after all the servers are up and running) takes more time than the simple master/slave deployment, and can't be easily reduced using the current code.
A similar optimisation happens when we delete multiple sandboxes. Here the operation is at sandbox level (1 replication cluster = 1 sandbox) not at server level, and for that reason the gain is less sharp. Still, operations are noticeably faster.
There is room for improvement, but I have seen that the total testing time for dbdeployer test suite has dropped from 26 to 15 minutes. I think it was a week end well spent.