Instance startup and message forwarding method and device

By implementing the port multiplexing function and message forwarding mechanism in the blockchain network, the problem of startup failure caused by port occupation during instance startup in the blockchain network is solved, ensuring the normal operation of the instance and accurate packet forwarding.

CN115914371BActive Publication Date: 2024-08-27ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211351108.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-31
Publication Date
2024-08-27
Estimated Expiration
2042-10-31

AI Technical Summary

Technical Problem

In the blockchain network, due to limited port resources when a server instance is started, the instance started first may occupy the port and the instance started later cannot start.

Method used

By implementing the port reuse function in the server, multiple instances are allowed to share the same port, and when the target port is occupied by other instances and the instance has the port reuse function enabled, the port reuse function is enabled for the new instance to ensure that it can Start normally, and use the message forwarding unit to determine the destination instance based on the address information for accurate forwarding.

Benefits of technology

It effectively solves the problem that the instance started first occupies the port and causes the instance started later to fail to start. It ensures that multiple instances can run normally and avoids packet confusion in port reuse scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115914371B
    Figure CN115914371B
Patent Text Reader

Abstract

This specification provides an instance startup and message forwarding method and device. The instance startup method is applied to a server, the server is connected to a blockchain network, a first server instance and at least one other instance are deployed in the server, and the instance is used to provide blockchain services related to the blockchain network, including: when any other instance is started, read the mode configuration information of the first service instance in response to the startup instruction for the first server instance; when the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled, determine whether the target port bound to the first server instance is occupied by other instances; if the target port is occupied by other instances, enable the port reuse function of the first server instance, and try to start the first server instance after the enablement is completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification belong to the field of blockchain technology, and more particularly, to a method and device for instance startup and message forwarding. Background Art

[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. In the blockchain system, data blocks are combined into a chain data structure in a sequential manner according to time order, and a distributed ledger that cannot be tampered with or forged is guaranteed by cryptography. Users can participate in blockchain-related transactions through blockchain nodes. For example, multiple blockchain nodes corresponding to different users in the blockchain network can perform secure multi-party computation (SMPC) on the private data of a certain node based on privacy technologies such as homomorphic encryption and zero-knowledge proof.

[0003] At this stage, instances (such as server instances and client instances) can be deployed in the server to provide blockchain services related to the blockchain network to the participants in the blockchain network. At the startup stage of any instance, it is necessary to bind a port to it so that it can interact with other instances or servers through the port after the startup is completed. Among them, the client instance can be randomly assigned an available port by the server, and the server instance can be assigned a port by the user or bound to a default port.

[0004] Since the number of port resources provided by the server is usually limited (such as 0 to 25535, etc.), there may be port occupation between different instances. For example, the port set for a server instance may have been occupied by other server instances or client instances that have been started. At this time, if the server instance is started normally according to the port, it will fail to start. In other words, there is a problem that the instance started first occupies the port and the server instance started later cannot start. Summary of the invention

[0005] The object of the present invention is to provide an instance startup and message forwarding method and device.

[0006] According to a first aspect of one or more embodiments of this specification, an instance startup method is proposed, which is applied to a server, the server is connected to a blockchain network, and multiple instances are running in the server, and the instances are used to provide blockchain services related to the blockchain network. The method includes:

[0007] In response to receiving a message to be forwarded, reading a destination port of the message to be forwarded;

[0008] When the multiple instances are respectively bound to the destination ports and the port multiplexing function is enabled for the multiple instances respectively, the destination instance corresponding to the message to be forwarded is determined from the multiple instances according to the address information carried by the message to be forwarded, and the message to be forwarded is forwarded to the destination instance.

[0009] According to a second aspect of one or more embodiments of this specification, a message forwarding method is proposed, which is applied to a server, the server is connected to a blockchain network, and a first server instance and other instances are deployed in the server, and the instances are used to provide blockchain services related to the blockchain network. The method includes:

[0010] In response to a start instruction for the first server instance, reading mode configuration information of the first service instance;

[0011] If the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled, determining whether the target port bound to the first server instance is occupied by other instances that have been started;

[0012] If the target port is occupied by other instances that have been started, and the port reuse function has been enabled for the other instances that occupy the target port, the port reuse function of the first server instance is enabled, and after the enabling is completed, the first server instance is attempted to be started.

[0013] According to a fourth aspect of one or more embodiments of this specification, an instance startup device is proposed, which is applied to a server, the server is connected to a blockchain network, and multiple instances are running in the server, the instances are used to provide blockchain services related to the blockchain network, and the device includes:

[0014] A port reading unit, configured to read a destination port of the message to be forwarded in response to receiving the message to be forwarded;

[0015] A message forwarding unit is used to determine the destination instance corresponding to the message to be forwarded from the multiple instances according to the address information carried by the message to be forwarded, and forward the message to be forwarded to the destination instance when the multiple instances are respectively bound to the destination ports and the port multiplexing function is enabled for the multiple instances respectively.

[0016] According to a fifth aspect of one or more embodiments of this specification, a message forwarding device is proposed, which is applied to a server, the server is connected to a blockchain network, a first server instance and at least one other instance are deployed in the server, and the instance is used to provide blockchain services related to the blockchain network, and the device includes:

[0017] An information reading unit, configured to read mode configuration information of the first service instance in response to a startup instruction for the first server instance;

[0018] an occupation judgment unit, configured to judge whether a target port bound to the first server instance is occupied by another instance that has been started, if the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled;

[0019] The instance startup unit is used to enable the port reuse function of the first server instance if the target port is occupied by other instances that have been started and the other instances occupying the target port have enabled the port reuse function, and try to start the first server instance after the enabling is completed.

[0020] According to a seventh aspect of one or more embodiments of this specification, an electronic device is provided, including:

[0021] processor;

[0022] a memory for storing processor-executable instructions;

[0023] The processor implements the method as described in any one of the first aspect or the second aspect by running the executable instructions.

[0024] According to an eighth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in any one of the first aspect or the second aspect are implemented.

[0025] In the aforementioned embodiment, the server can read the mode configuration information of the first service instance in response to the startup instruction for the first server instance; and then, when the mode configuration information does not indicate that the port multiplexing function of the first server instance needs to be enabled, determine whether the target port bound to the first server instance is occupied by other instances that have been successfully started; then, if the target port is occupied by other instances that have been successfully started, and the other instances occupying the target port have enabled the port multiplexing function, the server can enable the port multiplexing function of the first server instance, and attempt to start the first server instance after the enabling is completed.

[0026] Each instance described in this solution has a port reuse function, that is, when this function is turned on, multiple instances can share the same port provided by the server. Based on this, this solution enables the port reuse function for the first server instance when the target port is occupied by other instances and the other instances have enabled the port reuse function, so that the first server instance can reuse the port with other instances that occupy the target port and also enable the port reuse function. For the first server instance, it can monitor the target port normally, so that it can be started smoothly. Obviously, when the target port bound to the first server instance is occupied by other instances, the first server instance can be started smoothly by turning on the port reuse function, which effectively solves the problem that the server instance started later cannot be started because the instance started first occupies the port.

[0027] In addition, when multiple instances bound to the same port respectively enable their own port multiplexing functions, for the to-be-forwarded messages received by the port (i.e., messages with the destination port being the port), the server can determine the corresponding target instance from the multiple instances based on the address information carried by the message, and forward the message to the instance, thereby achieving accurate forwarding of the message, and to a certain extent avoiding the message confusion that may occur in the port multiplexing scenario, thereby ensuring that multiple instances that reuse the same port after startup can operate normally respectively. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0029] Figure 1 This is a process of an example startup method provided by an exemplary embodiment.

