easyengine icon indicating copy to clipboard operation
easyengine copied to clipboard

[MySQL] One container per site OR single container for multiple sites - which is better?

Open mbtamuli opened this issue 8 years ago • 16 comments

We have two approaches we can use for EEv4.

  • a single database container for multiple sites
  • a dedicated database container for each site.

Each approach has their pros and cons. Single database container will require less resources but will be accessible by all sites. Per site database container will ensure one site and its database is completely isolated, but will require more resources.

mbtamuli avatar May 08 '18 08:05 mbtamuli

Make it a dedicated one please as you could also use some other docker features like resource limiting on it. Just a thought :)

michacassola avatar May 08 '18 15:05 michacassola

That depends. If it is a shared dedicated server for hosting clients or not. Another case is about a remote database server (my case)

andremacola avatar May 09 '18 05:05 andremacola

I would prefer the resource savings. +1 single container

dmhendricks avatar May 11 '18 05:05 dmhendricks

+1 for Single Database Container for Multiple Sites.

nsgoyat avatar May 15 '18 14:05 nsgoyat

I think the choice will differ greatly on how folks will be using it. I mean, there are people that will choose option 1 because of their use case and others will choose option 2.

For my use case, option 2 would be better. Per site database container will be better because it will ensure one site and its database is completely isolated. I know it requires more resources but it feels to be the right approach to me.

"We" have been complaining about shared resources for years and doing that with EasyEngine would be counter-intuitive.

renatonascalves avatar May 15 '18 17:05 renatonascalves

If we need to choose only one option (??), then personally I'd go with 1on1 approach, for the typical WP performance sites. It's important to think about the scenario:

  1. Security implications are much worse than +10% resources/response times in almost any case

  2. Even for typical performance focused WP site, much of the DB work can be negated using caching anyway, either via memory cache or page cache. For small sites, there isn't much significance for 10% response times on DB queries.

  3. And, if you really need lots of DB queries and you think that this 10% response times diff is important, then: (a) you probably better upgrade the hardware anyway and (b) You probably running very active site, and security is more important.

  4. If you have an active site without users and security is not important, but still you don't use caching, then what exactly are you doing? computation? vast crawling? that's an edge case and perhaps more suitable for other systems or you're doing something wrong.

Having said that, security doesn't start or end in docker..

eddr avatar May 15 '18 17:05 eddr

@mbtamuli

In my opinion, a single container is probably the easiest solution, but it doesn't use the main feature of docker, the isolation and it will be less flexible in case of changes with the next ee releases.

Here some other reasons I have found to prefer dedicated container usage :

  • monitoring : netdata provides the ability to monitor docker containers without additional configuration, and it will be easier to identify what site use the server ressources.
  • migration : each site can be migrated on another server almost on the fly
  • compatibility : some applications other than wp, may require particular configuration on MySQL. This way, It will not impact other websites running on the same host, and each container can use it's own my.cnf
  • customization : users may want to use MySQL 5.7 instead of MariaDB 10.2, or vice versa. It will allow to use custom setup
  • Issues : in case of crash/recovery, most part of users will prefer to have only a single website down, instead of all sites.
  • features : To handle high traffic, docker can be used to setup a Galera Cluster on a single machine with increase availability, especially during container upgrade.
  • Security : To access database from the outside, it will be more secure to expose only the port of a container, instead of exposing all Database

VirtuBox avatar May 16 '18 00:05 VirtuBox

Putting everything from cron to mkdir in its own container is fine until your mobile phone has more RAM than your client is willing to pay for in a VPS instance.

dmhendricks avatar May 16 '18 01:05 dmhendricks

I think like @VirtuBox. Let us use the power of docker. Small performance difference is not worth ditching it all.

eddr avatar May 16 '18 11:05 eddr

+1 for one container per site. Migration, isolation, and security are important for me. Almost by definition if my sites aren't busy enough to need their own VPS, then they won't need the minor performance increase of having a shared DB container.

mikelittle avatar May 22 '18 15:05 mikelittle

+1 a dedicated database container for each site.

codente avatar May 22 '18 16:05 codente

I think dedicated database container is more useful

overdigo avatar May 24 '18 02:05 overdigo

+1 Dedicated database for each site. Reasons :

  • security
  • fine-tuning
  • ressource allocation
  • easier backup / duplication
  • etc...

pserafini avatar May 24 '18 11:05 pserafini

Thanks all for your inputs.

We did performance testing by creating 100s of WP sites with single shared MySQL container as well as one container per site. The results were quite close and inconclusive for practical performance consideration.

Here is how we are progressing:

  1. The default will be a one mysql container per site.
  2. EE v4, like v3 will support remote mysql connection during in site create command. The real-life use case for us to use Amazon RDS with WordPress sites. But if somebody wants to connect to "a single shared mysql container", they can create on such mysql host container and then pass its connection parameters during site creation.

If you see any issues with above, please report.

rahul286 avatar May 30 '18 06:05 rahul286

Should be moved to done in the project board. 😃

michacassola avatar May 31 '18 13:05 michacassola

@michacassola done :)

rahul286 avatar May 31 '18 17:05 rahul286