# Load balancing question



## fred974 (May 2, 2017)

Hi guys,

Could anyone please tell me if I can create a web and database load balancing with several jails inside the same physical server?

Will I get any benefit or is load balancing only really usefull when done accros multiple physical servers?

Thank you


----------



## SirDice (May 2, 2017)

It's possible and you will get some benefits. Like being able to shutdown one or more jails without taking the whole service down. But you're still going to have a problem when this one single physical server breaks (hardware tends to break after some time). So if you want to do this right you're going to need to find a balance between the number of physical servers and jails.


----------



## fred974 (May 2, 2017)

SirDice said:


> you're still going to have a problem when this one single physical server breaks


I am somehow planning to have replication on another physical server as I ahve 2 physical server at my disposal
Here is a diagram 
	
of what I have in mind
1. Should I combine HAProxy to load balance both the web and DB cluster?
2. Should I install the databases on the same server as the web (combine) or keep them separated?
I know that on zfs I need specific dataset for Mysql..


----------



## SirDice (May 2, 2017)

fred974 said:


> Should I combine HAProxy to load balance both the web and DB cluster?


Our setup is quite similar to this. Except we use hardware firewalls that forwards traffic to a CARP address. We have two HAProxy machines running with CARP (fail-over). HAProxy then balances to 4 web servers. You could set up something similar by running CARP and HAProxy on the host and use the jails for the webservers. 



> Should I install the databases on the same server as the web (combine) or keep them separated?


We have them separated because the database servers and webservers have different hardware requirements. The DB servers have fast SSDs and a lot of memory (we need them to be as fast as possible). The webservers run on regular spinning disks and have a reasonable amount of memory. Most of the websites run from memory so there's very little I/O.


----------



## fred974 (May 6, 2017)

SirDice ,

Git is not really an opetion for wordpress..
Can you think of anything I could do to keep my wordpress plugin sync between webserver in a cluster?
I looked at /net/glusterfs but read that it is very heavy on resourcses and not all reliable..
Also not sure how it work in zfs infrastructure.

Also I looked the web and cannot find anything that i can user for MariaDB cluster..Galera is not working in FreeBSD and Maxscale just doesn't seem to exist in FreeBSD

Has anyone use zrep before?


----------



## SirDice (May 8, 2017)

fred974 said:


> Can you think of anything I could do to keep my wordpress plugin sync between webserver in a cluster?


You can designate one of the webservers as "master" and sync the others from it. For websites an net/rsync usually suffices. I'm assuming the website code itself doesn't change that often so there's very little reason to keep this in sync every second. Syncing when the site's been updated (on the master for example) should be more than enough.


----------



## Remington (May 8, 2017)

I would use rsync to duplicate the web files and use MariaDB's replication feature to update database changes to slave server.

You could use mysqldump but if you have large database then this is not feasible.

MySQL Workbench Synchronization is also another feature to use.


----------

