Skip to content

Host-mounted database files, fixes #208 - #337

Merged
rfay merged 27 commits into
ddev:masterfrom
rfay:20170615_host_mount_db
Jul 5, 2017
Merged

rfay merged 27 commits into
ddev:masterfrom
rfay:20170615_host_mount_db

Conversation

@rfay

@rfay rfay commented Jun 16, 2017 •

Copy link
Copy Markdown
Member

The Problem:

OP #208 "Consider storing ddev db on host-mounted storage"

This is an experimental PR that allows people to experiment with the host-mounted database idea.

  • Update the ddev rm prompt that doesn't need to be as scary
  • Fix drush template that had wrong? creds
  • Rename .ddev/data to .ddev/import
  • Add /var/lib/mysql mount into docker-compose
  • Pre-create the directories in .ddev
  • Use alternate mysql container
  • Some platform/test refactoring that was done and probably didn't need to be. OTOH we may need to add an app.stop into tests after all so that linux tests can stop containers before deleting files for testsites.

The Fix:

The Test:

You can try this out with the artifacts at https://circleci.com/gh/drud/ddev/1128#artifacts/containers/0

Please make sure to:

  • ddev rm your existing site
  • rm -rf .ddev
  • ddev config again.

Automation Overview:

Related Issue Link(s):

Release/Deployment notes:

@rfay rfay self-assigned this Jun 16, 2017
@rfay

rfay commented Jun 16, 2017

Copy link
Copy Markdown
Member Author

I have to say I'm getting wildly varying results from ddev exec drush si -y, between 1:30 and 4:06 at least. I have no idea.

@rickmanelius

Copy link
Copy Markdown
Contributor

Going to kick the tires on this one.

@tannerjfco

Copy link
Copy Markdown
Contributor

@rfay I encountered similar wild variance when working on the performance tests as well. At the time, I suspected the update to Edge didn't happen cleanly, but didn't pin it down exactly. I'm pretty sure that after performing a full docker reset, the variance stopped for me.

@tannerjfco

Copy link
Copy Markdown
Contributor

I took this for a test spin with a clean Drupal 8 installation, and with a Commerce Kickstart installation, since I expect these two to be the most demanding.

Overall, in terms of feel, I couldn't really discern much of a difference with the db data host-mounted. I poked around the admin UI watching times on the Network dev tool, and nothing really felt slower, nor did I see a big difference in the load times I was seeing.

I also compared site installation of commerce kickstart, as its profile installation includes a migration of content from CSV. I posted the migration result and overrall install time here: https://docs.google.com/spreadsheets/d/1Ez9E9UTTbuwoOonqne_dfqauYYMfNMtybpiEWvLtLsE/edit#gid=0

There does seem to be an impact to write performance here, but I'm not sure if it's one we'll need to worry about, at least based on this case. We may want to try and identify some other write-intensive tasks developers might perform locally. Overall, the host mount seemed to add about 15s to the total installation, with notable but not drastic reductions in throughput on each of the migrations (number of nodes migrated per minute).

@tannerjfco

tannerjfco commented Jun 16, 2017 •

Copy link
Copy Markdown
Contributor

My feeling is that this would be reasonable to move forward on, at least based on my experience briefly testing it. There is a performance impact using a host mount, but it is not as significant as I would have expected.

With that said, this will involve some consideration to workflow changes:

  • Now that "remove" is no longer destructive, how will a user destroy the database if they want to?
  • How do I get to "clean" state again for a site?
  • Is "stop" still of benefit to users if "remove" is no longer destructive?

@rfay

rfay commented Jun 16, 2017

Copy link
Copy Markdown
Member Author

@tannerjfco some answers:
Destroy database (or clean slate) with:

  • (drupal) ddev exec drush sql-drop -y or
  • ddev rm -y && rm -rf .ddev/mysql or
  • ddev import-db

Could be that we no longer need rm and stop only would be just fine. stop <= rm, rm rm.

@rfay
rfay force-pushed the 20170615_host_mount_db branch from 513b9db to 1240216 Compare June 16, 2017 19:34
@rickmanelius

Copy link
Copy Markdown
Contributor

I'm mid-review, but wanted to respond to a recent question/comment about how to remove the db and what the future of remove or rm would be. I still think there is value is removing the containers because they need to be refreshed. Then the DB could potentially be removed by simply removing the .ddev/mysql directory, although we probably want to utilize ddev instead of manual intervention on the command line. Thinkng...

@rickmanelius

Copy link
Copy Markdown
Contributor

Setup

Going off #337 (comment), I'm using artifacts from https://circleci.com/gh/drud/ddev/1128. Confirmed ddev version output as follows:

cli:       	v0.7-17-g513b9db1
web:       	drud/nginx-php-fpm7-local:v0.7.3
db:        	drud/mysql-local-57:20170615_no_VOLUME
dba:       	drud/phpmyadmin:v0.2.0
router:    	drud/ddev-router:v0.4.2
commit:    	v0.7-17-g513b9db1
build info:	Built Fri Jun 16 13:10:14 UTC 2017 circleci@prealloc-isbzgmgb-1497618222493 drud/golang-build-container:v0.4.2

Performance Testing

  • Run ddev rm my drupal 7.54 app to remove database.
  • Run rm -rf .ddev to start from a clean state.
  • Run ddev config with defaults. Confirmed that within .ddev is a config.yml, import, and mysql directories.
  • I kept getting 500 and 501 errors until I removed the existing settings.php file.
  • Drupal 7 was incredibly snappy and performant post install. Very cool!
  • Drupal 8 initial install time was 5 minutes. Performance post install is adequete, but noticeable delays. FWIW, I have 3 sites up w/2GB of resources dedicated to Docker. Performance improves dramatically when I shut down the other two sites.
    • With all other sites stopped, the Drupal 8 install time was still 8 minutes.
    • Running a docker restart got the install time back to ~1:30. Clicking around the admin sections of the site is super snappy!
  • Running ddev rm, I can confirm the database persists when I use ddev start.

