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

IE8 compatibility notes I encountered

1. IE8's getElementById only supports id, not ...

MySQL Installer Community 5.7.16 installation detailed tutorial

This article records the detailed tutorial of MyS...

mysql solves the problem of finding records where two or more fields are NULL

Core code /*-------------------------------- Find...

The whole process of implementing the summary pop-up window with Vue+Element UI

Scenario: An inspection document has n inspection...

Implementation of FIFO in Linux process communication

FIFO communication (first in first out) FIFO name...

MySQL query data by hour, fill in 0 if there is no data

Demand background A statistical interface, the fr...

Some tips on website design

In fact, we have been hearing a lot about web des...

Perfect solution for theme switching based on Css Variable (recommended)

When receiving this requirement, Baidu found many...

JavaScript canvas realizes colorful sun halo effect

This article example shares the specific code of ...

How to set a fixed IP in Linux (tested and effective)

First, open the virtual machine Open xshell5 to c...

The new version of Chrome browser settings allows cross-domain implementation

Preface Currently, the front-end solves cross-dom...

Detailed examples of converting rows to columns and columns to rows in MySQL

mysql row to column, column to row The sentence i...