Small and medium-sized companies deployed to implement Linux cluster Web site experience

Source: Internet
Author: User
Tags rsync haproxy mrtg

In fact, in many small companies and small businesses, in particular, e-commerce and electronic advertising-related sites, their site also requires a load-balanced high availability of the Linux cluster, but because of the cost constraints, the boss will require the system architect to design a solution with the least amount of money to achieve this requirement, as the system architect we, How should this request be achieved?

The first is the choice of the room, if the company has its own room that is the best; if there is no room for their own, I suggest that you put in the BGP room hosting, if there is a choice, it is best to choose a hardware firewall with the room, so that security is also protected; In addition, how do we choose the server? With a load-balanced and highly available cluster environment, we can fully assemble the server ourselves, which is also the highest in price/performance. Like IBM and Dell's brand servers, although the quality is guaranteed, but the price is often not acceptable to the boss. Of course, everything is premised on stability and principle.

The first is the selection of load balancing devices. We can have two choices, one is through the hardware to carry out, the common hardware has more expensive NetScaler, F5, Radware and array and other commercial load balancer, its advantage is to have a professional maintenance team to maintain these services, the disadvantage is that the cost is too large, So for the smaller network services for the time being no need to use, the other is similar to Lvs/haproxy, Nginx Linux based open source free load balancing software strategy, these are implemented through the software level, so the cost is very low, Small companies and small businesses because of the cost of the problem, so software-level load balancing is the first choice.

As for a load-balanced, highly available architecture, I am the nginx/haproxy+keepalived architecture, and many of my friends have questions about why you don't choose a lvs+keepalived cluster solution. This is because the sites we deploy tend to have static and dynamic separation, Regular distribution of the demand, if we choose the first lvs+keepliaved structure, then at least we will add a layer of two load-balanced machines in the middle, so that more consumption of machines, virtually also increase the cost of the entire site; In addition, many friends are more worried about a problem, said nginx/ Haproxy+keepalived's stability is not as good as lvs+keepalived, this is actually a misunderstanding; with the successful implementation of more than 10 projects, plus years of observation, we found that the stability of these software-level load balancers is indeed excellent, In the case of high concurrency, the possibility of downtime is negligible, and the implementation of a commercial web site in the near period, with Haproxy+keepalived, in the billion/day high concurrent traffic impact, Haproxy stable as rock. LVS is the best performance aspect, especially when the rear nodes (such as Web or MySQL database servers) exceed 10, and the performance is excellent. And the small company's concurrency and flow is generally not particularly large, about a day lasts between 1 million/day, so I also recommend nginx/haproxy+keepalived here.

If the site is placed in the IDC room trusteeship, and the computer room is not the front of the hardware firewall protection, then we try to do a good job of traffic monitoring, I will generally install mrtg+nload software on the main nginx/haproxy to monitor the flow, nload can be real-time monitoring of traffic, Its installation is also very simple, we first install good rpmforege. Rpmforge is the CentOS software warehouse, with more than 4,000 kinds of packages, the CentOS community is considered to be the safest and most stable of a software warehouse, the address is http://pkgs.repoforge.org/rmpforge-release. After this installation is successful, we can easily install Nload by command yum-y install nload. After you enter this command, nload software will be very intuitive to show the real-time flow of the state, the upper half of the ncoming is to enter the network card traffic, the lower half of the outgoing is from the network card out of the flow, each part of the current flow (Curr), average flow (avg), Minimum flow (min), Maximum flow (max), total flow (TTL). Because this software is more intuitive, I use it to replace the previous real-time flow monitoring software Iptraf,nload work interface as follows:

Many friends who are interested in clustering often ask me how many servers are needed if the site is to deploy a load-balanced, highly available Linux cluster, and the company wants to implement it in the most cost-efficient way. My answer is four units, that is, the 2+2 architecture, the front is two units nginx/haproxy+ Keeplaived machine, behind the two configuration of a relatively good web machine, MySQL database using a main one from the way, placed on two web machines, monitoring Nagios deployed from the nginx/haproxy machine, traffic monitoring I generally put the main nginx/ Haproxy, the software is the Mrtg+nload way, the data synchronization between the server I used is Rsync+inotify method, of course more often, I used is pure rsync way, this is to avoid the site has a large file changes will produce frequent reading disk trouble; Of course, if everyone's company on the file server has higher requirements (such as picture type), we can consider adding two more servers to make DRBD+HEARTBEAT+NFS way; if there is a mass of files to store, we can consider using MFS, Of course, this is more machine-consuming.

How do we solve the session synchronization problem, like the small company cluster architecture above? We can use the Nginx Ip_hash and haproxy balance source mechanisms, which are similar in principle, will allow a client to access a real Web server on a fixed backend for a considerable amount of time. So that the session will be maintained, we in the Site page login, it will not be between the two Web server jumped between the jump, and naturally will not appear once the site and remind you did not log in , the need for a new landing situation.

In addition, the small company's Web server we have at least two kinds of choices: one is Apache, the other is Nginx, in the traffic and concurrency is not the environment, we can choose Apache as our web server, although its ability to resist concurrency is not high, but its stability is the best, Many of my E-commerce sites are based on Apache, and the large traffic concurrency environment, I am more inclined to nginx.

MySQL Here I use is a master from the design, although many friends think this design is relatively simple, but it turns out that it is also the most stable. My E-commerce site is also the use of this framework, a few years down, never because the database failure has been lost a single phenomenon, the early stage of the site on-line, we can through the PHP program, the background of the query function of the portal Select Slave machine, which can greatly reduce the pressure of the main database; From the MySQL machine is not just a backup and standby role, we completely through the PHP program to the background of complex queries from the MySQL machine. Of course, MySQL's master-slave replication status monitoring is also very important, I generally through the Nagios and shell script dual monitoring methods.

How to help enterprises save and save money, this is actually a system administrator/architect of a job, I hope you can understand this in the work.

Related Article

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.