[Cloud Native] The evolution of software architecture and the advantages and disadvantages of each architecture

1. What is software architecture?

Software architecture refers to the process of planning and defining the organizational structure, components, modules, interfaces, and the relationships and behaviors of the system when designing and building a software system. It describes the overall structure of a software system and the relationship between its components, as well as the behavior and functions of the system.

The evolution of software architecture can be roughly divided into:

  1. stand-alone architecture
  2. Application Data Separation Architecture
  3. Application Service Cluster Architecture
  4. Read-write separation architecture
  5. Cold and hot separation architecture
  6. Vertical sub-database architecture
  7. microservice architecture
  8. Container Orchestration Architecture

Let me introduce you one by one
insert image description here

2. Stand-alone architecture

A stand-alone architecture is a simple technical architecture that usually refers to running an entire application on a single server. In a stand-alone architecture, all components and functions run on the same physical or virtual machine.

Reasons for appearance: In the early days of the Internet, the number of visits was relatively small, and the stand-alone architecture was sufficient to meet the needs

Advantages of stand-alone architecture:

  1. easy to deploy
  2. low cost

In a stand-alone architecture, all components run on the same server and can communicate with each other through local calls or direct access. This architecture is simple, easy to deploy and manage, and is suitable for small applications or scenarios that do not require high availability and scalability.

Disadvantages of stand-alone architecture:

  1. Single point of failure: Since all components run on the same server, once the server fails, the entire application will be inaccessible.
  2. Limited scalability: stand-alone architectures usually can only improve performance by upgrading hardware, and cannot cope with high loads through horizontal expansion.
  3. Difficult to maintain and upgrade: Since all components are concentrated on one server, maintenance and upgrade may affect the normal operation of the entire application.
  4. Database and application compete for resources

3. Application data separation architecture

Application data separation architecture is an architectural design that separates applications and data storage. In this architecture, applications and data storage can run on different servers or in different environments and communicate through the network.

Cause: There is serious resource competition in the stand-alone architecture, which causes the site to slow down

The benefits of applying a data separation architecture include:

  1. Scalability: By separating application and data storage, the capacity of applications and data storage can be independently scaled to meet growing demand.
  2. Maintainability: Independent application and data storage make system maintenance and upgrade easier, and can be configured, optimized and upgraded separately.
  3. Security: Through reasonable security and authentication mechanisms, the security and privacy of data can be protected.
  4. Heterogeneity: Applications and data storage can choose different technologies and platforms to meet different needs and constraints.

shortcoming:

  1. Higher hardware costs
  2. There is a bottleneck in performance, unable to cope with massive concurrency

4. Application service cluster architecture

The application service cluster architecture is an architectural approach in which multiple application servers are clustered to improve application reliability, scalability, and performance.

Reason: A single application is not enough to support a large number of concurrent requests, and the response of war points becomes slow when the concurrency is high

The core concepts of the application server cluster architecture include load balancing, session sharing and failover.

  • Load balancing: By distributing user requests to different application servers, the balanced distribution of requests can be realized to avoid overloading of a single server and improve the overall performance.

  • Session sharing: In order to ensure user session consistency between different application servers, session information needs to be stored in a shared storage, such as a database or cache. In this way, when user requests are forwarded to different application servers, the continuity of user sessions can be maintained.

  • Failover: When an application server fails, other healthy servers in the cluster can take over the work of the server to ensure the availability of the application. This can be achieved by using heartbeat detection, monitoring and automatic failover mechanisms.

Load balancing middleware: Nginx, LVS, F5, etc.

advantage:

  1. high availability
  2. high performance
  3. Have a certain ability to expand

shortcoming:

  1. Performance bottleneck, there is only one database, which cannot support massive concurrency
  2. Higher hardware costs
  3. More operation and maintenance work

5. Read-write separation architecture

The read-write separation architecture is an architecture design that separates the read and write operations of the database, which improves the performance and scalability of the database.

The core idea of ​​the read-write separation architecture is to distribute read operations to multiple read-only slave databases (also called slave databases), while write operations are handled by the master database (also called master database). The master library is responsible for writing data and synchronizing to the slave library, while the slave library is responsible for processing read operations. In this way, the load of read operations can be balanced to multiple slave libraries, and the concurrency performance of read operations can be improved.

Cause: The database is called a performance bottleneck. Internet games generally read more and write less, and the database bears a lot of pressure, which is mainly caused by these read requests. Therefore, it is necessary to separate the read operation from the write operation.

Use mycat,tddlsuch middleware to separate read and write requests. Make the corresponding read and write requests assigned to the corresponding master library/slave library

advantage:

  1. Improved database read performance
  2. Read operations are shared by other servers, and write performance is indirectly improved
  3. The database has a slave library, and the availability of the database is improved (for example: if one server is down, there are other servers)

shortcoming:

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

6. Cold and hot separation architecture

The cold and hot separation architecture is an architecture design that separates storage and processing of cold data and hot data by introducing cache, which improves system performance and storage efficiency.

Reason: Massive requests cause the database load to be too high, and the site response slows down again