[0030] Figure 2 This is a process of another example startup method provided by an exemplary embodiment.

[0031] Figure 3 This is a process of a message forwarding method provided by an exemplary embodiment.

[0032] Figure 4 It is a structural schematic diagram of a device provided by an exemplary embodiment.

[0033] Figure 5 It is a block diagram of an example starting device provided by an exemplary embodiment.

[0034] Figure 6It is a block diagram of another message forwarding device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0035] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0036] In order to solve the problem in the related art that the first started instance occupies the port and causes the server instance started later to fail to start, this specification proposes an instance startup method. The instance startup scheme is described in detail below in conjunction with the accompanying drawings.

[0037] See also Figure 1 , Figure 1 1 is a flowchart of an example startup method provided by an exemplary embodiment. The method is applied to a server, the server is connected to a blockchain network, a first server instance and at least one other instance are deployed in the server, and the instance is used to provide blockchain services related to the blockchain network. Figure 1 As shown, the method includes steps 102-106.

[0038] Step 102: In response to a start instruction for a first server instance, read mode configuration information of the first service instance.

[0039] The server described in this specification is connected to a blockchain network, in which multiple instances can be deployed to provide blockchain services related to the blockchain network. Exemplarily, the blockchain services may include but are not limited to consensus services, network services, storage services, contract services, etc.

[0040] Among them, during the operation process after the startup is completed, any instance can actively establish a network connection with other instances in the server, or can also actively establish a network connection with other servers or instances outside the server. At this time, any instance is equivalent to the client on both sides of the network connection, and the connected instance is equivalent to the server. Alternatively, any instance running in the server can also establish a network connection with it in response to the request of other instances, that is, other instances actively establish a network connection with any instance. At this time, any instance is equivalent to the client on both sides of the network connection, and the instance that actively establishes a network connection with it is equivalent to the server. It can be seen that any instance deployed in the server can be used as a server instance or a client instance during operation, and this specification does not limit this.

[0041] Normally, for a client instance, an available port can be bound to it by the server's operating system (such as a Linux system, etc.), so that the client instance can communicate with other instances through the port after the startup is completed. For a server instance, a port can be specified for it by the user who triggers the startup of the server, or a default port corresponding to the instance (such as a preconfigured fixed port, etc.) can be determined, and the port can be bound to the server instance, so that the server instance can communicate with other instances through the port after the startup is completed. Among them, the port to which any instance described in this specification is bound can include an IP address and a port (Port). For the instance startup method described in this specification, a first server instance and at least one other instance are deployed in the server, wherein the instance can be any server instance deployed in the server, and the other instance is an instance deployed in the server except the first server instance, and the other instance can include other server instances and / or other client instances.

