Microservice architecture design (1)

Microservice architecture design (1)

Opening remarks

Nowadays, many companies have high-concurrency systems. The previous monolithic architecture has encountered a bottleneck, and an architecture is needed to solve this pain point. When the monolithic architecture and system traffic are large, the concurrency cannot be increased, and the system is easily blocked. It doesn’t work. At this time, microservices are created to solve this kind of pain point. Microservices and dividing a single service into multiple microservices adopt the idea of ​​divide and conquer. The split microservices also need to be moderate. Can not be divided into too detailed; the three principles of business oriented, road to simplicity, divide and conquer, taking into account the company's business needs, input and output, system expansion, etc., in short, the architecture is to use the minimum labor cost to construct and maintain the realization of requirements .

Architecture selection

Selection one

For very large concurrency, it can be used, nginx cluster plus gateway cluster
Microservice architecture design (1)
1, nginx can do routing and forwarding, and can separate dynamic and static, caching, reverse proxy, load balancing
2, gateway (zuul, gateway), gateway can load balance, authentication and authentication Right, data encryption
3.
Microservices , which are various subsystems, order services, commodity services, etc. 4. Eruka is service registration and service discovery, including client, and server. Each microservice is registered to it, and the client pulls the service list Query the service, and then access the service through http.
5. Cache redis can improve access speed.
6. Timing tasks can perform timing processing for logic that needs asynchronous processing.
7. Message queues can perform system decoupling, traffic peaking, asynchronous processing, log processing, and data synchronization.
8. File system , Can store files specifically, such as fastDFS, hadoop, gfs
9, cdn, can be used to speed up file access
10, database (mysql), open source, mature system, can be used to store structured data
11, cloud host, Hardware server used to deploy the service

Selection two

Microservice architecture design (1)
This architecture has an additional api aggregation service. All terminals pass through the gateway and then access the aggregation service. The apis of all the aggregation services are placed in the same microservice. This is conducive to the code management of the api and improves the development efficiency; the disadvantage is Concurrency is not very high, and multi-person development is prone to conflicts.

Selection three

Microservice architecture design (1)
This architecture, api aggregation service, has been changed to multiple api microservices, which can improve concurrency, but the disadvantage is also not conducive to early development. Each business must have an api that is relatively scattered, the code is not easy to manage, and the deployment is slightly complicated .

to sum up

1. The above three architectures have their own advantages and disadvantages. Many of the microservices are public, such as order services and commodity services. These can be made public, that is, public basic services for projects that are not built from scratch.
2. For those projects that build systems from scratch, it is best to start each system independently, which is conducive to the smooth progress of the project and the timely realization of requirements.
3. For a system with high concurrency, architecture 3 can be used, and various clusters, page static, cdn, thread pool, message queue, cache can be used to increase the amount of concurrency; current limit, fuse, downgrade, cut flow, version back Roll, timeout and retry to ensure high availability.

Guess you like

Origin blog.51cto.com/xxdeelon/2547726