Home > Article > Operation and Maintenance > How multiple nginx clusters work
Nginx Web server can achieve load balancing, but one Nginx is also limited. If the volume is not high, how to achieve load balancing on its upper layer. If it is DNS or CDN, building multiple computer rooms will inevitably lead to data synchronization problems in multiple computer rooms. Is there any good information on this?
Answer:
The information in this area is basically incomplete piece by piece. I will probably tell you a basic architecture: (Recommended learning: nginx tutorial)
DNS server, if there are sufficient funds, it is recommended to use a BGP computer room and 2-3 DNS servers For equalization, bind software is usually used. If funds are tight, you can purchase a professional DNS service, such as domestic dnspod.
CDN server, if you want to save trouble at the beginning, you can buy the services of a professional company, such as chinacache, but the cost will become higher and higher with development. If you build it yourself, you may build it separately, put servers in different computer rooms such as China Telecom, China Unicom, China Mobile, etc., and perform dynamic resolution through DNS. For very large websites, you can use Squid, for ordinary medium to large websites, use Nginx, and for internal use, use Varnish.
The front-end is balanced. If you have sufficient funds, you can use hardware equipment, hundreds of thousands of units. If you already have a technical team, you can use Nginx/Haproxy Keepalived to build your own front-end. The balancing methods are relatively flexible, including random, weight, IP, and URL.
The problem of synchronization depends on what is being synchronized. Normally, real-time file synchronization is possible. But for databases, the synchronization method depends on the specific type.
The back-end application server and database cluster depend on traffic planning.
There are several ways to achieve balance among multiple Nginx units:
1. Each Nginx unit has a public network address, and multiple directions to the same domain name are set at the domain name. , the simplest way to implement Lun Xun. But the fault cut-off will be slower.
2. One public network Nginx distributes to multiple nginx on the intranet through the upstream function, wheel, IP, and URL. But if nginx on the public network goes Down, the internal network will be completely disconnected.
3. A pair of public network Nginx plus three public network IPs, achieve high availability through Keepalive, and then upstream to the intranet.
4. A hardware balancing server is at the front end, and then the content is balanced to other servers through hardware.
The hypothesis you mentioned can be realized through methods 2, 3, and 4.
The above is the detailed content of How multiple nginx clusters work. For more information, please follow other related articles on the PHP Chinese website!