I manage several WordPress websites including some that are very high traffic websites. These high traffic websites are hosted on multiple web servers to load balance the traffic (web servers point to the same database). When someone visits the URL, the load balancer directs the traffic to one of the web nodes to reduce the load on a single server.
Now when I connect the child site using the URL, a random node gets connected to the MainWP dashboard and only that node receives updates, but the other nodes don’t.
Is there a way to connect to the individual web server nodes separately (using IP or some other method) so I can manage all web servers nodes for a single WordPress website from the MainWP dashboard?
Now the problem is adding them as unique sites in MainWP Dashboard since the web servers all point to the same Database.
Adding the 1st URL goes through normally. On adding the 2nd URL, I get the following error:
Error detected: This site already contains a link. Please deactivate and reactivate the MainWP plugin. Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again.
I get that because the connection was completed in the DB by the 1st web server URL, and closed once it connected. Since the web servers share the DB it’s not open for more connections.
Is there a way around it, to let other web servers of the same site connect to the same source MainWP dashboard?
In case you connect the site as a single instance, actions you take in your Dashboard reflect only to one file system depending on the load balancer’s direction.
In case you try to connect each file system and as a separate site in your Dashboard, only the first one gets connected because once the first one is connected and public & private OpenSSL keypair is set, DB is locked for further connections (this one of the MainWP security measures that ensures that one child site can be connected only to one MainWP Dashboard at the same time).
For this kind of setup, we do not have out of box solution, but this surely is an interesting case that we have our dev team looking into and looking for a solution. For a start, they are working on a hook that should help.
As soon as I get more info from them, I will update you.
After you add the first one, you need to use that subdomain in the $one_added_url variable, the other subdomains, you need to list in the $balance_urls array, and after that try to connect them all.
MainWP was not designed for this type of set up and we have no way of testing it. Theoretically, this code snippet should allow things to work for you but again it is untested so be sure to test it and use it at your own risk.
@bogdan Thank you and the MainWP team for the swift response! I will test it out.
May I ask if the modified MainWP Dashboard version will be supported with updates? Or when MainWP comes out with a new version and if I update this version will get overwritten?
To be clear, our dev team created this custom solution specifically for you. Since this is a first-of-its-kind request, we’re not yet committing to integrating it into our core product or providing ongoing support.
Here’s our current stance:
We need to ensure it works flawlessly in your setup.
We’ll need time to better test it on our end.
Your feedback will be crucial in determining next steps.
For now, please go ahead and install it. We’re eager to hear how it performs for you. Your experience will help guide our decisions about potential future support and updates.
Keep in mind, if you update to a new MainWP version, it might overwrite these custom modifications. We’ll cross that bridge when we come to it.
Tried adding https://server2.website.com/ on MainWP dashboard, but getting same error as before: Error detected: This site already contains a link. Please deactivate and reactivate the MainWP plugin. Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again.
Thanks @bogdan. I replaced the mainwp plugin with the updated version you provided, it’s still giving the same error:
Error detected: This site already contains a link. Please deactivate and reactivate the MainWP plugin
Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again
I have a question that popped into my head while reading this thread: Why does OP not simply declare an exception to his load balancer that maps the IP of the MainWP Dashboard to a specific target server permanently? Surely one of the servers is the file master and the other ones are synced to it? Seems a bit odd to have the folks here compensate for OP’s esoteric setup. I know, I know… I exaggerate ;D
Thank you for your patience as our development team explored potential solutions.
After a thorough investigation and multiple attempts, we have determined that it is not possible to achieve the desired functionality with your current configuration at this time. The MainWP Plugin is not designed to support environments with a single database and multiple file systems distributed across different servers.
Additionally, we believe it would be inappropriate to pursue this further as we cannot be 100% certain of how it would function. Given the high-traffic nature of your website, we do not want to jeopardize its stability or performance.
We understand this might be disappointing news, and we regret any inconvenience this may cause.
I was wondering about this setup too. It seems like this setup would cause problems with every plugin, not just MainWP Child. Not to mention some other functions in WordPress like media uploads or auto-updates.
I certainly see the desirablility of using MainWP to help manage a load-balanced setup like this. I admit I have no experience using load balancing with WordPress, but my intuition is that in addition to using a single database I would want to use a shared filesystem. Or at least separate filesystems that are synced in some way. If using a shared filesystem, then it wouldn’t matter which node is connected with MainWP because they would all function the same. If the filesystems are synced, then the idea from @svt of having an exception for the MainWP Dashboard to always target the same “authoritative” node makes sense. And maybe a set of hooks to trigger a filesystem sync after MainWP child does any updates to the filesystem.