[0042] The server connected to the blockchain network can be used to implement blockchain functions. In order to better adapt to the distributed scenarios of the blockchain network and improve the implementation effect and efficiency of blockchain functions, the server can split the blockchain functions implemented by itself into multiple independent or related microservices (Microservice) and deploy them locally in the form of instances. In other words, the first server instance and other instances deployed in the server described in this specification can be microservices provided by the server respectively, that is, any instance deployed in the server can be a microservice instance corresponding to the corresponding blockchain function.

[0043] The port reuse function described in this specification can be provided by the server's operating system. For example, when the server's operating system is a Linux system, the port reuse function can be provided by the SO_REUSEPORT option, that is, turning on the SO_REUSEPORT option of any instance will turn on the port reuse function for that instance. For another example, when the server's operating system is a Windows system, the Net.tcp PortSharing service in HTTP.sys can be used to cooperate with WinRM to implement the port reuse function. The specific process can be found in the records in the relevant technology, which will not be repeated here.

[0044] In addition, the port multiplexing function described in this specification has the following characteristics: different instances (or different processes, etc.) bound to the same port need to enable the port multiplexing function separately, according to the order of the startup time of each instance. If the first instance bound to any port does not enable the port multiplexing function, then other subsequent instances will not be able to bind to the port and start smoothly; if the first instance bound to any port enables the port multiplexing function, then other subsequent instances bound to the port will not be able to start smoothly if their own port multiplexing function is not enabled, and they need to enable their own port multiplexing function in order to start smoothly.

[0045] When the first server instance has not yet started, the server may receive a startup instruction initiated by a user for the instance, or generate a startup instruction for the instance according to a preset startup plan. At this time, in response to the above startup instruction for the first server instance, the server can read the mode configuration information of the first service instance. Among them, the mode configuration information can be used to indicate the working mode of the instance, for example, indicating whether it is in single-threaded mode or multi-threaded mode, or indicating whether it is in single-process mode or multi-process mode, etc. Exemplarily, when the mode configuration information indicates that the first server instance is in accept or epoll mode, it indicates that the instance is in multi-threaded or multi-process mode.

[0046] When the first server instance is in multi-thread mode or multi-process mode, it means that the instance will inevitably turn on the port reuse function during the subsequent startup process, that is, turning on the port reuse function is originally a fixed setting when the first server instance is started in multi-process mode or multi-thread mode. At this time, it is naturally not necessary for the server to turn on the port reuse function specifically for the first server instance during this startup. For example, this function can be used to solve the possible herd shock problem in the accept / epoll mode. In other words, if the mode configuration information indicates that the first server instance is not in multi-thread mode or multi-process mode, it indicates that there is no need to turn on the port reuse function of the first server instance.

[0047] Therefore, when the mode configuration information of the first server instance indicates that the port multiplexing function of the first server instance needs to be enabled (such as the information indicates that the first server instance is in multi-threaded mode or multi-process mode), the server can enable the port multiplexing function of the first server instance and attempt to start the first server instance after the enabling is completed.

[0048] Step 104: if the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled, determine whether the target port bound to the first server instance is occupied by other instances that have been started.

[0049] Before the first server instance is started, other instances in the server may have been started, so the target port bound to the first server instance may be occupied by other instances that have been started. If the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled (i.e., if the first server instance is started according to normal steps, its port reuse function will not be enabled), the server needs to determine whether the target port bound to the first server instance is occupied by other instances that have been started.

[0050] As mentioned above, any instance deployed in the server may be a server instance or a client instance. Since the server instance and the client instance bind ports in different ways, the server can use different methods to check whether the single target port is occupied by other instances that have been started.

[0051] For example, in the case where other instances that have been started include a second server instance, the server can determine whether the target port is monitored by the second server instance: if the target port is monitored by the second server instance, it can be determined that the port is occupied by the second server instance; conversely, if the target port is not monitored by the second server instance, it can be determined that the port is not occupied by the second server instance. The second server instance can be any server instance deployed in the server except the first server instance. In other words, if there is at least one server instance that has been started and listens to the target port in the server, it can be determined that the port is occupied by the server instance; if there is no server instance that has been started and listens to the target port in the server, it can be determined that the port is not occupied by the server instance. For another example, in the case where other instances that have been started include any client instance, the server can determine whether the port bound to any client is the same as the target port: if they are the same, it can be determined that the target port is occupied by any client instance; if they are different, it can be determined that the target port is not occupied by any client embodiment. In the case where multiple client instances are deployed in the server, if at least one client instance is bound to the target port, it can be determined that the port is occupied by the client instance; if no client instance is bound to the target port, it can be determined that the port is not occupied by the client instance. In the above manner, it can be accurately determined whether the target port is occupied by other instances.

[0052] Among them, the server can record the ports bound to each instance that has been started locally, based on which the port monitored by the second server instance can be determined (the port bound to any server instance will be monitored by the instance), or the port bound to any client instance can be determined. It should also be noted that if there is at least one server instance that has been started to listen to the target port or there is at least one client instance that has been started to bind to the target port, it can be determined that the target port is occupied by other instances that have been started; if there is no server instance that listens to the target port or there is no client instance that has been started to bind to the target port, it can be determined that the target port is not occupied by other instances that have been started.

[0053] In one embodiment, for any client instance started before the first server instance, the server can enable the corresponding port reuse function for it before starting the instance. For example, the server can enable the port reuse function of any other instance, and start the other instance after enabling. In this way, it can be ensured that the client instance bound to the target port has enabled the port reuse function, thereby ensuring that after the instance is started, the first server instance can also enable the port reuse function and be successfully started after enabling.

