[MySQL] One container per site OR single container for multiple sites - which is better?
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.
Make it a dedicated one please as you could also use some other docker features like resource limiting on it. Just a thought :)
That depends. If it is a shared dedicated server for hosting clients or not. Another case is about a remote database server (my case)
I would prefer the resource savings. +1 single container
+1 for Single Database Container for Multiple Sites.
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.
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:
-
Security implications are much worse than +10% resources/response times in almost any case
-
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.
-
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.
-
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..
@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
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.
I think like @VirtuBox. Let us use the power of docker. Small performance difference is not worth ditching it all.
+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.
+1 a dedicated database container for each site.
I think dedicated database container is more useful
+1 Dedicated database for each site. Reasons :
- security
- fine-tuning
- ressource allocation
- easier backup / duplication
- etc...
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:
- The default will be a one mysql container per site.
- EE v4, like v3 will support remote mysql connection during in
site createcommand. 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.
Should be moved to done in the project board. 😃
@michacassola done :)