Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #
Proposed Changes
This is a PoC to see how easy/difficult it would be to add support for MySQL in Studio. The reason I created this experiment is because I think it would be valuable for folks who use Studio to pick the database of their choice. For now, I commented out SQLite support completely but we can implement a way to support both.
The way this is intended to work is that a user can select MySQL as their preferred database. Studio would then download pre-packaged MySQL binaries for the relevant OS (from our CDN). Once downloaded, Studio will manage an instance of MySQL for each site.
When a new site is created, a new instance will be provisioned. The configuration for the instance (my.cnf) and the data files will be stored in the Studio app directory. Other provisioning steps include setting up db users, updating the wp-config.php file with correct DB credentials, and finally running a conventional WordPress installation via wp cli.
Studio manages the instances and ensures they are stopped when Studio exits or a site is stopped/deleted. Studio also cleans up the data directory when a site is removed.
Todo
Performance
MySQL uses some memory. Each running instance will use around 120MB of memory. If you want to run many sites simultaneously, things will slow down.
The query performance is similar to SQLite, though the more data the DB holds the better it performs vs SQLite. The bottleneck is Webassembly/Playground, which is significantly (~12x) slower than using PHP directly but this is irrespective of which DB is used.
Testing Instructions
nvm use && npm install && npm run start
ps aux | grep mysql
and you should see an instance of MySQL running for each created site.Cleanup
There should not be a need to cleanup anything but if there were problems it is possible that the MySQL instances were not stopped correctly. You can run
ps aux | grep mysql
to see if there were any instances that weren't stopped. You can manually kill them if needed.Pre-merge Checklist