Hierarchical website architecture

Source: Internet
Author: User
Tags haproxy

A reasonable website architecture usually involves hierarchical design of the entire architecture. The advantage is that the pressure on the server is dispersed, so that the service will not be stopped due to the heavy pressure on a single server. In architecture design, I think there are two prime principles. One is "all problems are pushed to the front", and the other is "avoiding single point of failure ". These two points actually ensure the high availability, scalability and reliability of the system architecture.

The following figure shows a simple example. In my understanding, the architecture of a website can be divided into the following layers:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1G1535602-0.jpg "title =" general network. jpg "/>

From the underlying layer, there are four layers: shared storage layer, server layer, cache acceleration layer, and Server Load balancer layer.

Shared storage layer:The storage space is provided. Because multiple servers on the above layer are connected to shared storage devices, data consistency is ensured. Of course, shared storage devices are expensive, and not all companies can afford them. Without such conditions, you can only use a server with large hard disk space as a storage device and mount the device on the upper-layer server through NFS.

Technologies or tools involved in this layer include distributed file systems, NFS, DRBD, and RAID arrays.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1G1531618-1.gif "/> related links:

DRBD + HeartBeat + NFS architecture http://pmghong.blog.51cto.com/3221425/1261349

Mirror technology DRBD http://pmghong.blog.51cto.com/3221425/1260138

Disk Mirroring Technology DRBD principles overview http://pmghong.blog.51cto.com/3221425/1259488


Server layer:As the name suggests, this layer of server mainly provides related business support. For example, if this is a website architecture, the main services provided here are web Services and mysql database services. A collection composed of multiple servers is called a "server pool". When user requests are allocated, the system selects one of the services from the server pool, and the allocated server actually provides services. When the business expands and the server pressure is too high, you can add new servers to the server pool to share the pressure, so as to reduce the pressure on a single machine and improve efficiency.

Software involved in this layer: apache, nginx, lighthttpd, etc. Nginx is superior in performance. It supports high concurrency, consumes less resources, and is easy to configure.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1G1531618-1.gif "/> related links:

Nginx + tomcat run jsp http://pmghong.blog.51cto.com/3221425/1218497

Apache + nginx Dynamic and Static separation http://pmghong.blog.51cto.com/3221425/1217151

Build lemp environment http://pmghong.blog.51cto.com/3221425/1178603


Cache layer:This layer is not actually necessary, but when the business is small, you can ignore this layer of design first. As the name suggests, the cache layer caches static files for acceleration. After the cache layer is set, when the user requests access for the first time, the cache server will go through the underlying layer to retrieve the user request data, send it to the user, and save a copy of data locally. But for the second time, when the user requests the same content, the cache server will still run at the bottom layer, but it only performs one verification, make sure that the cached data is consistent with the data on the underlying server. If they are consistent, the cache server will directly return the cached data to the user, thus improving the user experience.

Software involved in this layer: squid, nginx

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1G1531618-1.gif "/> related links:

Nginx implements reverse proxy http://pmghong.blog.51cto.com/3221425/1244223


Load Balancing layer:Servers at this layer are placed at the front-end as pioneers, and user requests arrive first). This requires considerable processing and load capabilities, because it acts as a scheduler, it is necessary to handle the pressure caused by a large number of user access. Therefore, servers at this layer usually require high CPU, high memory, and high bandwidth. In addition, this layer serves as the front-end of the entire architecture and is equivalent to the overall architecture commander. Once this layer Stops providing services, all the underlying servers will stop providing services (to be exact, therefore, we should pay enough attention to the settings of this layer of servers to ensure their reliability through some mechanisms and technologies. As a result, the entire system is paralyzed.

Software and Technology involved in this layer: haproxy, keepalived, nginx, lvs, etc.


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1G1531618-1.gif "/> related links:

Nginx + keepalived SLB architecture http://pmghong.blog.51cto.com/3221425/1264947

Haproxy + keepalived for high-availability Load Balancing http://pmghong.blog.51cto.com/3221425/1262741

High Availability cluster http://pmghong.blog.51cto.com/3221425/1201533 with lvs + keepalive

LV s_tun http://pmghong.blog.51cto.com/3221425/1195695

LVS_DR http://pmghong.blog.51cto.com/3221425/1195686

LVS_NAT http://pmghong.blog.51cto.com/3221425/1192543


Add:

In fact, there are two more points to consider in the architecture design. One is the database design. For a large website, database design is particularly important. It may play a vital role in the overall response speed of the website. For example, when there is a large amount of data, we need to consider how to "cut" the data and improve the query speed. (Only mysql is considered here)

Related Technologies and key points:

Mysql sub-tables (vertical sub-tables, horizontal sub-tables), mysql partitions, mysql slow queries, SQL statement optimization, parameter optimization, indexing, database backup, and so on.

Main architecture: master-slave replication, mysql Cluster


The other is the monitoring system. It is incumbent on our O & M personnel to rush to the site and handle problems in a timely manner when an accident occurs. It is impossible for us to view the monitoring screen 7x24 to see if there is a problem with the server. At this time, we need a tool to "look" at our server, that is, the monitoring system.


The monitoring system mentioned here can be large or small. It should be determined based on the business needs. It can be implemented through shell, python, and other scripts to implement monitoring and alarm. You can also use other open-source software. Here, we recommend the following:

Nagios, cacti, and zabbix have their own advantages and disadvantages. We will not discuss them here. If you need them, you can understand them on your own.



All of the above points are my own opinions. In view of my weak knowledge, I may not consider many aspects. Please give me more advice. If you have any additional information, please feel free to raise it! Thank you.

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.