Home  >  Article  >  System Tutorial  >  Dry stuff! 9 high-performance and high-concurrency technical architectures

Dry stuff! 9 high-performance and high-concurrency technical architectures

PHPz
PHPzforward
2024-02-13 11:00:29517browse
1. Layering

Layering is the most common architectural pattern in enterprise application systems. The system is divided into several parts in the horizontal dimension. Each part is responsible for a relatively simple and single responsibility, and then the upper layer relies on the lower layer. and scheduling form a complete system.

In the layered architecture of the website, there are three common layers, namely the application layer, the service layer and the data layer. The application layer is specifically responsible for the display of business and views; the service layer provides service support for the application layer; the database provides data storage access services, such as databases, caches, files, search engines, etc.

The layered architecture is logical. In terms of physical deployment, the three-tier architecture can be deployed on the same physical machine. However, with the development of the website business, it is necessary to deploy the already layered modules separately, that is, three-tier The structures are deployed on different servers so that the website has more computing resources to cope with more and more user visits.

So although the original purpose of the layered architecture model is to plan a clear logical structure of the software to facilitate development and maintenance, in the development process of the website, the layered structure is crucial for the website to support the development of high concurrency and distributed direction.
Dry stuff! 9 high-performance and high-concurrency technical architectures

2. Redundancy

The website needs to run continuously 7×24 hours, so it must have a corresponding redundancy mechanism to prevent a certain machine from being inaccessible when it goes down. Redundancy can be achieved by deploying at least two servers to form a cluster to achieve high service. Available. In addition to regular backups, the database also needs to implement hot and cold backups. Disaster recovery data centers can even be deployed globally.

3. Separation

If layering is to segment the software horizontally, then partitioning is to segment the software vertically.

The larger the website, the more complex the functions, and the more types of services and data processing. Separating these different functions and services and packaging them into modular units with high cohesion and low coupling will not only help the software Development and maintenance also facilitates the distributed deployment of different modules, improving the concurrent processing capabilities and function expansion capabilities of the website.

The granularity of separation for large websites may be very small. For example, at the application layer, different businesses are separated, such as shopping, forums, search, and advertising, into different applications. Opposing teams are responsible for them and are deployed on different servers.

4. Asynchronous

Using asynchronous, the message passing between businesses is not a synchronous call, but a business operation is divided into multiple stages, and each stage is executed asynchronously for collaboration by sharing data.

The specific implementation can be processed within a single server through multi-threaded shared memory; in a distributed system, asynchronous implementation can be achieved through distributed message queues.

The typical asynchronous architecture is the producer-consumer method, and there is no direct call between the two.

5. Distributed

For large websites, one of the main purposes of layering and separation is to facilitate distributed deployment of divided modules, that is, different modules are deployed on different servers and work together through remote calls. Distribution means that more computers can be used to complete the same work. The more computers, the more CPU, memory, and storage resources, and the greater the amount of concurrent access and data that can be processed, thus providing more users with Serve.

In website applications, there are several commonly used distributed solutions.

Distributed applications and services: Distributed deployment of layered and separated application and service modules can improve website performance and concurrency, speed up development and release, and reduce database connection resource consumption.

Distributed static resources: The static resources of the website, such as JS, CSS, Logo images and other resources, are deployed in a distributed manner and adopt independent domain names, which is what people often call the separation of static and dynamic resources. Distributed deployment of static resources can reduce the load pressure on the application server; speed up browser concurrent loading by using independent domain names.

Distributed data and storage: Large websites need to process massive data in P units. A single computer cannot provide such a large storage space. These databases require distributed storage.

Distributed computing: Currently, websites generally use Hadoop and MapReduce distributed computing frameworks for such batch calculations, which are characterized by mobile computing rather than mobile data. The computing program is distributed to the location of the data to accelerate computing and distribution. calculate.

Dry stuff! 9 high-performance and high-concurrency technical architectures

6. Security

Websites have many modes in terms of security architecture: identity authentication through passwords and mobile phone verification codes; network communications need to be encrypted for login and transactions; in order to prevent robot programs from abusing resources, verification codes need to be used for identification; for common XSS attacks and SQL injection require encoding conversion; spam information needs to be filtered, etc.

7. Automation

Specifically include automated release process, automated code management, automated testing, automated security detection, automated deployment, automated monitoring, automated alarms, automated failover, automated failure recovery, etc.

8, cluster

For modules with centralized user access, independently deployed servers need to be clustered, that is, multiple servers deploy the same application to form a cluster, and jointly provide external services through load balancing equipment.

Server clusters can provide more concurrent support for the same services, so when more users access, you only need to add new machines to the cluster; in addition, when one of the servers fails, At this time, the request can be transferred to other servers in the cluster through the load balancing failover mechanism, thus improving the availability of the system.
Dry stuff! 9 high-performance and high-concurrency technical architectures

9. Cache

The purpose of caching is to reduce the calculation of the server so that the data can be returned directly to the user. In today's software design, caching is everywhere. Specific implementations include CDN, reverse proxy, local cache, distributed cache, etc.

There are two conditions for using cache: access to data hotspots is unbalanced, that is, some frequently accessed data needs to be placed in the cache; data is valid within a certain period of time, but expires quickly, otherwise it will be lost due to data expiration. Dirty reads affect the correctness of data.
Dry stuff! 9 high-performance and high-concurrency technical architectures

The above is the detailed content of Dry stuff! 9 high-performance and high-concurrency technical architectures. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete