In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Dubbo-go application dimension registration model how to achieve", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Dubbo-go application dimension registration model how to achieve" it!
1 quotation
Prior to v1.5, the Dubbo-go registration model was based on services, which can be regarded as an interface dimension. For example, an example of registration information based on the service dimension model is as follows:
"com.xxx.User": [{"name": "instance1", "ip": "127.0.0.1", "metadata": {"timeout": 1000}}, {"name": "instance2", "ip": "127.0.0.2", "metadata": {"timeout": 2000}}, {"name": "instance3", "ip": "127.0.0.3", "metadata": {"timeout": 3000},]
The benefits of this model are self-evident, simple and intuitive, and provide fine-grained means of service control.
In the past two years, with the advent of the cloud era, this model has exposed its shortcomings:
The mainstream registration models are all application dimensions.
If you register with the service dimension, then the scale is proportional to the number of services. under the large-scale cluster, the registry is under great pressure.
2 new registration model for Dubbogo v1.5.0
This time Dubbo-go supports a new registration model, that is, the registration model of the application dimension. To put it simply, under the registration of the application dimension, the registration information is similar:
"application1": [{"name": "instance1", "ip": "127.0.0.1", "metadata": {}}, {"name": "instance2", "ip": "127.0.0.2", "metadata": {}, {"name": "instanceN", "ip": "127.0.0.3", "metadata": {}]
Under this mode, you can see that the registration information will be greatly reduced, and the size of the cluster is only related to the number of instances.
At the same time, in implementing this feature, Dubbo-go wants to maintain two goals:
Fully compatible with users and unaware of user migration
The ability to maintain fine control of the original service granularity-that is, to retain the metadata of the existing service dimensions
Therefore, Dubbo-go should focus on the following points:
At present, the configuration of Consumer is based on the interface. How to find the corresponding application of the interface according to the interface? For example, if the user configures the com.xxx.User service, how does Dubbo-go know which application provides the service?
After knowing which application it is, you can get the registration information of the application, such as instance information, from the registry; how do you know the metadata of the com.xxx.User service itself?
To solve these two problems, Dubbo-go introduces two additional components: ServiceNameMapping and MetadataService, based on the existing registration model.
The former is used to solve the mapping between services and applications, and the latter is used to obtain the metadata of services.
As a result, the application dimension registration model of Dubbo-go becomes:
Cdn.nlark.com/yuque/0/2020/png/755700/1595053608806-be43aed1-83b4-4a05-8d25-60a0c7fa5445.png ">
2.1 ServiceNameMapping
ServiceNameMapping is not complicated. Considering that most people want to invoke a service on the Consumer side, nine times out of ten they know which application provides the service, so Dubbo-go introduces a new configuration item, provideBy.
Of course, the so-called "nine times out of ten" means that sometimes you really don't know who provided the service, so Dubbo-go also supports a configuration center-based ServiceNameMapping implementation. Dubbo-go will use the service name as Key to read the corresponding application name from the configuration center. This means that when Provider starts, it also writes its own service-application name mapping to the configuration center in the configuration center.
2.2 MetadataService
MetadataService is a little more complex, with two modes: remote and local.
Similar to the previous ServiceNameMapping,Dubbo-go, it provides an implementation of the configuration center-based MetadataService, the remote pattern. When Provider starts, the service metadata is written in.
Another mode is the local mode. Dubbo-go can directly think of MetadataService as a normal micro-service, which is then provided by Provider. Similar to:
This leads to a problem:
Since Dubbo-go treats MetadataService as a normal service, how can Consumer get MetadataService's metadata? This is a typical chicken problem of laying eggs and eggs.
Dubbo-go 's solution is very simple and rough. When Provider starts, it not only writes the application's own information to the registry, but also writes its MetadataService information.
This is the registration information for an application:
In essence, application dimension registration information + service metadata = service dimension registration information. In other words, applying dimensional registration is just a way to reorganize this information.
3 differences and improvement
Dubbo-go v1.5.x aligns Dubbo 2.7.5, which can be considered as the direct implementation of its Go source code with reference to Dubbo 2.7.5, but considering the language differences between Java and Go, the implementation between them can not be completely equivalent.
3.1revision number revision comparison
When Dubbo v2.7.x registers with MetadataService, the hash values of all service interfaces applied by its provider are written into the metadata center as revision numbers, and this revision is the result of the overall calculation of the methods of all interfaces and their parameters. The purpose is to reduce the number of pulls from the consumer to the registry.
The hash algorithm used in Go to calculate revision is not consistent with Java, and the method signature information of Go and Java is different, so the calculated hash value must be different.
This inconsistency will cause that if the Go application and the Java application release the same service at the same time, the revision numbers of the Go service and the Java service must be different, and Consumer needs to cache the metadata of the two revisions respectively.
3.2 timing of application registration
When implementing Dubbo-go v1.5.0, one of the considerations is full backward compatibility with v1.4.x. The Dubbo-go v1.5.x application consumer can call either the service of the Dubbo-go v1.4.x application or the service of the Dubbo v2.6.x application, or it can invoke the service of the target v2.7.x application.
In order to achieve compatibility, the implementation of Dubbo-go v1.5.x faces a problem: when a Dubbo-go provider application starts, a service starts successfully, and after registering the application information with the metadata center, the instance will be registered with the registry, while the provider application of Dubbo 2.7.x registers the instance only after the information of all its service interfaces is registered with the metadata center!
The consequence of this problem is that every time the provider of Dubbo-go v1.5.0 publishes the interface to the metadata center, it will trigger the consumer application of Dubbo-go v1.5.0 / Dubbo v2.7.x to pull Dubbo-go v1.5.0 application information. When provider publishes too many services, the performance loss of the consumer side is very obvious!
Dubbo-go fixed this problem in v1.5.1. Provider first publishes all its service interfaces to the metadata center at startup, and then registers the instance to the registry, reducing the number of times consumer pulls metadata.
Thank you for your reading, the above is the content of "how to realize the Dubbo-go application dimension registration model". After the study of this article, I believe you have a deeper understanding of how to realize the Dubbo-go application dimension registration model, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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: 0
*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.