[0054] Step 106: If the target port is occupied by other instances that have been started, and the other instances that occupy the target port have enabled port reuse, enable the port reuse function of the first server instance, and try to start the first server instance after enabling.

[0055] When it is determined that the target port is occupied, the server may further determine whether the (at least one) other instance occupying the port has enabled the port reuse function respectively. And, when it is determined that the other instance occupying the target port has enabled the port reuse function, enable the port reuse function of the first server instance, and try to start the first server instance after enabling.

[0056] Through the aforementioned embodiments, the server can read the mode configuration information of the first service instance in response to the startup instruction for the first server instance; and then, when the mode configuration information does not indicate that the port multiplexing function of the first server instance needs to be enabled, it is determined whether the target port bound to the first server instance is occupied by other instances that have been successfully started; then, if the target port is occupied by other instances that have been successfully started, and the other instances occupying the target port have enabled the port multiplexing function, the server can enable the port multiplexing function of the first server instance, and attempt to start the first server instance after the enabling is completed.

[0057] Each instance described in this solution has a port reuse function, that is, when this function is turned on, multiple instances can share the same port provided by the server. Based on this, this solution enables the port reuse function for the first server instance when the target port is occupied by other instances and the other instances have enabled the port reuse function, so that the first server instance can reuse the port with other instances that occupy the target port and also enable the port reuse function. For the first server instance, it can monitor the target port normally, so that it can be started smoothly. Obviously, when the target port bound to the first server instance is occupied by other instances, the first server instance can be started smoothly by turning on the port reuse function, which effectively solves the problem that the server instance started later cannot be started because the instance started first occupies the port.

[0058] In one embodiment, the operating system of the server may be a Linux system, which may provide a SO_REUSEPORT option for each instance in the server. Based on this, the server may enable the port reuse function of the instance by configuring the SO_REUSEPORT option provided by the system for the first server instance. Specifically, the server may add the following SO_REUSEPORT option configuration setsockopt code before the bind() statement for binding the target port during the socket configuration (socket option) of the first server instance:

[0059] setsockopt(fd,SOL_SOCKET,SO_REUSEPORT,…);

[0060] The corresponding processing step of this line of code in the Linux system kernel is to set the sk_reuseport field of the socket of the first server instance to a corresponding preset value, such as 1. After this line of code is executed, the value of the sk_reuseport field is set to 1, thereby enabling the SO_REUSEPORT option of the first server instance.

[0061] In another embodiment, in order to improve the security of port reuse, the server may also determine whether the user identifier of the first server instance is the same as the user identifier of other instances occupying the target port, and if the user identifier of the first server instance is the same as the user identifier of each other instance occupying the target port, the port reuse function of the first server instance is enabled. Among them, the user identifier of any instance can be used to characterize the identity of the user who triggers the startup of the instance. In this way, it can be ensured that the port reuse function of the first server instance is enabled only when each instance of the reused target port is triggered and started by the same user, and then the startup of the instance is completed. It can be understood that after the first server instance is started in this way, each instance of the reused target port (including the first server instance and at least one other port) corresponds to the same user, which effectively avoids the problem of cross-user data theft that may be caused by instances of different users reusing the same port, that is, port hijacking is avoided, and data security in the port reuse process is improved.

[0062] In one embodiment, when the target port is occupied by other instances that have been started, at least one other instance occupying the target port may not have the port reuse function enabled. It can be seen from the aforementioned characteristics of the port reuse function that even if the port reuse function of the first server instance is enabled at this time, the instance cannot be successfully started. Therefore, in order to avoid the abuse of the port reuse function and the invalid activation of the first server instance, the server can avoid enabling the port reuse function of the first server instance and avoid starting the first server instance. In other words, the server can directly terminate the startup instruction response process for the first server instance at this time. In addition, a corresponding reminder message or log record can be generated for the aforementioned termination reason, so that the user who initiated the startup instruction can know the reason for the failure to start the first server instance, and realize a clearer user interaction logic.

[0063] In one embodiment, the target port may not be occupied by other instances that have been started. In this case, it is possible to avoid turning on the port reuse function of the first server instance and trying to start the first server instance. In this way, the abuse of the port reuse function can be avoided: if other instances are subsequently bound to the target port and the port reuse function is turned on, they will not be able to start smoothly, so it is possible to avoid reusing the target port with the first server instance, thereby avoiding possible connection errors or message confusion.

[0064] It can be seen from the above embodiments that before receiving the startup instruction for the first server instance, the server may have already moved other instances bound to the target port, and the other instances may be server instances and / or client instances. Among them, in the case where any other instance is a server instance, the port reuse function activation and instance startup process of the instance are similar to those of the first server instance, and will not be repeated. In the case where any other instance is a client instance, the port reuse function activation and instance startup process of the instance are different from those of the first server instance. Figure 2 , taking the SO_REUSEPORT option as an example, the startup process of any client instance client bound to the target port and the startup process of the first server instance server started after the client are explained.

[0065] like Figure 2 As shown in a, the process of the server starting any client instance client includes the following steps 201c to 203c:

[0066] Step 201c, receiving a startup instruction for the client.

[0067] Step 202c, enable the SO_REUSEPORT option of the client.

