In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
It is believed that many inexperienced people don't know what to do about how to build a micro-service project architecture in Spring Cloud. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. Definition of micro-service
The popular definition of a microservice is a small project service, but writing an article requires a clear definition. The description language of the article is roughly as follows:
A micro-service that can run independently and provide complete services.
There are three conditions: independent operation, full service and miniature.
Running independently means being completely decoupled from other services, either merging them into a microservice or interacting through an interface if there is a business association between them. This also means that if database operations are involved between different microservices, one microservice cannot directly manipulate library tables belonging to another microservice, even if their tables are in the same library. Because once this behavior occurs, there is a new coupling dimension between the two microservices.
Providing complete services means that even if other unrelated micro-services are hung up, their own services provided through the interface will not be affected, unless there is an interface interaction between them, which only affects the related parts.
Micro means that each micro service will not have too many interfaces, otherwise it will become a traditional project.
Any service that meets the above three conditions, I think, is a micro-service-so, micro-service is a concept, not a technology. No matter what technology, framework or method is used to build it.
2. Benefits of microservices
The main benefits of micro services are: agile development, selective expansion, etc.
Projects that use micro-service architecture can achieve agile development because of the complete decoupling between micro-services-that is, a micro-service fix has some BUG or upgraded version, and only needs to be redeployed and upgraded, unlike traditional projects, fix a small BUG has to redeploy and upgrade the entire service; decoupling between services is very convenient for agile development, upgrade, and so on.
At the same time, you can also selectively expand or cluster according to the concurrency of micro-services. For example, for a micro-service with extremely high concurrency, you can deploy projects and databases separately. (as mentioned above, micro-services cannot manipulate data belonging to other micro-services. Even queries are not allowed. In this way, when a micro-service needs to be deployed independently, there is no coupling problem, otherwise it will cause other micro-services to directly operate the micro-service database failure due to migration.
3. Why use Spring Cloud
Spring Cloud recommends a number of micro-service solutions, using Spring Cloud to quickly build a micro-service architecture and relying on the good ecology of the Spring community.
4. The idea of using Spring Cloud to build micro-services.
First of all, you need a registry for the registration service, which can be selected as zookeeper or eureka.
Other micro services register in the self-built registry and communicate through resttemplate+ribbon. In this case, url does not need to use the full ip+port method, but uses the name provided by the micro service when registering in the registry. Another advantage of using only the registered name instead of ip+port for communication is that clustering can be achieved: multiple copies of the same micro-service are deployed, and no matter what the ip and port are, ribbon will schedule the micro-service cluster to achieve load balancing.
There is also the use of feign to achieve the effect of interface calls like RPC, and feign itself already uses ribbon.
When microservices provide interfaces to external access, it is not as convenient to use registration name communication as between microservices, but it still requires ip+port to access: this is very troublesome for interface users. After all, the number of microservices may be very large, and external callers need to remember the port numbers of each microservice, and this will not make the cluster effective. At this time, you can configure the unified gateway to allow the user to forward it to the corresponding micro-service through the gateway. In this way, the case of multiple microservices and clusters is transparent to the caller, and the user's perception is that an interface of the service is invoked, rather than an interface under a specific microservice.
After reading the above, have you mastered the method of how to build the micro-service project architecture in Spring Cloud? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 207
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.