This is the 30th day of my participation in the Wenwen Challenge.

Architectural design method

What are the methods of architectural design? Architectural design follows specific methods, such as TOGAF (The Open Group Architecture Framework), five-view approach, etc. Among them, TOGAF is mainly aimed at complex enterprise system architecture, which is relatively heavy and not suitable for Internet products with very fast iteration speed. Therefore, Internet companies mainly use the five-view method.

What is a five-view method? It refers to drawing the corresponding logical view, development view, operation view, physical view and data view to design the architecture from the aspects of business logic, development environment, running state, physical deployment and data relationship. The logical view, development view, and running view belong to the software architecture, while the physical view and data view belong to the system architecture.

  • Logical view: Corresponds to the logical architecture, focusing on functional requirements and the division of system responsibilities and behaviors. The logical view includes not only the functions visible to the user, but also the corresponding auxiliary functions. For example, in the second kill system, activities switch, commodity list, user login, activity management, background permissions and other functions, among which background permissions belong to auxiliary functions.

  • Development view: corresponding to the development architecture, focusing on the quality attributes of the system development process. It includes the way of organization, configuration, compilation and packaging of software source code and the dependence with third-party packages.

For example, the second kill system we introduce here uses Go language to develop the code, uses TOML format to store the configuration, and Gitlab performs compilation and packaging, etc.

  • Operation view: corresponding to the operation architecture, it mainly focuses on the quality attributes in the software operation process, including process, thread, coroutine, concurrency, synchronization and communication between objects, etc.

For example, when a seckill system runs with coroutines that consume data from a queue, and coroutines that filter requests and write valid requests to a queue, it requires good design to deal with concurrency, synchronization, and communication between them.

So that’s the software architecture aspect of the five-view approach. Now let’s look at the other two, which are systems architecture aspects.

  • Physical view: focuses on installation and deployment requirements corresponding to the physical architecture. It includes the system, network, server and other infrastructure and related configuration when the software is running, and how to use the infrastructure to realize the high availability and scalability of applications.

For example, the Server Load Balancer (SLB) of a cloud vendor is used to provide Load balancing capabilities, and the multiple availability zone (HA) of a cloud vendor is used to achieve high availability.

  • Data view: corresponding to the data architecture, focusing on data requirements, including data formats, attributes, relationships, etc.

For example, the second kill system activity and activity theme, activity of the relationship and attributes of goods, administrators can create, modify and delete activity theme, events, goods and so on through the management background.

Why do software architectural designs need these views? What problem are they trying to solve?

As the saying goes, “a picture is worth a thousand words.” The five views in an architectural design are like the construction drawings of the different parts of a building in an architectural project. They make it easier to understand what needs to be done.

For example, at the first glance of the logical view, development view, operation view, data view, know which functions to develop, how to implement, how to deploy; O&m personnel know how to deploy infrastructure by looking at the physical view. As soon as the tester looks at the data view, he understands how to verify the accuracy of the data through a series of actions.

Second kill system architecture design

Earlier we looked at how architecture is designed and why. So how to design the system architecture of seckill?

I’m going to use the five-view approach I just mentioned.

Logical architecture

As we know from the previous definition, logical architecture is concerned with functional requirements. Do you still remember the functional requirements of miui SEC kill system I mentioned in module 1? At that time, it introduced the demand analysis of the front end, back end and management background of seckill system, such as activity information management, activity details, commodity details, etc., and the results of demand analysis are to design the logical architecture.

There are so many requirements at the front end, back end and back end of the management system, how do we organize those requirements information? There is a “three-tier architecture” approach to logical architecture that can help us solve this problem. Which three floors? They are the presentation layer, the business logic layer, and the data layer.

The presentation layer

The so-called presentation layer simply refers to the way users can use system functions. Through the demand analysis, we learned that the main users of miui network kill system are: consumers, administrators. Consumers can obtain the activity information and commodity information through the computer Web terminal, mobile phone Web terminal and mobile phone App terminal. The administrator can access the management background from the Web terminal of the computer to manage the kill activities.