[0068] In one embodiment, in response to a startup instruction for a client, the server can directly enable the SO_REUSEPORT option of the client. Then determine all idle ports and all reusable ports at the current moment. Among them, the idle ports are ports that have not been bound to any instance - such ports can be directly bound to the client; the reusable ports are ports bound to instances in the server that have enabled the SO_REUSEPORT option and have completed startup - such ports can be bound to the client after enabling the SO_REUSEPORT option of the client. Furthermore, a section of ports can be selected from all the idle ports and all the reusable ports as ports to be bound. Among them, the ports can be randomly selected, or the ports with the least number of historical uses can be determined as ports to be bound, or the ports with the longest idle time before the current moment can be determined as ports to be bound, etc. This specification does not limit this.

[0069] In another embodiment, in response to the startup instruction for the client, the server can enable the SO_REUSEPORT option of the client, and then determine all reusable ports at the current moment, and select a port as the port to be bound. The server can also select the port to be bound randomly or according to a preset rule, which will not be repeated.

[0070] The server may enable the SO_REUSEPORT option by setting the setsockopt code before the bind() statement of the client. Please refer to the description of the aforementioned embodiment, which will not be repeated here.

[0071] In addition, in response to the startup instruction for the client, the server can also determine all idle ports at the current moment and select a port from them as the port to be bound - at this time, the server may not start the client, and this situation will not be discussed further.

[0072] Step 203c, bind the port to be bound for the client and try to start the client.

[0073] After turning on the SO_REUSEPORT option of the client and determining the port to be bound, the server can bind the port to the client and try to start the client. Specifically, the server can bind the port to be bound by executing a bind() statement, and start the instance by executing the startup code corresponding to the client. The specific process is not repeated here.

[0074] It is understandable that, after the SO_REUSEPORT option of the client is enabled, the instance is started, and no matter the bound port to be bound is an idle port or a reusable port, the client can be successfully started.

[0075] It should be noted that Figure 2 In the figure, a and b correspond to the startup process of the client instance client and the startup process of the first server instance server, respectively, and correspond to each other, but the process described in a occurs before the process described in b. Figure 2 As shown in b, after the client is started, the process of the server starting the first server instance server includes the following steps 201s to 205s:

[0076] Step 201s, receiving a startup instruction for the server.

[0077] Step 202s, determining whether the server is in multi-thread mode or multi-process mode.

[0078] In response to the startup instruction for the server, the server can obtain the mode configuration information of the server and determine whether the server is in multi-thread mode or multi-process mode through the information. For example, if the mode configuration information indicates that the server is in accept / epoll mode, it can be determined that the server is in multi-thread mode or multi-process mode; conversely, if the mode configuration information indicates that the server is not in accept / epoll mode, it can be determined that the server is in single-thread mode or single-process mode.

[0079] According to the judgment result, if it is determined that the server is in multi-thread mode or multi-process mode, the process may proceed to step 204s; otherwise, if it is determined that the server is not in multi-thread mode or multi-process mode, the process may proceed to step 203s.

[0080] Step 203s, determine whether the target port is occupied by other instances.

[0081] At this point, the server can further determine whether the target port is occupied by the client or other servers. First, the server can determine the designated target port according to the user's port designation information, or determine the pre-configured target port according to the preset port configuration information. Then, it can search among the instances that have been started to see if there is already an instance bound to the target port, such as finding out whether the server instance is listening to the target port, or whether there is a port bound to the client at all times that is the same as the target port. Among them, the server can record the ports bound to each instance that has been started, so that the above search can be completed in the record.

[0082] In addition, the server may further determine whether the instance occupying the target port has enabled the SO_REUSEPORT option. Accordingly, if the target port is occupied by at least one client instance and / or at least one other server instance, and the instance occupying the target port has enabled the SO_REUSEPORT option, the process may proceed to step 204s; if the target port is not occupied by any instance, the process may proceed to step 205s.

[0083] Step 204s, enable the SO_REUSEPORT option of the server.

[0084] If the process proceeds from step 202s to step 204s, it means that in multi-threaded mode or multi-process mode, the server needs to start up after opening the SO_REUSEPORT option in order to solve the thundering problem that may occur in the above mode. If the process proceeds from step 203s to step 204s, it means that although the working mode of the server does not require opening the SO_REUSEPORT option of the instance, the target port set for it is occupied, and the SO_REUSEPORT option needs to be opened for it at this time, so that the server can start up smoothly when the target port is occupied, and after the startup is completed, the port can be reused (or shared) with other instances.

[0085] Step 205s, bind the target port for the server and try to start the server.

[0086] After turning on the SO_REUSEPORT option of the server, you can bind the target port to it and try to start the instance. Specifically, you can turn on the SO_REUSEPORT option and start the server by executing the following code:

[0087] #include<sys / socket.h>

[0088] setsockopt(fd,SOL_SOCKET,SO_REUSEPORT,...); / / Turn on the SO_REUSEPORT option

[0089] int bind(int sockfd,const struct sockaddr*myaddr,socklen_taddrlen); / / Bind target port

[0090] int listen(int sockfd,int backlog); / / Listen to the target port

[0091] int accept(int sockfd,struct sockaddr*cliaddr,socklen_t*addrlen); / / Receive the connection of the client instance

