[golang gin framework] 39. Gin Mall Project - Microservice Architecture in Microservice Practice

1. Introduction

The monolithic architecture is widely used in small and medium-sized enterprises . When the business is not complicated and the team size is small , the monolithic architecture has higher productivity than the microservice architecture.

Monolithic architecture

When the business is more complex , the amount relatively large, and the team size expands, it is necessary to introduce the microservice architecture. It has higher productivity than the single architecture, can save costs , and solve problems such as high concurrency and project restart . For example: A mall project needs to be upgraded, and an api interface needs to be added. In the case of a single architecture, the framework routers file needs to be modified, and then re-published and deployed . At this time, the application needs to be restarted , and the service will start after the restart. At this time, if there is a The user is in the payment operation, but the project is restarting at this time, and the order will be lost at this time , which will bring unnecessary troubles to the user and business personnel; what's more: when the concurrency is relatively large , it needs to be expanded Server , to achieve load balancing, such an operation is to optimize the entire website , which will increase the cost of operation and maintenance , at this time it is necessary to use microservices



, when the concurrency is relatively large, you can find out which module has a large concurrency, and you can optimize this module , because each module is independent when using microservices . For example: front-end login operation (authentication If the concurrency of the login module (verification code service) is relatively large, we can optimize the microservice of the login module (verification code service) and deploy more microservices of the login module (verification code service). For example, if the concurrency of the order module service is relatively large, we can Several more order module service cluster operations can be deployed, which can achieve high concurrency and save hardware costs. Another advantage is that when microservices are used, project upgrades are also easy to handle. In the case of a single architecture , you need to modify the framework routers file, and then re-publish and deploy . At this time, the application needs to be restarted , and the service will start after the restart. For micro-services, you only need to add a micro-module service function, and the existing functions of the project will not be affected.

Two. Program

  1. The first solution of the mall microservice architecture

  1. The second solution of the mall microservice architecture

[Previous section] [golang microservice] 9.go-micro + gorm implements paging query of commodity microservices

[Previous section] [golang gin framework] 38. Gin operates Elasticsearch to create indexes, modify mappings, data CURD and data paging

[next section]

 

Guess you like

Origin blog.csdn.net/zhoupenghui168/article/details/131564823