The computer Web terminal, mobile phone Web terminal and mobile phone App terminal are mainly used to present the activity information and commodity information to users, and provide the entrance of relevant operations, such as purchase and background maintenance, which belong to the presentation layer.

Logic layer

The logical layer is mainly related to business logic, such as the front end functions of seckill system mainly include user login, view activities, subscription notification, view goods, purchase, order, etc. The functions of the management background mainly include thematic management, field management, commodity management, inventory management, price management, purchase restriction management and so on. These are all related to the seckill business logic, so we can attribute the related requirements to the logical layer.

The data layer

The data layer refers to what data the business logic of the system needs to process. For example, the data of seckill system includes configuration data and user data, among which configuration data is mainly activity information and commodity information, and user data is mainly user order and user information, which can be classified into the data layer.

Physical architecture

  • First, in order to achieve static and static separation, we need to deploy CDN nodes to cache the static pages and static data of sec-killed system using CDN, so as to provide higher performance by utilizing CDN’s nearby access ability. For example, we can deploy CDN nodes in both China and Singapore to provide better access speed for Both Chinese and overseas users.

  • Second, static and static separation means that in addition to the CDN, we also need to deploy the snapkill back-end node. To achieve high availability of back-end nodes, we need to use cloud architectures to ensure high availability of their infrastructure layer. You also need to deploy to multiple availability zones in the cloud to prevent the failure of a single availability zone from affecting services. For example, use two availability zones, each with two machines. When accessing storage resources, each device works in active/standby mode and preferentially accesses the storage resources in the current availability zone. If the storage resources in the current availability zone are faulty, the device automatically switches to the secondary storage resources in another availability zone. Storage between different available areas is synchronized using high-speed dedicated lines.

  • Third, we need to deploy routers, firewalls, switches, and Server Load balancers (SLBS) in order to provide services to the different availability zones as a whole. The router receives requests from the Internet and forwards them to the Intranet. Firewalls filter out risky data, such as cyber attacks by hackers; The switch is responsible for forwarding requests to specific availability zones; SLB is a load balancer that can provide access to multiple nodes in the availability zone as a whole and evenly forward requests to each back-end node. SLBS are deployed in active/standby mode. If the SLB in AZ 1 fails, the SLB in AZ 2 automatically takes over the traffic from AZ 1 and forwards the traffic to the cloud host in AZ 1.

  • Fourth, after each node is deployed, domain name resolution needs to be set to resolve the domain name to the SLB extranet IP address deployed. Generally, for a system with heavy traffic, multiple load balancers are used and dynamic DNS resolution is used to perform DNS load balancing for multiple SLBS to prevent a single SLB from carrying heavy traffic.

The data architecture

The data architecture is usually represented by an E-R (Entity Relationship Diagram), which is commonly used to represent the Relationship between data objects and their properties and users.

In the process of demand analysis, we learned that the second kill system mainly has two major data: activity information and commodity information. In addition to these two primary data points, there are two secondary data points: orders and blacklists. Orders are generated when users snap up commodities and place orders, while blacklists are designed to counter scalpers, usually generated through big data analysis and statistics. If the user ID is in the blacklist, it is not allowed to snap up commodities.

So what are the attributes of these big data sets?

Combined with the demand analysis process, we learned that:

  • Event information, including topics, sessions, description, time, purchase restriction policy, commodity list, status and other information;

  • Commodity information, including commodity ID, name, description, specification, original price, active price, active stock and other information;

  • Order information, including order ID, user ID, commodity ID, commodity price, commodity quantity, total price, delivery address, creation time and other information;

  • Blacklist, including the user ID list.

In these data, activity information, commodity information, blacklist are managed by the administrator in the management background, only the order information is created by users in the mall order, the administrator can view the order information through the management background.