Teach you to quickly build a web cluster project based on nginx

Teach you to quickly build a web cluster project based on nginx

1. Project Environment

8 centos7/8 servers, nginx 1.21.1, ab, nfs4,
zabbix, keepalived 2.1.5, ansible, bind

2. Project Description

Build a 4/7 layer load balancing web cluster project based on nginx

Simulate the business environment of an enterprise to build a high-concurrency , high-availability web cluster.

Use stress testing to test the performance of the entire cluster, identify bottlenecks, and continuously optimize.

3. Project Steps

1. Installation

Install and deploy ansible services, establish a password-free channel with other servers, and write a playbook to install and deploy nginx and zabbix

2. Configuration

Deploy nginx and zabbix through ansible, configure nginx long connection, number of concurrency, number of worker processes, speed limit and related configuration of zabbix, upload website content (build a WordPress blog system or flask interface website, etc.)

3. Implement load balancing

Use two servers as dual-VIP load balancers, use nginx's 4/7 layer load balancing function, and use weighted round-robin scheduling algorithm

4. Build the server

Build an nfs server to ensure data consistency of the website, and set the backend real-server/backend server to automatically mount when it boots

5. Stress Testing

Use ab software to perform stress testing on the client

6. Monitoring

Add relevant servers and monitoring items on the zabbix/prometheus monitoring platform to monitor the performance of the entire web cluster--"zabbix

7. High Availability

Use keepalived software to make the load balancer highly available and prevent single point of failure--》keepalived

8. Domain name resolution

Build a DNS server to perform domain name resolution for the entire web cluster. Through DNS domain name resolution load balancing, bind two VIPs to one domain name for user access, thereby importing traffic to different load balancers.

9. Improve performance

Try to optimize the entire web cluster to improve performance: optimize kernel parameters, nginx parameters, consider adding cache and other measures

10. Use Ansible to write playbooks

Try to use Ansible to write playbooks to install all software: nginx, zabbix, keepalived, ab, nfs, etc.

IV. Project Summary

1. Gradually understand the concept of cluster, from 1 to multiple
2. Have a certain understanding of high performance and high availability, have a certain understanding of the system's performance indicators and parameters, have a certain understanding of the brain split phenomenon and how to avoid it
3. I have a certain understanding of one-click deployment and installation, which is very convenient and fast. I will try better automation operations in the future--》ansible
4. Gain an overall understanding of the bottleneck of the entire cluster under stress testing
5. I have some understanding of system optimization and feel it is necessary to improve performance without increasing costs.
6. I have also had some exposure to monitoring. Monitoring is a very basic operation and maintenance work. It can detect problems in advance and make early warnings.
7. Lay the foundation for future large-scale cluster learning and improve overall planning capabilities
8. Troubleshooting capabilities have been improved
9. Have a certain understanding of the coordination of many basic functional software, such as: zabbix, keepalived, ansible, nginx, nfs, ab, bind, etc.
10. Have a certain understanding of DNS load balancing and layer 4/7 load balancing

5. Notes on Building a Web Site

1. Web site content, you need to determine: blog, interface website, test page, etc. Data consistency issues: NFS, SAN, cloud storage, NAS, etc.

2. Optimization of kernel parameters:

[root@docker ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
net.ipv4.conf.all.promote_secondaries = 1
net.ipv4.conf.default.promote_secondaries = 1
net.ipv6.neigh.default.gc_thresh3 = 4096
net.ipv4.neigh.default.gc_thresh3 = 4096
kernel.softlockup_panic = 1
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
kernel.shmmax = 68719476736
kernel.printk = 5
kernel.sysrq = 1
kernel.numa_balancing = 0
[root@docker ~]# ulimit
unlimited
[root@docker ~]# ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 14826
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 100001
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 14826
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@docker ~]#

ab -c 2000 -n 100000 http://192.168.0.92/

This is the end of this article about building a web cluster project based on nginx. For more relevant nginx web cluster project content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Keepalived+Nginx+Tomcat sample code to implement high-availability Web cluster
  • Using software load balancer to implement web server cluster (iis+nginx)
  • nginx+apache+mysql+php+memcached+squid to build a cluster web environment

<<:  Solution to the problem of text position jumping when the search text box leaves the focus

>>:  CSS delivery address parallelogram line style example code

Recommend

How to solve the Mysql transaction operation failure

How to solve the Mysql transaction operation fail...

How to optimize MySQL performance through MySQL slow query

As the number of visits increases, the pressure o...

Detailed explanation of table return and index coverage examples in MySQL

Table of contents Index Type Index structure Nonc...

Using Nginx to implement grayscale release

Grayscale release refers to a release method that...

MySQL 5.6 root password modification tutorial

1. After installing MySQL 5.6, it cannot be enabl...

Nginx external network access intranet site configuration operation

background: The site is separated from the front ...

Solution to invalid margin-top of elements in div tags

Just as the title says. The question is very stran...

How to solve the problem of MySQL query character set mismatch

Find the problem I recently encountered a problem...

CSS implementation code for drawing triangles (border method)

1. Implement a simple triangle Using the border i...

Steps to split and compress CSS with webpack and import it with link

Let's take a look at the code file structure ...

JS implements Baidu search box

This article example shares the specific code of ...