In a traditional database architecture, all data is stored in the same database regardless of how often the data is accessed. In the cold and hot separation architecture, data is divided into cold data and hot data according to the access frequency of the data.

冷数据Refers to data that is accessed less frequently, often historical data or data that is infrequently queried. This data can be migrated to low-cost, low-performance storage media such as disk or cloud storage.

热数据Refers to data with high access frequency, which is often queried and updated frequently. These data can be retained in high-performance storage media, such as memory or fast storage devices.

Cache commonly used middleware:Redis

advantage:

  1. Significantly reduce the access requests to the database, and the performance improvement is very obvious
  2. Storing cold data in low-cost storage media can save storage resources and costs.
  3. Storing hot data in high-performance storage media can improve data read and write speed and response time, thereby improving system performance.

shortcoming:

  1. It brings problems such as cache consistency, cache breakdown, cache failure, cache avalanche, etc.
  2. Server costs need to increase further
  3. The single database of the database is too large, the volume of a single table is too large, and the database becomes the performance bottleneck again

7. Vertical sub-database architecture

The vertical sub-database architecture is an architectural design that divides the database according to functions or business modules

In the traditional single database architecture, all data is stored in the same database, no matter which business module's data. In the vertical sub-database architecture, the data of different business modules are stored in independent databases to achieve logical separation. For example, the database of a shopping application can be divided into: user library, commodity library, transaction library

advantage:

  1. The throughput of the database has been greatly improved, and it is no longer a bottleneck
  2. By distributing the data of different business modules into multiple databases, horizontal expansion can be achieved, and each database can be independently expanded and adjusted to improve the scalability of the system.
  3. Dispersing data into multiple databases simplifies database management and maintenance.

shortcoming:

  1. Problems such as cross-database join and distributed transactions need to be solved, and the current mmp has corresponding solutions
  2. The combination of database and cache can resist massive requests at present, but the application code is coupled together as a whole, modifying a line of code needs to be republished

8. Microservice Architecture

Microservice architecture is a software architectural style that breaks down a large application into a set of small, independent services, each dedicated to performing a specific business function. These services can be independently developed, deployed and expanded, and cooperate with each other through a lightweight communication mechanism to jointly build a complete application system.

Causes: The previous architecture has disadvantages such as poor expansion, difficulty in continuous development, unreliability, inflexibility, and difficulty in code maintenance

advantage:

  1. High flexibility: service independent testing, deployment, upgrade and release
  2. High independence: each service can expand by itself
  3. Improved fault tolerance: one service problem does not bring down the entire system
  4. Easy application of new technology: support multiple programming languages

shortcoming:

  1. High operation and maintenance complexity: business development, applications and services are constantly upgraded, the deployment of applications and services becomes complicated, and the deployment of multiple services on the same server also needs to solve the problem of operating environment conflicts
  2. Resource ring usage: These independently running microservices need to occupy memory and CPU
  3. Difficulty in handling faults: a request is called across multiple services, and it is necessary to view the logs of different services to complete the problem location

9. Container orchestration architecture

A container orchestration architecture is an architectural design for managing and orchestrating containerized applications.

A container orchestration architecture provides an automated way to deploy, scale, and manage containerized applications for highly scalable, elastic, and reliable deployments.

In the container orchestration architecture, applications/services can be packaged as images with the help of containerization technologies (such as docker), and the images can be dynamically released and deployed through container orchestration tools (such as k8s), and services are implemented in a containerized manner.

The reason for this:

  1. The microservices are split finely, the workload of multi-service deployment is heavy, and the configuration is complex and error-prone
  2. The number of microservices is large, the expansion and contraction are troublesome, and error-prone, and the environment parameter information corresponding to the service needs to be reconfigured after each expansion.
  3. The operating environment between microservices may conflict, requiring more resources to deploy or modify the configuration to resolve conflicts

advantage:

  1. Deployment, operation and maintenance are simple and fast: a single command can complete the deployment or expansion of hundreds of services
  2. Good isolation: the file system and network between containers are isolated from each other, and there will be no environmental conflicts
  3. Easy, supports rolling update: switching between versions can be upgraded or rolled back with a single command

shortcoming:

  1. The number of technology stacks has increased, and the requirements for the R&D team are high
  2. Network and storage challenges: In the container orchestration architecture, network communication is required between containers and access to shared storage resources is required. Additional configuration and management work may be required to handle networking and storage challenges between containers.

10. Summary

The evolution of the software architecture first solves the problem between the application and the database, by deploying the application and the database on different servers. Then, through load balancing, the high concurrency problem of the application is solved. The second is to optimize the database, through the read Write separation, use cache, sub-database and sub-table, and distributed database to optimize the database. The last is to optimize the operation and maintenance.

Software architecture is an important stage of software development and plays a role in guiding and making decisions in the software life cycle. A good software architecture can provide good scalability, maintainability and reusability, thereby reducing development and maintenance costs, and meeting system requirements and user expectations.
insert image description here

Guess you like

Origin blog.csdn.net/m0_63463510/article/details/131363952