Recommendations

  • Using ddev describe, I conflated the two sets of mysql credentials (internal and external). Might need to better describe each of them so others don't make the same mistake I did when attempting a site install.
  • Several times when running ddev start I see the 500 and/or 501 error pages. A follow page load usually gets me to the install page, but I'm just noting a timing issue that leads to a somewhat false positive. Alternatively, we could basically instruct users that it might be caused by the fact that the containers are coming up and to attempt a refresh.
  • The massive performance delta on the site install time and performance was "fixed" by a docker restart. It seems like Docker for Mac is not able to release resources appropriately, and that can trickle down to our tests.

@rfay
rfay force-pushed the 20170615_host_mount_db branch from f7334cc to 081d1bb Compare June 16, 2017 19:58
@rickmanelius

Copy link
Copy Markdown
Contributor

Regardless of if we proceed with this PR or not, there is a legitimate question regarding what the future of the remove command. Inventorying what is possible to remove:

  • Containers
  • Database
  • Files
  • Configuration
    • Docker Compose
    • DDEV Config
    • App config (settings.php, wp-config).

A future state of remove may be to default to the most benign (containers) but offer flags to target each component. Something like...

  • ddev remove
  • ddev remove --db
  • ddev remove --files
  • ddev remove --config
  • ddev remove --all

The --all flag would essentially return a site back to a non-ddev state. It would remove the databse, the files, the containers, and the config.

@rickmanelius rickmanelius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I'm 95% there on approving, but want to sit with it for just a moment. I think we've thought through all the implications and the performance (biggest conern) is negligibly affected. We would still need to file a ticket to address the future of remove, but that's not necessary to combine. Ultimately, this feature may save us from many a pissed off users that too quickly hit the nuclear button and lost hours/days of work. To that end, we may wish to consider moving the database storage to ~/.ddev/mysql and then using the ddev commands to remove them, further protecting from a repo deletion (which a user might not expect would contain the DB).

@rfay

rfay commented Jun 16, 2017

Copy link
Copy Markdown
Member Author

Remember that files are actually stored on disk with the repo, so really ddev has no business removing them. They actually might not even have been put there by ddev; ddev import-files is actually kind of a silly (convenience) thing for us to provide, since it's just putting files in place right with the repo.

I agree with making a difference between removing the config and removing the db, although people should probably already know how to remove the db in very traditional ways. But the magic of removing a folder could be wrapped in ddev. Also, that way we could make sure to stop the db container before we did it, which could help make less of a mess.

@rfay rfay changed the title Experimental: Host-mounted database files Host-mounted database files Jun 16, 2017
@rfay rfay changed the title Host-mounted database files Host-mounted database files, fixes #208 Jun 16, 2017
@beeradb

beeradb commented Jun 19, 2017

Copy link
Copy Markdown
Contributor

I opened #340 as an alternative approach to this using named docker volumes.

Personally, I feel like just relying on built in docker named volume functionality to achieve these goals rather than host mounting the DB directory is probably the way to go from a maintainability perspective.

@rickmanelius

Copy link
Copy Markdown
Contributor

Nice! Similar to the review of this PR (#337), we'll want to see what the performance delta is as well as determine if this approach helps the end-user with data persistence (based on workflow).

@rickmanelius

Copy link
Copy Markdown
Contributor

This was value for experimentation/feedback, but adopted a different approach in #340. Closing this one out.

@rfay

rfay commented Jun 25, 2017

Copy link
Copy Markdown
Member Author

There were some while-I-was-there commits here that need to be grafted somewhere else, so I'll reopen this as a placeholder for getting those done.

@beeradb

beeradb commented Jun 28, 2017

Copy link
Copy Markdown
Contributor

As we rework this can we make sure to pull in the language changes from https://github.com/drud/ddev/pull/349/files#diff-5c1b23b6448d5099a5a94f5b2b0685f2 ? We should make sure we're clear that ddev rm is no longer destructive. It should also probably not have a the prompt unless a remove --remove-data flag is used.

@rfay
rfay force-pushed the 20170615_host_mount_db branch from e2229d2 to f83a62f Compare July 5, 2017 14:02
@rfay

rfay commented Jul 5, 2017 •

Copy link
Copy Markdown
Member Author

I rebased this against current master and triggered regular and nightly build jobs against it.

IMO it just needs the

@beeradb beeradb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading over the commits from the last few days + reviewing the MySQL docker work (https://github.com/drud/docker.mysql-local/pull/24) this looks to be ready to go.

I'm 👍 for bringing this in.

@rickmanelius

Copy link
Copy Markdown
Contributor

So it looks like there are two bullets requested by @rfay and then @tannerjfco can merge. Correct?

#337 (comment)

@rfay

rfay commented Jul 5, 2017

Copy link
Copy Markdown
Member Author

I fixed the things I had concerns about.
I didn't see anything new from @tannerjfco

I guess it's probably ready. I can pull it when you think you're ready @rickmanelius unless Tanner does have something.

@rickmanelius

Copy link
Copy Markdown
Contributor

@rfay At this time, I don't plan on a retest of the functionality from the end-user perspective unless you feel the underlying logic changed enough to warrant another pass through.

@rfay
rfay merged commit 0f959ea into ddev:master Jul 5, 2017
@rfay
rfay deleted the 20170615_host_mount_db branch July 5, 2017 20:33
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.

4 participants