High-reliability Linux System Design for Keepalived + Nginx services
Source: Internet
Author: User
High-reliability Linux System Design for Keepalived + Nginx services-Linux Enterprise applications-Linux server application information. For details, see the following. Keepalived is a high-reliability running tool that implements VRRP backup routing in Linux. The Service Model Based on Keepalived can truly achieve seamless IP address transfer when the master server and backup server fail. On Sina dynamic application platform, Keepalived works well with LVS in online services.
Nginx is an http server based on the epoll model in the Linux 2.6 kernel. Unlike the Apache process derivation mode, Nginx processes are based on the Master + Slave multi-process model, it has a very stable sub-process management function. In Master process allocation mode, the Master process never performs business processing, but distributes tasks to ensure high reliability of the Master process, all the business signals of the Slave process are sent by the main process, and all the timeout tasks of the Slave process are aborted by the Master, which is a non-blocking task model. On the Sina Blog application platform, after nearly eight months of operation, there was no fault in the service due to the termination of the main process or the death of sub-processes.
In the production environment, the loss caused by any machine downtime must be minimized. In the traditional production environment, all servers are placed directly behind the 4/7-layer switch to avoid service suspension due to server or software faults. In the current business model, many high-concurrency service requirements, such as Js small files, high-speed dynamic interfaces, and Nginx layer-7 services, all Socket operations are expected to be completed as soon as possible, reduce the user's waiting time. As A 4/7-layer switch is responsible for the services of multiple products on the Sina site, it is often a constraint for High-concurrency service applications. As a result, the idea of using Keepalived + Nginx to implement dual-host cross-hot standby and using public ip addresses for DNS round-robin services was developed. This solution can be applied to all application environments requiring high-concurrency services. The less the Socket communication layer, the faster the data reaches the user's desktop.
1. Server IP address survival Detection:
The Keepalived itself performs the Server IP address survival detection. It configures two servers as Keepalived in mutual active and standby relationships. If either server fails, the other server can take over the IP address.
2. Server Application Service survival Detection:
In addition to ensuring the survival of servers, a normal service also requires the survival of application services. In the past, the reason why the Apache server does not respond to HTTP due to process freezing affects the service is caused by the Apache process mode. In the Nginx process model, we can think that as long as the Nginx process is alive, the service is normal. Therefore, we only need to detect the process to survive. The health status of the Slave process is completed by the Nginx Master process. The survival of the Master process can be monitored through a dedicated script on the server. Once the Nginx Master process exits abnormally, then immediately restart the Nginx process, which has been running on the Sina Blog system for nearly half a year.
3. online server maintenance:
The service IP address of Keepalived is managed through its configuration file, and its own processes are used to determine the survival status of the server. If online maintenance is required for the server process, you only need to stop the Keepalived service process of the maintained machine, and the other server can take over all applications of the server.
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.