Serialization method and deserialization method of data object and electronic equipment

By serializing only the unique identity of the metadata and the field values ​​of the data object in the microservice architecture, and associating the data receiver into the cached metadata, the problem of high serialization and deserialization performance overhead in the microservice architecture is solved, and the throughput of microservice applications is improved.

CN119513155APending Publication Date: 2025-02-25ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311076726.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-23
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the microservice architecture, the performance overhead caused by the serialization and deserialization process of objects is relatively large, affecting the throughput of microservice applications.

Method used

Under the microservice framework, if the metadata has been sent to the data receiver before sending the data object, only the unique identification of the metadata and the field value of the data object are serialized and sent to the data receiver. The data receiver associates the field value into the cached metadata based on the unique identifier after deserialization.

Benefits of technology

By reducing the overhead of serialization and deserialization of metadata, performance optimization is achieved and the throughput of microservice applications is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513155A_ABST
    Figure CN119513155A_ABST
Patent Text Reader

Abstract

The invention provides a serialization method and deserialization method of a data object and electronic equipment, and relates to the technical field of cloud computing, the method comprises the following steps: before a data sender sends the data object under a micro-service framework, if metadata of the data object is sent to a data receiver, the metadata of the data object is sent to the data receiver; if yes, serializing the unique identifier of the metadata and the value of the field to be sent of the data object to obtain serialized data; and sending the serialized data to a data receiver, carrying out deserialization processing on the serialized data by the data receiver, and associating the value of the currently received field to cached metadata based on the currently received unique identifier and the previously cached unique identifier. In the embodiment, the performance overhead of serialization and deserialization of the metadata is reduced, performance optimization is realized, and the throughput of a micro-service application is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of cloud computing, and in particular to a serialization method, a deserialization method and an electronic device for a data object. Background Art

[0002] Microservices refer to dividing a single application into a group of small services. The services coordinate and cooperate with each other. Each service runs in its own independent process and communicates with each other using lightweight communication mechanisms. Each service is built around a specific service and can be independently deployed to the production environment.

[0003] The microservice architecture style has been widely accepted. Although the microservice architecture has many benefits, it also introduces some additional overhead. Through performance analysis of microservice applications, it is found that, apart from the overhead of code execution itself, most of the overhead is spent on object serialization and deserialization. Therefore, how to optimize the performance of serialization and deserialization to improve the throughput of microservice applications has become a problem that needs to be solved. Summary of the invention

[0004] The embodiments of the present application provide a data object serialization method, a deserialization method and an electronic device to achieve performance optimization for serialization and deserialization, thereby improving the throughput of microservice applications.

[0005] In a first aspect, an embodiment of the present application provides a method for serializing a data object, the method comprising: before sending a data object under a microservice framework, if the metadata of the data object has been sent to a data recipient, serializing the unique identifier of the metadata and the value of a field to be sent of the data object to obtain serialized data; sending the serialized data to the data recipient so that the data recipient deserializes the serialized data and associates the value of the field with the metadata based on the unique identifier after deserialization.

[0006] In the second aspect, an embodiment of the present application provides a method for deserializing a data object, the method comprising: after receiving the metadata of the serialized data object, the unique identifier of the metadata, and the value of the field of the data object sent by the data sender under a microservice framework, deserializing the metadata, the unique identifier, and the value of the field of the serialized data object, and caching the metadata and the unique identifier; when the received serialized data object includes the unique identifier of the metadata and the value of the field, but does not include the metadata, associating the currently received field value to the cached metadata based on the currently received unique identifier and the previously cached unique identifier.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the above methods when executing the computer program.

