Docker from awareness to practice to underlying principles (1)|Technical Architecture

insert image description here

foreword

Well, the blogger here will first post some columns full of dry goods!

The first is a summary of bloggers’ high-quality blogs. The blogs in this column are all the bloggers’ most thoughtful writing. They are full of dry goods. I hope they will be helpful to everyone.

Then there is the blogger's most time-consuming column recently, "Docker From Understanding Practice to Underlying Principles", I hope everyone will pay more attention!

Blog Reference: Bit Employment Class


Chapter 1 - Technical Architecture

stand-alone architecture

Introduction

All services are deployed to one server.

Simply put, it's all on one server.

insert image description here

Cause

In the early days of the Internet, the usage was limited, and a stand-alone server architecture could meet the requirements.

Technical case

related software:

  • Web server software: Tomcat, Netty, Nginx, Apache, etc.

  • Database software: MySQL, Oracle, PostgreSQL, SQL Server, etc.

Architecture pros and cons

The advantage is that it is easy to configure and has low overhead, but the disadvantage is that you will face significant performance constraints, and the database and application will compete for resources.

Application Data Separation Architecture

Introduction

Very simple, that is, application services and database services use different servers.

insert image description here

Note that there is an extra line between the database and the application, and this line is the network.

Cause

Due to fierce competition for resources, the response speed of the website may slow down in a stand-alone situation.

How Architecture Works

DNS returns the ip of the application server, and then the application server goes to the database service to find it.

Advantages and disadvantages

  • Advantages: High economic controllability, better performance than stand-alone mode, excellent performance in independent isolation of database, application failure will not affect the database, and has certain fault tolerance.

  • Disadvantages: Increased hardware investment and performance limitations make it difficult to cope with large-scale and high-concurrency requirements.

Application Service Cluster Architecture

Introduction

Load balancing is introduced, and the application operates in a cluster mode.

insert image description here

Cause

An application server cannot withstand high concurrency, and it is easy to crash if it is high.

How Architecture Works

As shown in the schematic diagram, the layout scheme of multiple application servers is adopted to reduce the pressure of high concurrency.

**Significance of load balancing:** In order to solve the problem of which application server to assign user requests to, it is necessary to introduce dedicated system components for traffic distribution. In practical applications, the scope of load balancing is not limited to the application layer, but can also cover other network layers.

At the same time, there are many types of load balancing algorithms. The following is a brief introduction to several common ones:

  • Round-Robin algorithm (Round-Robin): distribute requests to different application servers fairly and sequentially to ensure fairness.
  • Weighted round-robin algorithm (Weight-Round-Robin): assign different weights according to factors such as server performance, so that servers with better performance can allocate more requests.
  • Consistent Hash Algorithm: The hash value is obtained by calculating user characteristics (such as IP address), and the request is distributed according to the hash result. The advantage of this method is that requests from the same user are always assigned to the same server, similar to our common dedicated customer representative service.

The advantage of this layout is that it can effectively deal with high concurrency situations and ensure the stability and response speed of the system.

insert image description here

How does DNS do load balancing?

We know that DNS can return the ip address through the domain name.

For example, if I want to visit www.taobao.com, I return ip1 for the first time, indicating the first LVS, return ip2 for the second time, indicating the second LVS...and so on. DNS can also complete the work of load balancing.

Advantages and disadvantages

Advantage:

  1. Ensure continuous availability of application services: Even if an application server fails, the entire website will not crash.
  2. It has certain high performance: it can quickly respond to a large number of requests without accessing the database (such as cached data).
  3. Possess a certain horizontal expansion capability: the expansion of the system can be realized by increasing the number of servers horizontally.

Disadvantages:

  1. Database performance becomes a bottleneck: Since there is only one database, the database may face performance issues when multiple users request data at the same time.
  2. The database is an independent architecture of a single server and lacks high availability.
  3. Increased O&M burden: With the expansion of deployment, O&M tasks also increase, and corresponding tools need to be developed to solve the challenges of rapid deployment.
  4. Higher hardware costs need to be borne.

Read-write separation/master-slave separation architecture

Introduction

By assigning the read and write tasks of the database to different nodes, we have established a master-slave cluster of database servers. In this cluster, one master node and one or more slave nodes are usually configured, or there can be one master node and multiple slave nodes. In this architecture, the primary database is responsible for processing write operations, while the secondary database is dedicated to processing read operations.

Cause

In situations where the database becomes the bottleneck, especially in Internet applications, there are usually significantly more read operations than write operations. In this case, the database is under great pressure due to the large number of read requests. Therefore, we can separate read and write operations to address this challenge.

How Architecture Works

insert image description here

If it is a write operation, access the master database, and then synchronize the data to all slave databases after the change.

If it is a read operation, just access the slave database.

insert image description here

Common such intermediate components are: MyCat, TDDL, Amoeba, Cobar, etc.

Advantages and disadvantages

advantage:

  1. Database read performance improvement
  2. Reading is shared by other servers, and writing performance is indirectly improved
  3. The database has a slave library, and the availability of the database is high