[0092] In the above method, you can enable the SO_REUSEPORT option for the client, bind a port to it, and then start the instance. After that, if the target port of the server is occupied by other instances and the other instances have the SO_REUSEPORT option enabled, you can enable the SO_REUSEPORT option for the server, bind the target port to it, and successfully start the instance, which effectively solves the problem that the instance started first occupies the target port and causes the server started later to fail to start. After the server is successfully started, the instance will share (i.e. reuse) the port with other instances occupying the target port.

[0093] Multiple instances that have been started can reuse the same port. In order to ensure that each instance can run normally and realize the corresponding blockchain service, the server can accurately forward the message received through the reused port. In this regard, this specification also proposes a message forwarding method. The message forwarding scheme is described in detail below with reference to the accompanying drawings.

[0094] See also Figure 1 , Figure 1 1 is a flowchart of a message forwarding method provided by an exemplary embodiment. The method is applied to a server, the server is connected to a blockchain network, and multiple instances are running in the server, and the instances are used to provide blockchain services related to the blockchain network. Figure 3 As shown, the method includes steps 302-304.

[0095] Step 302: In response to receiving a message to be forwarded, reading a destination port of the message to be forwarded.

[0096] Similar to the aforementioned instance startup solution, after multiple instances in the server are started separately, these instances will be running in the server.

[0097] In one embodiment, the multiple instances running in the server may include at least one server instance and / or at least one client instance. The port bound to any server instance may be specified for the instance by the user who triggers the start of the instance, or may be determined according to a pre-configuration file of the instance. The port bound to any client instance may be randomly assigned to the instance by the server, and as mentioned above, the port of any client instance assigned may be an idle port or a reusable port.

[0098] Among them, the above multiple instances can have the same user ID, and the user ID of any instance is used to represent the identity of the user who triggers the start of the instance. It can be seen that multiple instances running in the server that reuse the same port can be triggered by the same user. At this time, the above multiple instances are all used by the user, which effectively avoids the problem of cross-user data theft that may be caused by different users' instances reusing the same port, that is, avoiding port hijacking and improving data security during port reuse.

[0099] When receiving a message to be forwarded, the server can read the destination port of the message. The destination port can be recorded in the packet header of the message to be forwarded. For example, when the message to be forwarded is a handshake message for establishing a TCP (Transmission Control Protocol) connection, the destination port is the value of the 3rd to 4th bytes in the handshake message header. Alternatively, when the message to be forwarded is a UDP (User Datagram Protocol) message, the destination port is the value of the 3rd to 4th bytes in the UDP message header, etc., which will not be repeated.

[0100] In one embodiment, after determining the destination port, if the destination port is not a reused port (i.e., the destination port is bound to only one instance), the server can directly forward the message to the instance bound to the destination port, such as a server instance listening to the port. If the destination port is a reused port (i.e., the destination port is bound to multiple instances), the server can determine the destination instance corresponding to the message to be forwarded, i.e., the expected recipient of the message, from the multiple instances that reuse the destination port.

[0101] Step 304, when the multiple instances are respectively bound to the destination ports and the port multiplexing function is enabled for the multiple instances respectively, the destination instance corresponding to the message to be forwarded is determined from the multiple instances according to the address information carried by the message to be forwarded, and the message to be forwarded is forwarded to the destination instance.

[0102] In one embodiment, the server can determine the target instance corresponding to the message to be forwarded based on the address information of the message to be forwarded. For example, the server can extract the address information from the header of the message to be forwarded, and the address information can include the destination IP address and destination port of the message to be forwarded. Furthermore, based on the destination IP address and the destination port, as well as the IP address and port of each instance, the matching score of each instance for the message to be forwarded can be calculated respectively, and the instance with the largest matching score is determined as the destination instance corresponding to the message to be forwarded. Among them, the matching score of any instance for the message to be forwarded is used to characterize the probability that any instance is the expected recipient of the message to be forwarded. The instance with the largest matching score is more likely to be the expected recipient of the message to be forwarded. Therefore, it is determined as the destination message corresponding to the message, which helps to improve the accuracy of determining the destination instance and minimize possible connection errors and message confusion.

[0103] In addition, if the matching scores of multiple instances and the message to be forwarded are equal and the maximum, then an instance can be randomly selected from the instances corresponding to the maximum matching score as the destination instance. At this time, the server operating system can implement load balancing of the message in the kernel.

[0104] Through the above embodiments, when multiple instances bound to the same port respectively turn on their own port multiplexing functions, for the to-be-forwarded messages received by the port (i.e., messages with the destination port being the port), the server can determine the corresponding target instance from the multiple instances based on the address information carried by the message, and forward the message to the instance, thereby achieving accurate forwarding of the message, avoiding to a certain extent the message confusion that may occur in the port multiplexing scenario, thereby ensuring that the multiple instances that reuse the same port after startup can operate normally respectively.

[0105] Figure 4 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 4 At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a non-volatile memory 410, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0106] like Figure 5 As shown, Figure 5is a block diagram of an example startup device provided by this specification according to an exemplary embodiment. The device can be applied to Figure 4 The device is applied to a server, the server is connected to a blockchain network, a first server instance and at least one other instance are deployed in the server, and the instance is used to provide blockchain services related to the blockchain network. The device includes:

[0107] The information reading unit 501 is used to read the mode configuration information of the first service instance in response to the startup instruction for the first server instance;

