Some points to be considered in load Balancing + high availability cluster for Web site under Linux system

Source: Internet
Author: User
Tags hosting rsync haproxy nginx load balancing

With the maturity and widespread popularization of Linux system, Linux operation and maintenance technology has been paid more and more attention and sought after by enterprises. In some small and medium-sized enterprises, especially those involving e-commerce and e-advertising, the Linux cluster scenario is often required for load balancing and high availability.

So how to implement the Linux cluster architecture, can not only effectively ensure the healthy operation of the website, but also save the operation and maintenance costs?
According to the following years of operation and maintenance experience, a simple comb their own a little sentiment.

(1)
The choice of room
If you have a company's computer room that is no better, if not, recommended in the BGP room hosting, if there is a choice, it is best to choose the room with a hardware firewall, so there is security protection;
If the site is placed in the IDC room hosting, and the room is not the most front of the hardware firewall protection, to try to do a good job of traffic monitoring (especially nginx/haproxy load machine traffic), generally choose zabbix/cacti monitoring software.
Selection of servers
All with stability as the premise and principle, in the case of price can be accepted by the company, you can choose a brand server like IBM and Dell, the quality is guaranteed.
When server resources are tight, OpenStack virtualization (KVM) can be deployed, and virtual machines can act as test machines, beta machines, and internal deployment machines to take advantage of machine resources.

(2) Load Balancing + selection of highly available cluster schemes
Load Balancing Implementation
One is implemented through hardware.
Common hardware has more expensive NetScaler, F5, Radware and array, such as commercial load balancer, the advantage is a professional team to maintain, the disadvantage is that the cost is too large, for the network of Small enterprise website is not necessary;
One is implemented through open source free load balancing software policy
Commonly used is LVS, HAProxy, nginx load balancing, these are through the software level to achieve, the cost is very low, for small and medium-sized enterprises, in view of the cost problem, choose this kind of more reliable.

High-availability implementations
The nginx/haproxy+keepalived is the architecture, so why not choose a lvs+keepalived-based clustering scheme?
Because we deploy the site will generally involve static and dynamic separation, regular distribution of demand, if the site is the first Choice lvs+keepliaved architecture, then at least in the middle plus a layer of two load balancing machine, so more consumption of machinery, will also increase the cost of the entire site;

Some people will think that the stability of nginx/haproxy+keepalived than lvs+keepalived, in fact, this is a misunderstanding!
Through the observation period in recent years, combined with the successful implementation of more than 10 projects, it is found that the stability of nginx/haproxy+keepalived load balancer is very good, especially the haproxy+keepalive in the case of high concurrency is very unlikely.
A friend of the company in recent time to implement a commercial website with haproxy+keepalived, in the billion/day high traffic impact, Haproxy stable as rock.
LVS is generally recognized as the best performance, especially when there are more than 10 units in the back node (such as the Web or MySQL database server).
The concurrency and traffic of small and medium-sized companies are generally not particularly large, the daily PV continued within the million, recommended to use nginx/haproxy+keepalived.

Load Balancer + high-availability scenarios How many servers do you typically need to save costs in advance?
Generally speaking, small and medium-sized websites adopt 2+2+2 architecture. The front is 2 nginx/haproxy+keeplaived machines, followed by 2 well-configured web machines; Database 2 units, one master one from the way.

The data synchronization between servers adopts rsync+inotify real-time synchronization scheme. If the timeliness is not so high, you can use the pure Rsync method, combined with crontab for timing synchronization.

If the file server has a higher demand than the chip type, you can consider adding 2 additional servers, made Drbd+heartbeat+nfs way;
If you have a large amount of files need to be stored, you can also consider using MFS, of course, this is also more cost-consuming machine.

(3) Synchronization session problem in cluster architecture
Small and medium-sized Web sites can use Nginx Ip_hash and haproxy balance source mechanism, they are similar in principle, will allow a client to access a fixed back end of a real Web server for a long period of time, so that the session will be maintained, When we do login on our site page,
Will not be in the back of the Web server to jump between, and naturally will not appear after the site and remind you not to log on the need to re-login the situation;

If a large project or website can be considered in memcached way.

Session sharing issues can be consulted:http://www.cnblogs.com/kevingrace/p/6031356.html

(4) Web Service select Apache or Nginx
In the site traffic and small concurrency environment, can choose Apache as a Web service, although its anti-concurrency capability is not high, but its stability is the best, many e-commerce sites are based on Apache;
If the site is large traffic concurrency in the environment, strongly recommend Nginx as a Web service.

(5) database scheme: Master-slave
Small and Medium business sites, MySQL database with a master one from the solution to meet business needs, and then look relatively single, but it turns out that the stability of this design is very reliable!
Verified that the use of MySQL master one from the scheme for many years of the site, rarely because the database failure occurred over data loss phenomenon.
Web site in the early stage, you can use the PHP program, the background of the query function of the entrance to select slave machine, which can greatly reduce the pressure of the main database;
The slave machine is not just a backup and standby, it is possible to transfer complex queries from the backend to the MySQL machine via a PHP program.

Some points to be considered in load Balancing + high availability cluster for Web site under Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.