Databases Reference
In-Depth Information
Efficiency
Load balancing helps you use resources more efficiently because you have control
over how requests are routed. This is particularly important if your servers aren't
all equally powerful: you can direct more work to the more powerful machines.
Availability
A smart load-balancing solution uses the servers that are available at each moment.
Transparency
Clients don't need to know about the load-balancing setup. They don't have to
care about how many machines are behind the load balancer, or what their names
are; the load balancer lets the clients see a single virtual server.
Consistency
If your application is stateful (database transactions, website sessions, etc.), the
load balancer should direct related requests to a single server so that the state isn't
lost between requests. This relieves the application of having to keep track of
which server it's connected to.
In the MySQL world, load-balancing architectures are often tightly coupled with
sharding and replication. You can mix and match load-balancing and high-availability
solutions and place them at whatever level is appropriate within your application. For
example, you can load balance across multiple SQL nodes in a MySQL Cluster instal-
lation. You can also load balance across data centers, and within each data center you
might have a sharded architecture, each node of which is actually part of a master-
master replication pair with many replicas that are load balanced yet again. The same
is true of high-availability strategies; you can have multiple levels of failover in an
architecture.
Load balancing has many nuances. For example, one of the challenges is managing
read/write policies. Some load-balancing technologies do this themselves, whereas
others require the application to be aware of which nodes are readable and writable.
You should consider these factors when you decide how to implement load balancing.
A wide variety of load-balancing solutions are available, ranging from peer-based im-
plementations such as Wackamole ( http://www.backhand.org/wackamole/ ) to DNS,
LVS (Linux Virtual Server; http://www.linuxvirtualserver.org ), hardware load balanc-
ers, TCP proxies, MySQL Proxy, and managing the load balancing in the application.
Among our customers, perhaps the most common tactic is to use hardware load bal-
ancers. Many of them use HAProxy ( http://haproxy.1wt.eu ), which seems to be very
popular and work quite well. Some people use another TCP proxy, such as Pen ( http:
//siag.nu/pen/ ). We don't see MySQL Proxy used very often.
Connecting Directly
Some people automatically associate load balancing with a central system that's inser-
ted between the application and the MySQL servers. This isn't the only way to load
 
Search WWH ::




Custom Search