In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "dubbo interface call process, part of the field value loss how to do", in daily operation, I believe many people in dubbo interface call process, part of the field value loss how to do the problem there are doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "dubbo interface call process, part of the field value loss how to do" doubts help! Next, please follow the small series to learn together!
At work, I encountered a case where the field value was lost when calling the remote dubbo interface. After investigation, it is found that the code before and after the call is correct. The main reason is that hessian serialization is used when the interface is called, and there are duplicate fields between the child class and the parent class, resulting in the loss of field values.
Solution: Remove duplicate fields from the parent class.
dubbo serialization
Let's look at the concepts of serialization and deserialization:
Serialization: The process of converting an object into a sequence of bytes is called serialization of an object.
deserialization: The process of restoring a sequence of bytes to an object is called deserialization of an object.
Why serialize?
Serialization module provides data serialization between service provider and service consumer for dubbo protocol.
dubbo is a framework suitable for high concurrency and small data volume Internet application scenarios.
Serialization plays an important role in response speed, throughput and network bandwidth consumption of remote calls, and is one of the most critical factors to improve the performance of distributed systems.
The dubbo framework natively supports four serialization types, which correspond to the protocol one by one. The performance decreases in turn, namely:
dubbo serialization: A Java serialization scheme implemented by the dubbo framework itself, but not mature enough to be recommended for production use. (binary serialization)
Hessian2 serialization (default): Hessian is an efficient way to serialize binary across languages. (binary serialization), and then there are other new ways of cross-language serialization: Protostuff, ProtoBuf, Thrift, Avro, MsgPack, etc.
Json serialization: There are currently two implementations, one is the fastjson library used by Ali, and the other is the simple json library implemented by dubbo itself, but its implementation is not particularly mature, and the text serialization performance of json is generally not as good as the above two binary serialization. (Text serialization)
jdk serialization: Mainly using JDK comes with Java serialization implementation, performance is not ideal. Serialization methods specific to java: Kryo, FST
Using Kryo and FST is very simple, just add an attribute to the XML configuration of dubbo RPC:
After becoming an Apache Incubator project, the serialization method was optimized to support fastjson, fst, hessian2, jdk and kryo.
fst is a serialization framework that is fully compatible with JDK serialization protocol, serialization speed is 4 to 10 times that of JDK, and size is about 1/3 of JDK.
Kryo is also faster to serialize than JDK and is about 1/10th the size of JDK. Fst and kryo generally perform better than other serialization schemes and are recommended for production environments.
Frequently Asked Questions
dubbo supports different communication protocols
1. Dubbo Protocol
The default is to take the dubbo protocol, a single long connection, NIO asynchronous communication, based on hessian as a serialization protocol. The scenario used is that the amount of data transferred is small (less than 100kb per request), but the concurrency is high.
In order to support high-concurrency scenarios, there are generally only a few machines for service providers, but there are hundreds of service consumers, and the number of calls may reach hundreds of millions of times a day! At this time, it is most appropriate to use a long connection, that is, to maintain a long connection with each service consumer, possibly a total of 100 connections. Then directly based on long-connected NIO asynchronous communication, can support high concurrency requests.
Long connection, popular point, is to establish a connection after the request can be sent continuously, no need to establish a connection.
dubbo-keep-connection
For short connections, the connection needs to be reestablished before each request is sent.
dubbo-not-keep-connection
2, rmi protocol: take Java binary serialization, multiple short connections, suitable for the same number of consumers and providers, suitable for file transmission, generally less used.
Hessian protocol: Hessian serialization protocol, multiple short connections, suitable for the number of providers than the number of consumers, suitable for file transmission, generally less used.
HTTP protocol: take JSON serialization.
5. webservice: take SOAP text serialization.
Serialization protocols supported by dubbo
dubbo supports hession, Java binary serialization, json, SOAP text serialization and many other serialization protocols. Hessian, however, is its default serialization protocol.
Tell me about Hessian's data structure.
Hessian's object serialization mechanism has eight primitive types:
raw binary data
boolean
64-bit date (64-bit millisecond value)
64-bit double
32-bit int
64-bit long
null
UTF-8 encoded string
There are also three types of recursion:
list for lists and arrays
map for maps and dictionaries
object for objects
There is also a special type:
ref: Used to indicate a reference to a shared object.
Why is PB the most efficient?
In fact, PB performance is so good, mainly due to the following two reasons:
1. Use proto compiler to automatically serialize and deserialize, which is very fast and should be 20~100 times faster than XML and JSON.
2, its data compression effect is good, that is, it serializes the data volume is small. Because of its small size, transmission bandwidth and speed will be optimized.
At this point, the study of "how to lose some field values during dubbo interface call" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.