Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No sqlite #1

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open

No sqlite #1

wants to merge 2 commits into from

Conversation

jeroenpf
Copy link
Owner

@jeroenpf jeroenpf commented Jul 15, 2024

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

  • Version management. I hardcoded paths to locally downloaded binaries for now but the idea is that these will be downloaded from our CDN.
  • Fix MySQL issues in Playground
  • Automatic login does not work, you need to manually login with username + password.

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

  • Some hardcoded paths need to be changed. DM me to get the binaries.
  • Once the paths have been adjusted, you can run Studio using nvm use && npm install && npm run start
  • Create one or more new sites.
  • Run 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

  • Have you checked for TypeScript, React or other console errors?

@adamziel
Copy link

adamziel commented Aug 9, 2024

Also be sure to check TIDB. It’s available as WASM so you wouldn’t need to worry about MySQL binaries, operating systems, OS architectures etc. TIDB claims to have a lot of compatibility with MySQL, but I don't know how viable is it for WordPress.

@jeroenpf
Copy link
Owner Author

jeroenpf commented Aug 9, 2024

Thanks for the suggestion @adamziel i will take a closer look at it to see if it could be a solution. It would indeed make things easier if we dont need to juggle with all the permutations of OS and architectures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants