Practical Case: Evolution of Distributed Architecture

Time:2019-9-11

Practical Case: Evolution of Distributed Architecture

Preface

With the scale of computer system becoming larger and larger, the architecture of centralized deployment of all business units on one or several mainframes has become increasingly unable to meet the needs of today’s computer systems. At the same time, with the emergence of microcomputers, more and more inexpensive PC has become the preferred IT architecture of major enterprises, and distributed processing methods are increasingly favored by the industry. This article will introduce the history of distributed architecture and some related concepts of distributed architecture.

Let’s take a simple e-commerce system as an example to observe the possible structural changes of the system when the data volume and access volume increase. If our system has the following functions: user module (user registration and management), commodity module (commodity display and management), transaction module (creation of transactions and payment and settlement).

I. Single Application Architecture

Practical Case: Evolution of Distributed Architecture

The initial stage of the website can also be regarded as the early rise of the development of the Internet. We often run all our programs and software on a single computer. Deploy all software and applications on a single machine, so as to complete the construction of a simple system, at this time pay attention to efficiency.

Separation of Application Server and Database Server

With the website on-line, the number of visits gradually increased, and the load of the server slowly increased. When the server has not been overloaded, we should make a good plan to improve the load capacity of the website. If the optimization at the code level has not been able to continue to improve, without improving the performance of a single machine, increasing the machine is a better way, the input-output ratio is very high. The main purpose of adding machines in this stage is to split web server and database server, which not only improves the load capacity of single machine, but also improves disaster tolerance.

Practical Case: Evolution of Distributed Architecture

III. Application Server Cluster

With the continuous increase of access, a single application server has been unable to meet the demand. Assuming that the database server has not yet encountered performance problems, we can add application servers and distribute user requests to each server through the cluster of application servers, so as to continue to improve the load capacity. At this time, there is no direct interaction between multiple application servers, they all rely on the database to provide services to the outside world.

Practical Case: Evolution of Distributed Architecture

As architecture develops to this stage, various problems will gradually arise, such as who forwards user requests to specific application servers. At this time, the following architecture model may appear.

Practical Case: Evolution of Distributed Architecture

4. Separation of Reading and Writing in Database

When the pressure of the database increases, how to improve the load of the database level? With the previous ideas, you will naturally think of adding servers. But if we simply divide the database into two parts, and then load the subsequent database requests on two database servers, it will cause the problem of database disunity. So we usually consider the separation of reading and writing.

Practical Case: Evolution of Distributed Architecture

5. Use Search Engine to Relieve the Pressure of Reading Library

If a database is used as a reading database, the efficiency of fuzzy search is often not very good. For example, search is the core function of e-commerce websites. Even if the separation of reading and writing is done, this problem can not be effectively solved. Then we can introduce the search engine at this time, using the search engine can greatly improve our query speed.

Practical Case: Evolution of Distributed Architecture

6. Introducing caching mechanism to alleviate the pressure of database

With the continuous increase of access, many users access the same part of the content gradually. For these hot data, it is not necessary to read from the database every time. We can use caching technology, such as Memcache and redis, as the cache of our application layer. In some scenarios, for example, we restrict the access frequency of some IP of users, which is inappropriate to store in memory. Too much trouble. Nosql, such as mongDB, can be used to replace traditional relational databases.

Practical Case: Evolution of Distributed Architecture

VII. Horizontal/Vertical Separation of Database

In the process of evolution of our website, the data of transaction, commodity and user are still in the same database. Despite the way of increasing cache and separating read from write, the bottleneck of database is still the biggest problem with the increasing pressure of database. So we can consider vertical and horizontal data splitting.

Vertical splitting: splitting different business data in the database into different databases.

Horizontal splitting: splitting data from the same table into two or more tables.

Practical Case: Evolution of Distributed Architecture

VIII. Application Splitting

With the development of business, business is more and more, the pressure of application is more and more great, and the scale of project is also more and more huge. At this time, we can consider splitting the application into user, commodity and transaction subsystems according to the domain model.

Practical Case: Evolution of Distributed Architecture

After such splitting, there may be some same code, such as user operations, which need to be queried in commodities and transactions, so each system will have user queries to access related operations. These same operations must be abstracted and can be solved in a service-oriented way.

9. Servicization

After service decomposition, each service can communicate through RPC technology. Typical services are web service, hessian, http, RMI and so on.

Practical Case: Evolution of Distributed Architecture

Thank you for your patience in reading the article.

By the way, I would like to recommend a Java technology exchange group: 710373545, which will share some video materials recorded by senior architects: Spring, MyBatis, Netty source code analysis, high concurrency, high performance, distributed, micro-service architecture principles, JVM performance optimization, distributed architecture and so on, which become necessary knowledge for architects. Department. Free learning resources are also available, which have benefited a lot at present! ____________