background
As I have seen many technical systems along the way and witnessed some technical systems stop maintenance, I want to use a better technical system to build a distributed micro-service system, including the technology of development, middleware and operation and maintenance, as the technology stack of a technical team I hope. This year SpringCloud started to stop maintaining old technologies like Eureka, Feign, Zuul, and the Elastice-Job at Dangdang, which was going down. So for these reasons, you want to change the technology stack that works.
And I saw the other mall project, or do not use the service, or just write a backend or front end, or only use pure technologies give write function, monomer move brick is applied to implement the function, finish, so want to his own in the shape of a real point to development, try to solve and how reliable and stable distributed service plan.
I also made the background picture above, isn’t it also very beautiful
The purpose of this article
- To give you an overview of the overall design and the reasons for using the technology stack for some of the designs.
- Introduce the tools used to develop small programs and start front-end development
- Later, the key points and technical difficulties of each technical scenario will be introduced one by one. For example, when the rule engine is used, unified accounts are used for unified authentication. I’ve shared some of the techniques before, so I’m going to use them for this project.
- Some things are just under development and not finished yet.
- This article is also for their own to write about their favorite technology, leave a bottom.
Welcome to pay attention to the public number, the article faster step
My public account: Tibet thinking
The technical architecture
This time, we will focus on SpringCloudAlibaba
Service governance:
SpringCloud Dubbo, because the original springCloud suite is no longer being maintained. Although dubbo was used this time, some people asked if they regretted switching from Dubbo to springCloud. No, because dubbo only had service scheduling and governance functions at that time. The service was also degraded because Hystrix was no longer in use, so Sentinel was used
Service Gateway:
I used to work in a company where a Java service was used as the server of app, and then aggregated several downstream services to provide interface package layer and returned to APP, as well as those authentication functions. This time, SpringCloud Gateway was used for forwarding and authentication. Authentication part has changed the way, this point is more critical, put in the later business system design.
Message queue:
Use RocketMq instead of rabbitMq (slow) and Kafka (no tags, multiple consumers in a queue will consume the same thing)
Distributed transactions:
Is the transaction across the system, used to use the final consistency, asynchronous processing, this time to see if there is a scenario to use the distributed synchronous transaction, before I understand the framework developed by LCN people, this time I want to use Ali’s Seata. (Currently under development, it has not been used)
Rule engine:
Drools are used for marketing services. They are rules for making discounts in the store, such as: subtract 10 for every 100 items, subtract 10 dollars for every 3 items, and give one item for every one item. In fact, you can use the rules engine to do, before the network loan company, is used for docking N third party different rules.
Scheduled task scheduling:
SchedulerX instead of elastice-job because dangdang is about to die. Vipshop packaged it with Elastic-Job and they made Saturn, and Tiger Tooth packaged Saturn. This time, I will investigate Ali SchedulerX and see which one works well.
This interface is generated automatically for self-research.
This is a framework I made myself, the Concise MVC generator, because microservices are now all called in Dubbo without HTTP interfaces to springCloudgateway or upper layer applications. So we created a uri based on some special annotation of the interface that generates: /#{interface name}/#{method name}. This allows developers to just develop the Dubbo interface and automatically generate the HTTP interface for the Gateway to call.
Front end:
At present, I only do the small program side, not the PC side. This time, I write the front end by myself and use UniApp. This framework is based on VUE, which can be compiled for wechat, Douyin, Baidu, Installation, ios and other program platforms with a single code. He would set up the navigation bar, route to which page, and all we had to do was write the logic, connect to the back-end interface, style, and interaction. And encapsulate some component styles like buttons that can be downloaded from their marketplace.
Why not use him to implement the front-end code on the PC side, because the PC is bigger, the style layout is different.
icon
Iconfront is ali’s icon library, where you can find icon generated fonts or pictures for vue code of small programs to use as UI
Compile tools
Visual Studio Code, HBuilderX, wechat developer tools
Background management system
Vueadmin is a framework that uses vueadmin, the same way UniApp does to give you the navigation bar and jump to things. Just put the implementation in there.
Operational facilities
In terms of operation and maintenance facilities, the technical stack is some components that I think are more useful in the loan company, and many subsequent companies also use those components. Among them, the best one is the system developed by the loan company based on K8S, because other companies can only deploy K8S in a test environment and proD environment.
In fact, THERE are many things in the operation and maintenance box that I will not do in this project, because I have no time to do too much, so I may ask others to help me deploy.
Microservice partitioning
UDB system
I see a lot of systems have a service called security, but they only do authentication. The reason why it is called UDB is that when I worked in an Internet company, the system was not only for authentication, but also for the function of unified account, that is, wechat, mobile login and QQ authorized login were all unified in one place, and the wechat and QQ numbers of the same people were all bound to one number. It also generates an ID, which acts as the userId, and allows other business systems to interact with it uniformly.
Wechat authorization is also oauth2’s.
In such a unified authentication place, the token generated by UDB can contain userId, which enables the development of springCloudgateway to use the GatewayFilter interface to uniformly intercept data. Authentication is performed in filter first, so that UDB system can return userId. The userID is then inserted into the BODY of the Http so that the gateway downstream can use the same userID for multiple projects (such as banks).
UDB authentication uses JWT encryption userId to ensure that users can only modify their own data, and will not modify other users’ id data, unless you give the token to others.
Through such a combination of Udb system and springCloudgateway, userId interaction and authentication can be unified. Different projects, such as e-commerce and ordering, can be distinguished by one userId and different APPIDS when the same people, or one person to the same enterprise has different ID numbers. You can see that icbc app and E-Rong App also have the same natural person number and different business ID.
Marketing services
Here include coupons, promotional activities, business activities of the preferential way, one said to the shop is favorable, a full 100 minus 10, a full three pieces of minus 10 pieces, if you use the traditional way, to list all call store preferential rules, a shop there are multiple rules, then you there are many favorable conditions, each have different results, If else is cumbersome in code, so I recommend using Drools first, and we’ll talk about how to use it later.
Other services I think are very general, depending on whether the final consistency is to do distributed transactions when withholding money or goods. I won’t go into the details.
A sample has been developed
conclusion
One day, people will build their own favorite systems and toys. Pay attention to the engineering structure of the project.
Welcome to pay attention to the public number, the article faster step
My public account: Tibet thinking
Nuggets of gold: Hide Kelvin
Jane: Hide Kelvin
My Gitee: Underground Collection Kelvin gitee.com/kelvin-cai