[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the above is implemented.

[0009] Compared with the prior art, this application has the following advantages:

[0010] The present application provides a serialization method, a deserialization method and an electronic device for a data object. Before a data sender sends a data object under a microservice framework, if the metadata of the data object has been sent to a data receiver, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized to obtain the serialized data; the serialized data is sent to the data receiver, and the data receiver deserializes the serialized data, and associates the value of the currently received field with the cached metadata based on the currently received unique identifier and the previously cached unique identifier. In this embodiment, when a data object is transmitted between a data sender and a data receiver, it is not necessary to serialize and deserialize the metadata every time. If the metadata has been sent to the data receiver, the metadata is no longer sent in the subsequent data transmission. The data receiver associates the value of the field with the previously cached metadata through the unique identifier of the metadata to realize the data receiver's parsing of the data object. Since the performance overhead of serialization and deserialization of metadata is reduced, performance optimization is achieved, thereby improving the throughput of microservice applications.

[0011] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments according to the present application and should not be regarded as limiting the scope of the present application.

[0013] Figure 1 A schematic diagram of an application scenario of the serialization method and deserialization method of the data object provided in this application;

[0014] Figure 2A schematic diagram of object serialization according to an embodiment of the present application;

[0015] Figure 3 A flowchart of a method for serializing a data object according to an embodiment of the present application;

[0016] Figure 4 A schematic diagram of reading object data according to an embodiment of the present application;

[0017] Figure 5 A flowchart of a method for deserializing a data object according to an embodiment of the present application;

[0018] Figure 6 A structural block diagram of a device for serializing data objects according to an embodiment of the present application;

[0019] Figure 7 A structural block diagram of a device for deserializing a data object according to an embodiment of the present application; and

[0020] Figure 8 A block diagram of an electronic device used to implement an embodiment of the present application. DETAILED DESCRIPTION

[0021] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the concept or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary in nature and not restrictive.

[0022] To facilitate understanding of the technical solutions of the embodiments of the present application, the following describes the related technologies of the embodiments of the present application. The following related technologies can be combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.

[0023] Figure 1 A schematic diagram of an application scenario of the serialization method and deserialization method of the data object provided in this application. Figure 1 As shown, microservice application 1 is the data sender and microservice application 2 is the data receiver. The data sender and the data receiver establish a TCP long connection based on the Transmission Control Protocol (TCP). When the data sender sends a data object, it needs to be serialized, that is, a data object is written into a byte array. In order to let the data receiver know how to reconstruct the data object based on the byte array, the metadata of the data object needs to be written into the byte array.

[0024] For example, the following data object:

[0025] class Person{

[0026] String name;

[0027] int age;

[0028] }

[0029] The value of the name field of the data object is "Zhang San", and the value of the age field is 23. When serializing the data object, Figure 2 As shown, the byte array consists of metadata and value data. The metadata (such as Figure 2 The "type metadata" shown in the figure) occupies a relatively large part of the entire payload, while the actual effective payload (such as Figure 2 The "value data" shown in the figure does not occupy much space. If the metadata of the data object is serialized before each data object is sent, the data receiver needs to deserialize the received metadata each time, which will result in a large performance overhead.

[0030] In view of this, in this embodiment, it is not necessary to serialize and deserialize the metadata every time. Each time the data sender sends data, it determines whether the metadata of the data object to be sent has been sent to the data receiver in the previous data transmission process. If so, there is no need to send the metadata again. Instead, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized and sent to the data receiver. The data receiver deserializes the serialized data and associates the value of the field with the previously cached metadata based on the unique identifier after deserialization, thereby realizing the reconstruction of the data object. If the metadata of the data object was not sent to the data receiver in the previous data transmission process, the metadata, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized and sent to the data receiver. That is to say, the data sender serializes the metadata of the data object only when transmitting the data object for the first time, and then sends it to the data receiver. The data receiver then caches the metadata and unique identifier. Subsequent data transmission no longer transmits metadata, but instead reconstructs the data object based on the previously cached metadata and unique identifier. Since the amount of data in the unique identifier of the metadata is much smaller than the metadata itself, the serialization and deserialization overhead is relatively small. Therefore, this can reduce the performance overhead of serialization and deserialization of data objects.

[0031] The following describes the technical solution of the present application through multiple embodiments, taking the data sender and the data receiver as the execution subjects respectively.

[0032] The present application embodiment provides a method for serializing a data object. The method in the present embodiment can be applied to a computing device, which may include a server, a user terminal, etc. Figure 3 The flowchart of the method for serializing a data object according to an embodiment of the present application is shown, including:

[0033] Step S301, before sending the data object under the microservice framework, if the metadata of the data object has been sent to the data recipient, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized to obtain the serialized data.

[0034] Step S302: Send the serialized data to a data receiver, so that the data receiver deserializes the serialized data and associates the value of the field with metadata based on the unique identifier after deserialization.

[0035] In this embodiment, the execution subject is the data sender. Before sending the data object, the data sender first determines whether the metadata of the data object to be sent has been sent before. If it has been sent, the metadata is no longer serialized or sent. Instead, the unique identifier of the metadata and the value of the field of the data object are serialized and sent to the data receiver. Since the data volume of the unique identifier of the metadata is much smaller than the metadata itself, the performance overhead of serialization is reduced.

[0036] The metadata includes data describing the data object. Exemplarily, the metadata includes field type and field name.

[0037] It is understandable that the technical solution of the present application can also be applied to scenarios of non-microservice architectures. However, compared with applications under microservice architectures, the performance overhead caused by serialization and deserialization under non-microservice architectures is relatively small. Therefore, the technical solution of the present application significantly improves the serialization and deserialization performance under microservice architectures.

[0038] The serialization method of data objects provided in the embodiment of the present application, before sending the data object under the microservice framework, if the metadata of the data object has been sent to the data recipient, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized to obtain the serialized data; the serialized data is sent to the data recipient so that the data recipient deserializes the serialized data and associates the value of the field to the metadata based on the unique identifier after deserialization. In this embodiment, when transmitting data objects between the data sender and the data recipient, it is not necessary to serialize and deserialize the metadata every time. If the metadata has been sent to the data recipient, the metadata will no longer be sent in the subsequent data transmission. The data recipient associates the value of the field to the previously cached metadata through the unique identifier of the metadata to enable the data recipient to parse the data object. Since the performance overhead of serialization and deserialization of metadata is reduced, performance optimization is achieved, thereby improving the throughput of microservice applications.

[0039] In one implementation, the method further includes: if the metadata of the data object is not sent to the data recipient, serializing the metadata, the unique identifier of the metadata, and the value of the field to be sent of the data object; sending the serialized data to the data recipient so that the data recipient deserializes the serialized metadata, the unique identifier, and the value of the field, and caches the metadata and the unique identifier.

[0040] If the data sender determines that the metadata of the data object to be sent has not been sent before, the metadata, the unique identifier of the metadata and the value of the field of the data object to be sent are serialized and sent to the data receiver. The data receiver caches the metadata and the unique identifier to be used for reconstructing the value of the field of the received data object that does not contain metadata based on the cached unique identifier and metadata in the future to obtain the data object.

[0041] In one implementation, the method further includes: establishing a long connection with a data receiver based on the transmission control protocol TCP; sending the serialized data to the data receiver, including: the data sender sends the serialized data to the data receiver using the long connection.

[0042] In actual applications, the data sender and the data receiver establish a persistent connection based on the Transmission Control Protocol TCP. The process of sending data based on the TCP persistent connection is fixed. The message sent first will be received first. There will be no situation where the metadata is not received and the value of the field received first cannot be used to reconstruct the object.

[0043] In one implementation, the data object includes multiple fields. Before serializing the values ​​of the fields to be sent of the data object, the method also includes: if the actual layout of the multiple fields in the memory is inconsistent with the order in the code declaration of the fields, then reading the values ​​of the fields to be sent from the memory according to the actual layout in the memory.

[0044] Code declarations are statements used to define variables, functions, classes, etc. in programming, which tell the compiler or interpreter how to handle these identifiers when the program is executed. Through declarations, programmers can tell the compiler or interpreter the type of variables, the parameter and return value types of functions, the members of classes, and other information, so that the compiler or interpreter can correctly handle these identifiers.

[0045] Before serializing a data object, the values ​​of each field need to be read from memory. If the fields are read in the order in which they are declared in the code, there will be more cache misses. Reading the values ​​of the fields to be sent from memory according to the actual layout in memory can increase the cache hit rate.

[0046] In one example, if Figure 4 As shown in the figure, when reading the values ​​of each field (int a, doubled, charc, float f, Object o) of the data object class C, the L1 cache line of the central processor is 64 bytes. The order of reading the fields in the code declaration of the fields is as follows:

[0047] 1. Read field a (field type is int). A is not in the cache, so a cache miss occurs. At the same time, the addresses [+64,+128) and [+128,+192) where a is located are read into the cache.

[0048] 2. Read field d (field type is double). d is not in the cache, and a cache miss occurs. [+0,+64) needs to be loaded into the cache. However, since there are only two cache lines, according to the least recently used (LRU) algorithm, [+128,+192) has not been read recently. Therefore, [+128,192) is evicted from the cache and [+0,+64) is read into the cache.

[0049] 3. When reading field c (field type is char), c is not in the cache, a cache miss occurs, and [+64,+128) is evicted from the cache.

[0050] 4. When reading field f (field type is float), the corresponding address range [+0,+64) has been loaded into the cache in step 4, so the cache is hit.

[0051] 5. When reading field o (field type is Object), the corresponding address [64,128) is not in the cache, and a cache miss occurs. At the same time, [64,128) is added to the cache, and [+128,192) is evicted according to LRU.

[0052] It can be seen that according to the code declaration of the field, 5 fields are read and a total of 4 cache misses occur.

[0053] The order of reading fields according to the actual layout in memory is:

[0054] 1. Read field d. d is not in the cache, so an ache miss occurs. At the same time, [+0,+64) and [+64,+128) are read into the cache.

[0055] 2. Read field f. The address [+0,+64) corresponding to f has been read into the cache in step 1, so the cache is hit.

[0056] 3. Read field a. The address [+64,+128) corresponding to field a has been read into the cache in step 1, so the cache is hit.

[0057] 4. Read field o. The address [+64,+128) corresponding to field o has been read into the cache in step 1, so the cache is hit.

[0058] 5. Read field c. The address [+128,+192) corresponding to c is not in cache. A cache miss occurs. According to LRU, [+0,+64) is evicted.

[0059] It can be seen that according to the actual layout in memory, 5 fields are read and 2 cache misses occur.

[0060] In summary, reading fields according to the order in which they are declared in the code results in a high number of cache misses, whereas reading fields according to the actual layout in memory can increase the cache hit rate.

[0061] Corresponding to the above embodiment, the embodiment of the present application further provides a method for deserializing a data object. The method in this embodiment can be applied to a computing device, which may include: a server, a user terminal, etc. Figure 3 The flowchart of the method for deserializing a data object according to an embodiment of the present application is shown, including:

[0062] Step S501, after receiving the metadata of the serialized data object, the unique identifier of the metadata, and the value of the field of the data object sent by the data sender under the microservice framework, the metadata, the unique identifier, and the value of the field of the serialized data object are deserialized, and the metadata and the unique identifier are cached.

[0063] Step S502, when the received serialized data object includes the unique identifier of metadata and the value of the field, but does not include metadata, the value of the currently received field is associated with the cached metadata based on the currently received unique identifier and the previously cached unique identifier.

[0064] In this embodiment, the execution subject is the data receiver. After receiving the metadata of the serialized data object, the unique identifier of the metadata, and the value of the field of the data object sent by the data sender, the data receiver deserializes the metadata, the unique identifier, and the value of the field, and caches the metadata and the unique identifier. After that, the unique identifier of the metadata and the value of the field of the data object are received again. If the metadata is not included, the currently received unique identifier is matched with the previously cached unique identifier, and the metadata corresponding to the matched unique identifier is used as the metadata of the current data object. The value of the currently received field is associated with the cached metadata, thereby realizing the reconstruction of the data object.

[0065] The metadata includes data describing the data object. Exemplarily, the metadata includes field type and field name.

[0066] It is understandable that the technical solution of the present application can also be applied to scenarios of non-microservice architectures. However, compared with applications under microservice architectures, the performance overhead caused by serialization and deserialization under non-microservice architectures is relatively small. Therefore, the technical solution of the present application significantly improves the serialization and deserialization performance under microservice architectures.

[0067] The deserialization method of the data object provided in the embodiment of the present application, after receiving the metadata of the serialized data object sent by the data sender under the microservice framework, the metadata, the unique identifier of the metadata and the value of the field of the data object, deserializes the metadata, the unique identifier and the value of the field of the serialized data object, and caches the metadata and the unique identifier; when the received serialized data object includes the unique identifier of the metadata and the value of the field, and does not include the metadata, based on the currently received unique identifier and the previously cached unique identifier, the value of the currently received field is associated with the cached metadata. In this embodiment, when the data object is transmitted between the data sender and the data receiver, it is not necessary to serialize and deserialize the metadata every time. If the metadata has been sent to the data receiver, the metadata will no longer be sent in the subsequent data transmission. The data receiver associates the value of the field with the previously cached metadata through the unique identifier of the metadata to realize the data receiver's parsing of the data object. Since the performance overhead of the serialization and deserialization of the metadata is reduced, performance optimization is achieved, thereby improving the throughput of the microservice application.

[0068] In one implementation, the method further includes: establishing a long connection with a data sender based on a transmission control protocol TCP.

[0069] In actual applications, the data sender and the data receiver establish a persistent connection based on the Transmission Control Protocol TCP. The process of sending data based on the TCP persistent connection is fixed. The message sent first will be received first. There will be no situation where the metadata is not received and the value of the field received first cannot be used to reconstruct the object.

[0070] In one implementation, the data object includes multiple fields, and the values ​​of the fields of the data object are read and sent by the data sender according to the actual layout in the memory when the actual layout of the multiple fields in the memory is inconsistent with the order in the code declaration of the fields.

[0071] Code declarations are statements used to define variables, functions, classes, etc. in programming, which tell the compiler or interpreter how to handle these identifiers when the program is executed. Through declarations, programmers can tell the compiler or interpreter the type of variables, the parameter and return value types of functions, the members of classes, and other information, so that the compiler or interpreter can correctly handle these identifiers.

[0072] Before serializing a data object, the values ​​of each field need to be read from memory. If the fields are read in the order in which they are declared in the code, there will be more cache misses. Reading the values ​​of the fields to be sent from memory according to the actual layout in memory can increase the cache hit rate.

[0073] In one example, if Figure 4 As shown in the figure, when reading the values ​​of each field of the data object class C, the L1 cacheline is 64 bytes. The order of reading the fields in the code declaration of the fields is as follows:

[0074] 1. Read field a. A is not in the cache, so a cache miss occurs. At the same time, read the addresses [+64,+128) and [+128,+192) where a is located into the cache.

[0075] 2. Read field d. d is not in the cache, so a cache miss occurs. [+0,+64) needs to be loaded into the cache. However, since there are only two cache lines, according to the least recently used (LRU) algorithm, [+128,+192) has not been read recently. Therefore, [+128,192) is evicted from the cache and [+0,+64) is read into the cache.

[0076] 3. When reading field c, c is not in the cache, a cache miss occurs, and [+64,+128) is evicted from the cache.

[0077] 4. When reading field f, the corresponding address range [+0,+64) has been loaded into the cache in step 4, so the cache is hit.

[0078] 5. When reading field o, the corresponding address [64,128) is not in the cache, a cache miss occurs, and [64,128) is added to the cache, and [+128,192) is evicted according to LRU.

[0079] It can be seen that according to the code declaration of the field, 5 fields are read and a total of 4 cache misses occur.

[0080] The order of reading fields according to the actual layout in memory is:

[0081] 1. Read field d. d is not in the cache, so an ache miss occurs. At the same time, [+0,+64) and [+64,+128) are read into the cache.

[0082] 2. Read field f. The address [+0,+64) corresponding to f has been read into the cache in step 1, so the cache is hit.

[0083] 3. Read field a. The address [+64,+128) corresponding to field a has been read into the cache in step 1, so the cache is hit.

[0084] 4. Read field o. The address [+64,+128) corresponding to field o has been read into the cache in step 1, so the cache is hit.

[0085] 5. Read field c. The address [+128,+192) corresponding to c is not in cache. A cache miss occurs. According to LRU, [+0,+64) is evicted.

[0086] It can be seen that according to the actual layout in memory, 5 fields are read and 2 cache misses occur.

[0087] In summary, reading fields according to the order in which they are declared in the code results in a high number of cache misses, whereas reading fields according to the actual layout in memory can increase the cache hit rate.

[0088] In the embodiment of the present application, in combination with the microservice architecture that usually communicates based on TCP long connections, the metadata is cached to avoid transmission every time, thereby reducing the overhead of serialization and deserialization; in combination with the fact that the actual layout of Java objects in memory is inconsistent with the order of field code declarations, it is optimized to read objects according to the actual memory layout, thereby improving the cache hit rate and thus improving performance.

[0089] Using the technical solution of this application, for data objects of different object types, the performance improvement comparison after optimization is shown in Table 1:

[0090]

[0091] Table 1

[0092] Corresponding to the application scenario and method of the method provided in the embodiment of the present application, the embodiment of the present application also provides a serialization device for a data object. Figure 6 The structure block diagram of a data object serialization device according to an embodiment of the present application is shown, and the device includes:

[0093] The serialization module 601 is used to serialize the unique identifier of the metadata and the value of the field to be sent of the data object before sending the data object under the microservice framework to obtain the serialized data if the metadata of the data object has been sent to the data recipient.

[0094] The sending module 602 is used to send the serialized data to the data receiver, so that the data receiver deserializes the serialized data and associates the value of the field with the metadata based on the unique identifier after the deserialization.

[0095] The serialization device of the data object provided in the embodiment of the present application, before sending the data object under the microservice framework, if the metadata of the data object has been sent to the data receiver, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized to obtain the serialized data; the serialized data is sent to the data receiver, so that the data receiver deserializes the serialized data, and associates the value of the field to the metadata based on the unique identifier after the deserialization. In this embodiment, when the data object is transmitted between the data sender and the data receiver, it is not necessary to serialize and deserialize the metadata every time. If the metadata has been sent to the data receiver, the metadata will no longer be sent in the subsequent data transmission. The data receiver associates the value of the field to the previously cached metadata through the unique identifier of the metadata to realize the data receiver's parsing of the data object. Since the performance overhead of serialization and deserialization of metadata is reduced, performance optimization is achieved, thereby improving the throughput of microservice applications.

[0096] In one implementation, the device is also used to: if the metadata of the data object is not sent to the data recipient, serialize the metadata, the unique identifier of the metadata, and the value of the field to be sent of the data object; send the serialized data to the data recipient so that the data recipient deserializes the serialized metadata, unique identifier, and the value of the field, and caches the metadata and unique identifier.

[0097] In one implementation, the device is also used to: establish a long connection with a data receiver based on the transmission control protocol TCP; the sending module 602 is specifically used to: the data sender uses the long connection to send the serialized data to the data receiver.

[0098] In one implementation, the data object includes multiple fields, and the device is also used to: before serializing the values ​​of the fields to be sent of the data object, if the actual layout of the multiple fields in the memory is inconsistent with the order in the code declaration of the fields, then read the values ​​of the fields to be sent from the memory according to the actual layout in the memory.

[0099] In one implementation, the metadata includes a field type and a field name.

[0100] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.

[0101] Corresponding to the application scenario and method of the method provided in the embodiment of the present application, the embodiment of the present application also provides a deserialization device for a data object. Figure 7 The structure block diagram of a deserialization device for a data object according to an embodiment of the present application is shown, and the device includes:

[0102] The deserialization module 701 is used to deserialize the metadata, unique identifier and field value of the serialized data object after receiving the metadata, unique identifier and field value of the serialized data object sent by the data sender under the microservice framework, and cache the metadata and unique identifier;

[0103] The association module 702 is used to associate the currently received field value with the cached metadata based on the currently received unique identifier and the previously cached unique identifier when the received serialized data object includes the unique identifier of the metadata and the value of the field, and when no metadata is included.

[0104] The deserialization device of the data object provided in the embodiment of the present application, after receiving the metadata of the serialized data object sent by the data sender under the microservice framework, the unique identifier of the metadata and the value of the field of the data object, deserializes the metadata, unique identifier and field value of the serialized data object, and caches the metadata and unique identifier; when the received serialized data object includes the unique identifier of the metadata and the value of the field, but does not include the metadata, the value of the currently received field is associated with the cached metadata based on the currently received unique identifier and the previously cached unique identifier. In this embodiment, when the data object is transmitted between the data sender and the data receiver, it is not necessary to serialize and deserialize the metadata every time. If the metadata has been sent to the data receiver, the metadata will no longer be sent in the subsequent data transmission. The data receiver associates the value of the field with the previously cached metadata through the unique identifier of the metadata to realize the data receiver's parsing of the data object. Since the performance overhead of the serialization and deserialization of the metadata is reduced, performance optimization is achieved, thereby improving the throughput of the microservice application.

[0105] In one implementation, the device is also used to: establish a long connection with a data sender based on the transmission control protocol TCP.

[0106] In one implementation, the data object includes multiple fields, and the values ​​of the fields of the data object are read and sent by the data sender according to the actual layout in the memory when the actual layout of the multiple fields in the memory is inconsistent with the order in the code declaration of the fields.

[0107] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.

[0108] Figure 8 FIG. 1 is a block diagram of an electronic device used to implement an embodiment of the present application. Figure 8 As shown, the electronic device includes: a memory 810 and a processor 820. The memory 810 stores a computer program that can be run on the processor 820. When the processor 820 executes the computer program, the method in the above embodiment is implemented. The number of the memory 810 and the processor 820 can be one or more.

[0109] The electronic device also includes:

[0110] The communication interface 830 is used to communicate with external devices and perform data exchange transmission.

[0111] If the memory 810, the processor 820 and the communication interface 830 are implemented independently, the memory 810, the processor 820 and the communication interface 830 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0112] Optionally, in a specific implementation, if the memory 810, the processor 820 and the communication interface 830 are integrated on a chip, the memory 810, the processor 820 and the communication interface 830 can communicate with each other through an internal interface.

[0113] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present application when the program is executed by a processor.

[0114] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present application.

[0115] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.

[0116] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the Advanced RISC Machines (ARM) architecture.

[0117] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of exemplary but not limiting description, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DR RAM).

