Table of Contents
Reply content:
Home Backend Development PHP Tutorial In a cluster architecture, do servers need to perform their own duties? That is, it is divided into database server, memory server, picture server, etc.

In a cluster architecture, do servers need to perform their own duties? That is, it is divided into database server, memory server, picture server, etc.

Jul 06, 2016 pm 01:51 PM
java nginx php concurrent cluster

Project background:
Reading is greater than writing, the ratio is about 4:1, the number of users is more than one million, and the concurrency is about 4,000 (can be high or low, high to 10K, low to 1K)
The performance of several servers is almost the same, and the load balancing can basically be evenly distributed to each server

I want them to directly face users one-to-one through load balancing (that is, ABCD can be directly accessed).

Let them perform their respective duties (assuming A and B are memory servers, C is a database, and D is an image processing server), and let them accept user access layer by layer.

Give me some advice

Reply content:

Project background:
Reading is greater than writing, the ratio is about 4:1, the number of users is more than one million, and the concurrency is about 4,000 (can be high or low, high to 10K, low to 1K)
The performance of several servers is almost the same, and the load balancing can basically be evenly distributed to each server

I want them to directly face users one-to-one through load balancing (that is, ABCD can be directly accessed).

Let them perform their respective duties (assuming A and B are memory servers, C is a database, and D is an image processing server), and let them accept user access layer by layer.

Give me some advice

It’s better to separate.
If they are not separated, it seems that the resources of the machine can be fully utilized, but this is not the case. Different types of services are deployed together, which increases the complexity of the server environment, easily causes problems and is difficult to locate, and is also not conducive to performance optimization.
Different types of services have different demands on resources. Memory servers focus more on memory, while image servers focus on disks. If they are deployed together, if there is a memory bottleneck, it will also have an impact on the image server, resulting in a waste of disk resources.
So it is deployed separately, the environment of each service is simple, and resources can be allocated as needed.

Each performs its own duties, and the concept of distributed clusters includes different parts of a system. The first solution only achieves load balancing, and according to the literal meaning, it seems that each machine will install the corresponding application and database service. In this case, the data synchronization and file synchronization issues will make you miserable, so adopt the classic The functional hardware subcontracting architecture (the second one you mentioned) is a more appropriate method.
Access layer: Responsible for accepting and distributing user needs, installing load balancing services, and configuring the server to prioritize network, memory, and CPU.
Application caching layer: Caching application data according to business and usage frequency. Most of this layer is page caching. Network, IO priority.
Application layer: Responsible for accepting distribution from the access layer, processing requirements, and installing specific project applications. The server is configured to give priority to memory, CPU, and IO. (For a service-oriented system, it may be further subdivided into logical layer, service layer, persistence layer, etc. Please analyze the specific project in detail).
Data caching layer: According to your project background, database indexes can be placed in this layer, and some data dictionary tables can also be placed according to business needs and specific hardware configurations. Hard disk and IO are given priority.
Data layer: Install database service and file storage service. The database service can be configured for read-write separation based on your description. If the amount of data is relatively large, you also need to consider the sub-database settings of the database. Configure hard disk and IO priority.
On top of all the above servers, the servers at each layer should be disaster-tolerant according to the active-standby principle.
Of course, all architectures outside the scope of hardware are empty talk. I don’t know what kind of server you have, but it seems to have similar configurations. Try to modify it as much as possible, and make appropriate modifications according to the needs of each layer. If there are not enough machines, you can consider cutting off virtual machines, but the virtual machines will consume part of the server resources. How to configure the specific configuration to maximize performance depends on stress testing and subsequent tuning.

It is recommended to adopt the second option.

I feel that it is not good to separate. If you are all separated, if any server crashes, your program will crash. The first thing the program must ensure is stability. As for running multiple programs on one server to increase server complexity, it depends on how you do it. As for deployment issues, individual services are actually irrelevant on the server. For troubleshooting, just make good logs. If you have four servers doing distributed balancing, your service expansion and transfer will be relatively easy. You can make them all into a single server. , it does not have the scalability of a distributed system, and if the performance encounters a bottleneck, you must make a major structural change and change it to a distributed system. Overall, I think the first option is much more flexible than the second one

As for the service level reported by the subject, it should be done in a separated manner.

There are two main considerations:

  • Different types of services have different requirements and consumption of various machine resources, and machines can be customized as needed. Other students upstairs have said this;

  • Furthermore, deploying different services together, especially services that may have potential impacts, will increase the maintenance cost and instability of the system; as an extreme example, you would consider putting the test environment Should it be deployed together with the production environment? Adjusting the test environment parameters to affect the production environment is really the last thing that should happen.

Furthermore, someone mentioned that deploying in multiple places actually has to deal with multiple problem scenarios. I think this is exactly the opposite

  • First of all, the business layer cannot always assume that the service layer is safe and stable. It needs to tolerate or even have a circuit breaker mechanism for service layer failures

  • Secondly, all services are placed on one machine. If a single machine hangs up (for example, if the disk is full and the memory is full and the CPU explodes, etc.), all services will hang. If scattered, it will only cause individual service damage.

  • There is also an operation and maintenance cost consideration. In the early days, the web server and back-end services may be put together. After the traffic and pressure increase in the later period, we will definitely continue to work in the direction of division of labor and specialization.

The above is mainly my personal understanding, please refer to it~

It is necessary. Of course the servers have to perform their respective duties. The server needs to be deployed in a distributed manner. Expand laterally in the face of traffic pressure. Disaster recovery servers are even needed. If one server goes down, other servers will take over.

The essence of this problem lies in horizontal scalability. If you can only access ABCD through load balancing, you will give up scalability

So I suggest separating ABCD for independent services

Then you have to analyze which part of the system is the bottleneck, and then do load balancing, machine expansion, distribution, etc.

It’s best to separate
Your application is constantly growing
It has reached this stage now
Even if you don’t separate now
You will separate in the future.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

How to check the name of the docker container How to check the name of the docker container Apr 15, 2025 pm 12:21 PM

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to configure cloud server domain name in nginx How to configure cloud server domain name in nginx Apr 14, 2025 pm 12:18 PM

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

See all articles