[0108] An occupation determination unit 502 is used to determine whether a target port bound to the first server instance is occupied by another instance that has been started, if the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled;

[0109] The instance startup unit 503 is used to enable the port reuse function of the first server instance if the target port is occupied by other instances that have been started and the other instances occupying the target port have enabled the port reuse function, and try to start the first server instance after the enabling is completed.

[0110] Optionally, the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled, including:

[0111] If the mode configuration information indicates that the first server instance is not in the multi-thread mode or the multi-process mode, it indicates that there is no need to enable the port multiplexing function of the first server instance.

[0112] Optionally, the occupancy determination unit 502 is further configured to:

[0113] In the case that the other instances that have been started include the second server instance, if the target port is monitored by the second server instance, it is determined that the target port is occupied by the second server instance; and / or,

[0114] In the case that the other instances that have been started include any client instance, if the port bound to any client is the same as the target port, it is determined that the target port is occupied by any client instance.

[0115] Optionally, also include:

[0116] The other instance starting unit 504 is used to start the port multiplexing function of any other instance and start the any other instance after the start.

[0117] Optionally, the instance starting unit 503 is further used to:

[0118] If the user identifier of the first server instance is the same as the user identifier of the other instance occupying the target port, the port reuse function of the first server instance is enabled, wherein the user identifier of any instance is used to represent the identity of the user who triggers the startup of the instance.

[0119] Optionally, also include:

[0120] The first avoidance unit 505 is used to avoid enabling the port reuse function of the first server instance and avoid starting the first server instance if the target port is occupied by other instances that have been started and at least one other instance occupying the target port has not enabled the port reuse function.

[0121] Optionally, also include:

[0122] The second avoiding unit 506 is configured to avoid enabling the port reuse function of the first server instance and attempt to start the first server instance if the target port is not occupied by other instances that have been started.

[0123] Optionally, also include:

[0124] The function enabling unit 507 is used to enable the port reuse function of the first server instance when the mode configuration information indicates that the port reuse function of the first server instance needs to be enabled, and try to start the first server instance after enabling.

[0125] Optionally, the first server instance and the other instances are microservice instances provided by the servers respectively.

[0126] Optionally, the operating system of the server is a Linux system, and the instance starting unit 503 is further used to:

[0127] By configuring the SO_REUSEPORT option provided by the Linux system for any of the instances, the port reuse function of any of the instances is enabled.

[0128] like Figure 6 As shown, Figure 6 is a block diagram of a message forwarding device provided by this specification according to an exemplary embodiment. The device can be applied to Figure 4 The device is applied to a server, the server is connected to a blockchain network, and multiple instances are running in the server, the instances are used to provide blockchain services related to the blockchain network, and the device includes:

[0129] The port reading unit 601 is used for reading the destination port of the message to be forwarded in response to receiving the message to be forwarded;

[0130] The message forwarding unit 602 is used to determine the destination instance corresponding to the message to be forwarded from the multiple instances according to the address information carried by the message to be forwarded, and forward the message to be forwarded to the destination instance when the multiple instances are respectively bound to the destination ports and the port multiplexing function is enabled for the multiple instances respectively.

[0131] Optionally, the multiple instances include a server instance and / or a client instance, wherein:

[0132] The port bound to any server instance is specified by the user who triggers the instance to start, or is determined based on the pre-configuration file of the instance;

[0133] The port bound to any client instance is randomly assigned to the instance by the server.

[0134] Optionally, the message forwarding unit 602 is further configured to:

[0135] Extracting address information from the header of the message to be forwarded, the address information including the destination IP address and destination port of the message to be forwarded;

[0136] Based on the destination IP address and the destination port, as well as the IP address and port of each instance, the matching score of each instance for the message to be forwarded is calculated respectively, and the instance with the largest matching score is determined as the destination instance corresponding to the message to be forwarded, wherein the matching score of any instance for the message to be forwarded is used to characterize the probability that any instance is the expected recipient of the message to be forwarded.

[0137] Optionally, the multiple instances have the same user identifier, and the user identifier of any instance is used to represent the identity of a user who triggers the startup of the instance.

[0138] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0139] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0140] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, the present invention does not exclude that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0141] Although one or more embodiments of the present specification provide method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.

[0142] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing one or more of the present specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0143] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0144] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0146] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0147] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0148] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0149] It should be understood by those skilled in the art that one or more embodiments of the present specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of the present specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0150] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0151] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In the description of this specification, the description of the reference 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 this specification. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.

[0152] The above description is only an example of one or more embodiments of this specification and is not intended to limit one or more embodiments of this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the scope of the claims.

Claims

1. A message forwarding method, applied to a server, the server is connected to a blockchain network, and a plurality of instances are running in the server, the instances are used to provide blockchain services related to the blockchain network, the method comprising: In response to receiving a message to be forwarded, reading a destination port of the message to be forwarded; When the multiple instances are respectively bound to the destination ports and the port multiplexing function is enabled for the multiple instances respectively, the destination instance corresponding to the message to be forwarded is determined from the multiple instances according to the address information carried by the message to be forwarded, and the message to be forwarded is forwarded to the destination instance.

2. The method according to claim 1, wherein the multiple instances include server instances and / or client instances, wherein: The port bound to any server instance is specified by the user who triggers the instance to start, or is determined based on the pre-configuration file of the instance; The port bound to any client instance is randomly assigned to the instance by the server.