[0118] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.

[0119] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.

[0120] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0121] Any process or method described in the flow chart or otherwise described herein can be understood as a module, fragment or portion of a code representing one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.

[0122] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or used in combination with these instruction execution systems, devices or apparatuses.

[0123] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.

[0124] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.

[0125] The above is only an exemplary embodiment of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope recorded in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for serializing a data object, characterized in that: The method comprises: Before sending a data object under the microservice framework, if the metadata of the data object has been sent to the data recipient, the unique identifier of the metadata and the value of the field to be sent of the data object are serialized to obtain serialized data; The serialized data is sent to the data receiver, so that the data receiver deserializes the serialized data and associates the value of the field with the metadata based on the unique identifier after deserialization.

2. The method according to claim 1, characterized in that The method further comprises: If the metadata of the data object has not been sent to the data recipient, serializing the metadata, the unique identifier of the metadata, and the value of the field of the data object to be sent; The serialized data is sent to the data receiver, so that the data receiver deserializes the serialized metadata, unique identifier and field value, and caches the metadata and the unique identifier.

3. The method according to claim 1, characterized in that The method further comprises: Establishing a long connection with the data receiver based on the Transmission Control Protocol TCP; The sending the serialized data to the data receiving party includes: The data sender uses the long connection to send the serialized data to the data receiver.