shortcoming:

  1. Frequent reading of hot data leads to high database load
  2. When the synchronization fails, or the synchronization delay is relatively large, the data in the write library and the read library are inconsistent
  3. Server costs need to increase further

Cold and hot separation architecture

Introduction

Introduce cache, implement hot and cold separation, put hot data in cache for fast response

Cause

The huge number of requests caused the database load to be too high, and the site response slowed down again.

How Architecture Works

For hotspot data, go directly to the cache instead of the database.

insert image description here
insert image description here

When writing, both the cache and the database must be written! And it can only guarantee simultaneous success or simultaneous failure (software can do it)

When reading, if there is in the cache, it will be read directly in the cache, if not, it will be read in the database.

Architecture pros and cons

Advantage:

  1. Significantly improved performance: By separating read and write operations, the burden of accessing the database is significantly reduced.

defect:

  1. Causes cache-related issues: This can lead to consistency issues, cache breakdowns, cache invalidations, and cache avalanches.
  2. Increased server overhead: Implementing this strategy may require additional costs for server equipment.
  3. Problems may be encountered after the business scale expands: as the business volume increases, the amount of data continues to increase, which may lead to an excessively large database, and the data in a single table is too large, which affects query performance and makes the database a bottleneck again.

Vertical sub-database architecture (distributed database architecture)

Introduction

The data of the database is split, and the distributed storage of database data, distributed processing, and distributed query can also be understood as a distributed database architecture.

Cause

The single-machine writing database mentioned above will gradually reach the performance bottleneck, and the database needs to be split. The data volume of the data table is too large, the processing pressure is too high, and the table needs to be divided. In order to reduce the difficulty of operation and maintenance, the industry has gradually developed a distributed database. , the library table naturally supports distributed.

How Architecture Works

What is sub-library and sub-table

insert image description here

as the picture shows.

Distributed Database Architecture

insert image description here

Advantages and disadvantages

advantage:

  1. The throughput of the database has been greatly improved, and it is no longer a bottleneck

shortcoming:

  1. Problems such as cross-database join and distributed transactions need to be resolved. The current mpp has a corresponding solution.
  2. The combination of database and cache can currently handle a large number of requests, but the code of the application is coupled together as a whole, and modifying a line of code needs to be republished as a whole.

microservice architecture

Introduction

Microservice is an architectural style that divides the application code according to the business sector, so that the responsibilities of a single application are clearer, and they can be upgraded and iterated independently of each other.

Cause

  1. Difficult to scale: The system cannot be easily scaled because every time an application needs to be updated, the entire system has to be rebuilt.
  2. Continuous development is hindered: Even small code changes require the entire application to be redeployed, making it difficult to release new versions frequently and easily.
  3. Unreliability: Even if a single function of the system fails, it may cause the entire system to crash.
  4. Lack of flexibility: There is no support for building a single application using different technologies.
  5. Code maintenance is difficult: all functions are tightly coupled together, making it difficult for someone who takes over this code to find an entry point for improvement.

How Architecture Works

insert image description here

insert image description here

Advantages and disadvantages

Advantage:

  1. High flexibility: each service can be independently tested, deployed, upgraded and released.
  2. Independent scalability: Each service can scale independently without affecting other services.
  3. Improve fault tolerance: A problem with one service will not cause the entire system to crash.

Disadvantages:

  1. Complex operation and maintenance: With the continuous development of business, the number of applications and services increases, and the deployment becomes more complicated.
  2. Increased resource requirements: Each independently running microservice requires certain resources.
  3. Increased difficulty in troubleshooting: Since a request may require multiple service calls, troubleshooting becomes difficult, and it is necessary to check the logs of different services to locate the problem.

Container Orchestration Architecture

Introduction

Use containerization technology (such as docker) to package services/applications into images, and use container orchestration tools (such as k8s) to dynamically distribute and deploy images. Services run in containerized fashion.

Cause

  1. Microservices are split finely, and the deployment of multiple services requires a lot of work, and the configuration is complex and error-prone.
  2. It is troublesome to expand the number of microservices, and it is prone to errors. It is very complicated to reconfigure the environment parameter information corresponding to the service after each shrinkage and expansion.
  3. So far, the operating environment of microservices may conflict, requiring more resources for deployment or resolving conflicts by modifying configurations.

How Architecture Works

insert image description here

insert image description here

Advantages and disadvantages

Advantage:

  1. Rapid deployment, easy operation and maintenance: use simple commands to complete the deployment or expansion and contraction of hundreds of services.
  2. Strong isolation: Containers are highly isolated in terms of file systems and networks, avoiding environmental conflicts.
  3. Convenient rolling update: switch between different versions through a single command, and support easy rolling update.

Disadvantages:

  1. The technology stack is complicated and has high requirements for the R&D team.
  2. Self-management of machine resources is required: During off-peak hours, a large number of machine resources may need to be idled to prepare for peak periods, which brings challenges in machine costs and operation and maintenance costs. To solve this problem, consider purchasing server resources provided by cloud service providers.

Guess you like

Origin blog.csdn.net/Yu_Cblog/article/details/132558699