3. The method according to claim 1, wherein determining the destination instance corresponding to the message to be forwarded from the multiple instances according to the address information carried by the message to be forwarded comprises: Extracting address information from the header of the message to be forwarded, the address information including the destination IP address and destination port of the message to be forwarded; Based on the destination IP address and the destination port, as well as the IP address and port of each instance, the matching score of each instance for the message to be forwarded is calculated respectively, and the instance with the largest matching score is determined as the destination instance corresponding to the message to be forwarded, wherein the matching score of any instance for the message to be forwarded is used to characterize the probability that any instance is the expected recipient of the message to be forwarded. 4 . The method according to claim 1 , wherein the multiple instances have the same user identifier, and the user identifier of any instance is used to represent the identity of the user who triggers the startup of the instance.

5. An instance startup method, applied to a server, the server is connected to a blockchain network, the server is deployed with a first server instance and other instances, the instance is used to provide blockchain services related to the blockchain network, the method comprising: In response to a start instruction for the first server instance, reading mode configuration information of the first service instance; If the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled, determining whether the target port bound to the first server instance is occupied by other instances that have been started; If the target port is occupied by other instances that have been started, and the port reuse function has been enabled for the other instances that occupy the target port, the port reuse function of the first server instance is enabled, and after the enabling is completed, the first server instance is attempted to be started.

6. The method according to claim 5, wherein the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled, comprising: If the mode configuration information indicates that the first server instance is not in the multi-thread mode or the multi-process mode, it indicates that there is no need to enable the port multiplexing function of the first server instance.

7. The method according to claim 5, determining that the target port is occupied by other instances that have been started, comprises: In the case that the other instances that have been started include the second server instance, if the target port is monitored by the second server instance, it is determined that the target port is occupied by the second server instance; and / or, In the case that the other instances that have been started include any client instance, if the port bound to any client is the same as the target port, it is determined that the target port is occupied by any client instance.

8. The method according to claim 5, starting any other instance occupying the target port, comprising: Enable the port multiplexing function of any other instance, and start any other instance after enabling.

9. According to the method of claim 5, the step of enabling the port reuse function of the first server instance comprises: If the user identifier of the first server instance is the same as the user identifier of the other instance occupying the target port, the port reuse function of the first server instance is enabled, wherein the user identifier of any instance is used to represent the identity of the user who triggers the startup of the instance.

10. The method according to claim 5, further comprising: If the target port is occupied by other instances that have been started, and at least one other instance occupying the target port does not have a port reuse function enabled, avoid enabling the port reuse function of the first server instance and avoid starting the first server instance.

11. The method according to claim 5, further comprising: If the target port is not occupied by other instances that have been started, avoid enabling the port reuse function of the first server instance and try to start the first server instance.

12. The method according to claim 5, further comprising: In the case where the mode configuration information indicates that the port reuse function of the first server instance needs to be enabled, the port reuse function of the first server instance is enabled, and after the enabling is completed, an attempt is made to start the first server instance.

13. According to the method of claim 5, the first server instance and the other instances are microservice instances provided by the server respectively.

14. The method according to claim 5, wherein the operating system of the server is a Linux system, and enabling the port multiplexing function of any instance comprises: By configuring the SO_REUSEPORT option provided by the Linux system for any of the instances, the port reuse function of any of the instances is enabled.

15. A message forwarding device, applied to a server, the server is connected to a blockchain network, and a plurality of instances are running in the server, the instances are used to provide blockchain services related to the blockchain network, the device comprising: A port reading unit, configured to read a destination port of the message to be forwarded in response to receiving the message to be forwarded; A message forwarding unit is used to determine the destination instance corresponding to the message to be forwarded from the multiple instances according to the address information carried by the message to be forwarded, and forward the message to be forwarded to the destination instance when the multiple instances are respectively bound to the destination ports and the port multiplexing function is enabled for the multiple instances respectively.

16. An instance startup device, applied to a server, the server is connected to a blockchain network, a first server instance and at least one other instance are deployed in the server, the instance is used to provide blockchain services related to the blockchain network, the device comprising: An information reading unit, configured to read mode configuration information of the first service instance in response to a startup instruction for the first server instance; an occupation judgment unit, configured to judge whether a target port bound to the first server instance is occupied by another instance that has been started, if the mode configuration information does not indicate that the port reuse function of the first server instance needs to be enabled; The instance startup unit is used to enable the port reuse function of the first server instance if the target port is occupied by other instances that have been started and the other instances occupying the target port have enabled the port reuse function, and try to start the first server instance after the enabling is completed.

17. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the message forwarding method according to any one of claims 1 to 4 or the instance startup method according to any one of claims 5 to 14 by running the executable instructions.

18. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the message forwarding method according to any one of claims 1 to 4 or the steps of the instance starting method according to any one of claims 5 to 14.

Citation Information

Patent Citations

  • Example control method and device, equipment, storage medium and program product

    CN112506583A

  • Micro-service instance exit method and device, equipment and storage medium

    CN112799786A

  • Systems and methods for efficiently managing and configuring virtual servers

    US20090241030A1

  • A system and method of demultiplexing provider backbone bridging traffic engineering instances

    WO2009106943A1