Article hero: Xiao Ming, working in an Internet company, engaged in back-end development work. Recently, Xiaoming received a notice that the company needs to develop an application of “CERTIFICATE photo”, and the architectural scheme needs to be solicited. The main functions include:

Although Xiao Ming is engaged in back-end development, he has always paid much attention to the knowledge of architecture. In the past, he used to build applications well constructed by development leaders. Now he has the opportunity to practice by himself and plans to apply what he has learned to practical cases.

In Xiao Ming’s mind, he recalled the three basic principles of architecture:

  • Fit better than industry leading
  • Simple is better than complex
  • Evolution is better than one step

As a beginner in architecture, Xiao Ming is full of energy, but like most developers, he has little experience in architecture. He does not know how to start architecture, and it is difficult to start everything at the beginning. Xiao Ming consulted the CTO of the company and gave a 25-word architectural statement: The main purpose of architectural design is to solve the problems caused by software system complexity

Xiao Ming is also bone surprise, experienced (996 did not exercise people ~~), thinking about the “architecture truth” since it is to solve the problem of software system complexity, that must first find out where the system complexity is?

Finding complexity

According to “Architectural Truth”, Xiao Ming began to think about the complexity of the application of “ID Photo”. First, it is a tool application, with the main function of image processing:

Xiao Ming found that image processing and image storage might be complicated. At present, the company does not have a dedicated image processing team or a big data team. These two problems should be solved first.

The mobile phone Xiaoming is using is Galaxy S9, a photo is about 6m. If the initial application life is 1W per day, assuming that 20% of people can process pictures, the storage capacity of that day is about 10G, and the operation of a month requires 300G storage space. The disk with several tons of configuration can run for about a year. But this is only ten thousand days to live and consider the hundred thousand, million level of time how to do.

After discussion, Ming listed some of the complications and prioritized them:

  1. Image storage
  2. The image processing
  3. The order processing
  4. The logistics process
  5. .

Design architecture Scheme

For the complexity of image storage, Xiaoming first thought of a distributed file storage scheme, so that data capacity and availability can be well guaranteed. He first communicated this idea with Xiaizhu, and Xiaizhu did not deny that the project was just for Ming to consider the cost factor. When Ming looked back, he wanted to confirm that the introduction of “distributed file storage” would first bring the following problems:

  • System complexity enhancement
  • Increased operation and maintenance costs
  • The system availability decreases
  • .

Xiaoming thought about the simple is better than the complex principle, decided to use the simplest local disk to store image files, but the use of local disk scheme must consider the expansion, the future may be expanded at any time, data migration, so Xiaoming made a simple abstraction layer for image storage:

Xiaoming applied the architectural principles of simplicity over complexity and evolution over one-step to storage complexity. Meanwhile, for the variability of storage, the introduction of abstraction layer can effectively and reasonably cope with future changes.

After the initial decision of image storage, Xiao Ming began to design the complexity of image processing. The production process of a CERTIFICATE photo is roughly as follows:

  • User submits images
  • To detect human faces
  • Portrait cut with background
  • Deliver the cut drawings to the customer for processing
  • Client synthetic back, formal generation of documents

Detecting human face, image segmentation, never use this kind of technology company, since the research is basically impossible, besides the human cost is not enough, the first of the right solution is to use third-party services, a survey found that baidu AI someone like processing ability, xiao Ming began to consider the use of baidu AI service, so the introduction of baidu AI service:

For image processing Xiaoming to consider the appropriate is better than the industry leading principle, considering the cost of manpower and material resources to choose the right scheme, rather than at the beginning said to develop a set of image processing system, invest a lot of time and manpower to do the final gain outweighs the loss. After some operation, Xiao Ming will sort out the infrastructure map to The West kicking, waiting for the west kicking around ~~

conclusion

According to the comprehensive index that the main purpose of architecture design is to solve the problems caused by the complexity of software system, Xiaoming first finds out the complex points of the system, then solves the complex problems step by step through priority sorting, and finally designs a feasible architecture scheme based on the actual situation. Although the case architecture is relatively simple and does not have large-scale distributed, high-availability and high-concurrency scenarios, no matter how small the application is, it also has a framework, which should be implemented after careful consideration, otherwise it will be full of technical debt, and it will cost more to maintain and reconstruct in the later stage.





Every day, Architecture Digest publishes a great article in the field of architecture, covering application architecture (high availability, high performance, high stability), big data, machine learning and other hot fields of first-tier Internet companies.