4. The method according to any one of claims 1 to 3, characterized in that: The data object includes a plurality of fields. Before serializing the values ​​of the fields to be sent of the data object, the method further includes: If the actual layout of the multiple fields in the memory is inconsistent with the order in the code declaration of the fields, the values ​​of the fields to be sent are read from the memory according to the actual layout in the memory.

5. The method according to any one of claims 1 to 3, characterized in that: The metadata includes field type and field name.

6. A method for deserializing a data object, characterized in that: The method comprises: After receiving the metadata of the serialized data object, the unique identifier of the metadata, and the value of the field of the data object sent by the data sender under the microservice framework, the metadata, the unique identifier, and the value of the field of the serialized data object are deserialized, and the metadata and the unique identifier are cached; When the received serialized data object includes the unique identifier of the metadata and the value of the field, but does not include the metadata, the value of the currently received field is associated with the cached metadata based on the currently received unique identifier and the previously cached unique identifier.

7. The method according to claim 6, characterized in that The method further comprises: A long connection is established with the data sender based on the Transmission Control Protocol TCP.

8. The method according to claim 6 or 7, characterized in that: The data object includes multiple fields, and the values ​​of the fields of the data object are read and sent by the data sender according to the actual layout in the memory when the actual layout of the multiple fields in the memory is inconsistent with the order in the code declaration of the fields.

9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein the processor implements the method according to any one of claims 1 to 5 or 6 to 8 when executing the computer program.

10. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 or 6 to 8 is implemented.

Citation Information

Cited By

  • Graph database query throughput optimization method based on client multiplexing object

    CN120763351A

  • Method for optimizing query throughput of a graph database based on client-side reuse objects

    CN120763351B