Introduction to 21CTO Community

This article is the work of Shen Jian, architect of 58.com. The text is concise, I hope to be of value to you.

Here is a typical layered architecture of the Internet:

  • Client layer: The typical caller is browser or APP

  • Site application layer: implement core business logic, get data from downstream, and return HTML or JSON to upstream

  • Data-cache layer: Accelerates access to storage

  • Data-database layer: Solidify data stores

 

If servitization is implemented, the hierarchical architecture diagram might look like this:

There is a service layer in the middle.

 

The interior of the same layer, such as APP on the end and Web-server, also have MVC layering:

  • View layer: display

  • Control layer: logic

  • Model layer: data

 

It can be seen that every engineer is imperceptibly implementing the layered architecture.

 

So what is the nature of the layered architecture of the Internet?

If we think carefully will find that, whether it’s layered architecture across processes, or process within the MVC layered, is a “mobile data”, then “processed” and “being present” process, at the end of the day: the Internet layered architecture, is a data movement, treatment, present process, including data movement is the core of the whole process.

 

As shown above:

Data processing and presentation are computed by the CPU, which is fixed:

  • The DB, Service, and Web-server servers are deployed in fixed clusters

  • On the end, both Browser and APP have fixed CPU processing

 

Data is mobile:

  • Cross-process movement: Data is moved from the database and cache to the Service layer, to the Web-server layer, and to the client layer

  • Process movement: Data is moved from the Model layer, to the Control layer, to the View layer

 

Data moves, so two things are important:

  • Format of data transmission

  • The form of data at each level

 

First, the format of the data transfer, i.e., the protocol is important:

  • Between service and DB /cache, binary protocol/text protocol is the carrier of data transmission

  • Between web-server and Service, the binary PROTOCOL of RPC is the carrier of data transmission

  • The HTTP protocol is used to transfer data between the client and the Web-server

 

Let’s look at the form of data at each level. Take user data as an example:

  • Row (uid, name, age)

  • Kv (uid -> User)

  • The Service layer converts a row or KV into an application-friendly User object

  • The Web-Server layer converts application-friendly User objects into HTTP-friendly JSON objects

  • Client layer: The most terminal is the JSON object

 

Conclusion: The essence of the layered architecture of the Internet is the movement of data.

 

Why? This leads to the core principles and methods of “hierarchical architecture evolution” :

  • Let the upstream more efficient acquisition and processing of data reuse

  • So that downstream can be shielded from the details of data acquisition, encapsulation

 

Understanding this principle and method, along with some experience, can answer some of the questions that people often ask in the comments:

  • Do YOU need to introduce the DAO layer and when

  • Do you need to servitize, and when

  • Is it necessary to extract general Taiwan business, when to extract

  • Do you need to separate the front and back ends, and when

(These questions from netizens are actually difficult to answer. It would be irresponsible to say YES or NO without knowing the stage of the business, the scale of the business, and the amount of data and concurrency.)

More detailed evolution of the layered architecture will be discussed in the next article.

 

conclusion

  • The essence of the layered architecture of the Internet is the movement of data

  • In the hierarchical architecture of the Internet, the data transmission format (protocol) and the form of data at each level are important

  • The core principles and methods of the Evolution of Internet layered architecture: encapsulation and reuse

 

thinking

Which system architecture is not “fixed CPU, move data”, but “fixed data, move CPU”?

There will be a follow-up article by Mr. Shen Jian. You are also welcome to contribute to the 21CTO community and discuss high availability architecture technology with Shen Jian and other big bull.

Author: Shen Jian (Public id: Path of Architect)