CN111431817B - Connection pool, construction method thereof and computer readable storage medium - Google Patents

Connection pool, construction method thereof and computer readable storage medium Download PDF

Info

Publication number
CN111431817B
CN111431817B CN201911371098.0A CN201911371098A CN111431817B CN 111431817 B CN111431817 B CN 111431817B CN 201911371098 A CN201911371098 A CN 201911371098A CN 111431817 B CN111431817 B CN 111431817B
Authority
CN
China
Prior art keywords
connection
priority weight
current
priority
connections
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911371098.0A
Other languages
Chinese (zh)
Other versions
CN111431817A (en
Inventor
孙大江
刘永振
张波
査骏
牛天耘
冀乃庚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Unionpay Co Ltd
Original Assignee
China Unionpay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Unionpay Co Ltd filed Critical China Unionpay Co Ltd
Priority to CN201911371098.0A priority Critical patent/CN111431817B/en
Publication of CN111431817A publication Critical patent/CN111431817A/en
Application granted granted Critical
Publication of CN111431817B publication Critical patent/CN111431817B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present invention relates to a connection pool, a construction method thereof, and a computer-readable storage medium, the method comprising: determining a priority weight for each of a plurality of historical connections in the connection pool, the priority weights reflecting network status of the corresponding historical connections; and arranging the historical connections according to the priority weights to form the connection pool comprising a plurality of current connections, so that the arranged current connections are called according to the priority weight of each current connection in the connection pool by the outside.

Description

Connection pool, construction method thereof and computer readable storage medium
Technical Field
The present invention relates to a connection pool, a method of constructing the same, and a computer-readable storage medium, and more particularly, to a management mechanism of a connection pool for communication connection.
Background
In network applications, the connection pool is responsible for allocating, managing and releasing client-to-server long connections, which allows applications to multiplex existing connections without having to re-establish each time a request is sent. The management of the connection pool determines to a large extent the performance advantages of the network application.
Disclosure of Invention
In order to improve the efficiency of the connection pool, a management mechanism of the connection pool based on dynamic ordering is provided, and gray nodes are filtered and/or the polling frequency of the connection pool is reduced by introducing the dynamic ordering mechanism, so that the overall performance of the connection pool is improved, and specifically:
according to an aspect of the present invention, there is provided a construction method of a connection pool, including: determining a priority weight for each of a plurality of historical connections in the connection pool, the priority weights reflecting network status of the corresponding historical connections; and arranging the historical connections according to the priority weights to form the connection pool comprising a plurality of current connections, so that the arranged current connections are called according to the priority weight of each current connection in the connection pool by the outside.
In one embodiment of the invention, optionally, the priority weight of the history connection remains unchanged if it did not participate in the previous transmission.
In one embodiment of the invention, optionally, the priority weight of the historical connection is determined at least from: historical average priority weight, type of request of previous transmission, length of message of previous transmission, time consuming of previous transmission and number of in-transit messages.
In one embodiment of the present invention, optionally, the priority weight is positively correlated with the historical average priority weight and the message length of the previous transmission, and is negatively correlated with the time consumption of the previous transmission and the number of in-transit messages.
In one embodiment of the invention, the priority weight is optionally determined by:
wherein W represents the priority weight, w_av represents the historical average priority weight, req_type represents the request type of the previous transmission, req_len represents the message length of the previous transmission, cost represents the time consumption of the previous transmission, M represents the number of in-transit messages, and A, B represents a coefficient.
In one embodiment of the invention, optionally, the current connection is recalled and its historical average priority weight is redetermined by:
where W_av_new represents the redetermined historical average priority weight, N represents the number of accumulated invocations prior to the current invocation, W av The historical average priority weight representing the current connection and W representing the priority weight of the current connection.
In one embodiment of the present invention, the current connections in the connection pool are optionally arranged into a linked list according to respective priority weights, wherein the current connection with the higher priority weight is arranged before the current connection with the lower priority weight.
In one embodiment of the present invention, the current connections in the connection pool are optionally arranged into a maximum heap structure according to respective priority weights, wherein the priority weight of the current connection corresponding to a parent node of the maximum heap structure is greater than the priority weight of the current connection corresponding to a child node of the parent node.
According to another aspect of the present invention there is provided a computer readable storage medium having instructions stored therein, which when executed by a processor, cause the processor to perform any of the methods as described above.
According to another aspect of the present invention, there is provided a connection pool, characterized in that the connection pool includes: a plurality of current connections corresponding to a plurality of historical connections, the plurality of current connections being formed by arranging the plurality of historical connections according to priority weights of the plurality of historical connections for external retrieval of the arranged current connections according to the priority weights of each of the current connections; wherein each of the plurality of historical connections has the priority weight reflecting a network state of the corresponding historical connection.
In one embodiment of the invention, optionally, the priority weight of the history connection remains unchanged if it did not participate in the previous transmission.
In one embodiment of the invention, optionally, the priority weight of the historical connection is determined at least from: historical average priority weight, type of request of previous transmission, length of message of previous transmission, time consuming of previous transmission and number of in-transit messages.
In one embodiment of the present invention, optionally, the priority weight is positively correlated with the historical average priority weight and the message length of the previous transmission, and is negatively correlated with the time consumption of the previous transmission and the number of in-transit messages.
In one embodiment of the invention, the priority weight is optionally determined by:
wherein W represents the priority weight, w_av represents the historical average priority weight, req_type represents the request type of the previous transmission, req_len represents the message length of the previous transmission, cost represents the time consumption of the previous transmission, M represents the number of in-transit messages, and A, B represents a coefficient.
In one embodiment of the invention, optionally, the current connection is recalled and its historical average priority weight is redetermined by:
where W_av_new represents the redetermined historical average priority weight, N represents the number of accumulated invocations prior to the current invocation, W av The historical average priority weight representing the current connection and W representing the priority weight of the current connection.
In one embodiment of the present invention, the current connections in the connection pool are optionally arranged into a linked list according to respective priority weights, wherein the current connection with the higher priority weight is arranged before the current connection with the lower priority weight.
In one embodiment of the present invention, the current connections in the connection pool are optionally arranged into a maximum heap structure according to respective priority weights, wherein the priority weight of the current connection corresponding to a parent node of the maximum heap structure is greater than the priority weight of the current connection corresponding to a child node of the parent node.
Drawings
The above and other objects and advantages of the present invention will become more fully apparent from the following detailed description taken in conjunction with the accompanying drawings, in which identical or similar elements are designated by the same reference numerals.
Fig. 1 shows a connection pool according to the prior art.
FIG. 2 shows a schematic diagram of a connection pool according to one embodiment of the invention.
FIG. 3 shows a schematic diagram of a connection pool according to one embodiment of the invention.
FIG. 4 shows a schematic diagram of a connection pool according to one embodiment of the invention.
FIG. 5 shows a schematic diagram of a connection pool according to one embodiment of the invention.
FIG. 6 shows a schematic diagram of a connection pool according to one embodiment of the invention.
FIG. 7 shows a schematic diagram of a connection pool according to one embodiment of the invention.
Detailed Description
For the purposes of brevity and explanation, the principles of the present invention are described herein primarily with reference to exemplary embodiments thereof. However, those skilled in the art will readily recognize that the same principles are equally applicable to all types of connection pools and methods of construction thereof, as well as computer-readable storage media, and that these same or similar principles may be implemented therein, any such variations without departing from the true spirit and scope of the present patent application.
Fig. 1 shows a connection pool according to the prior art. According to the connection pool shown, first, the client initiates the connection pool on the left and establishes a long connection to the server on the right when it starts up. Next, when the client needs to send a request message to the server, it will traverse the connection pool, fetch the connection whose status is available (READY), and set this connection status to CONNECTED (CONNECTED). Finally, the client completes the communication flow with the server using the connection fetched in the previous step and resets the connection state to available (READY), and other requests can multiplex the connection. However, the connection pool needs to be traversed in searching for available clients from the connection pool, and if there are n connections, the operation complexity is O (n), which may take a lot of time. In addition, the connection pool has no ash list (a connection list which can record and display normal states but cannot run in practice) filtering function, so that the blocking probability is high. On the other hand, the selected connection cannot guarantee the best performance, and thus the connection pool performance is not fully exerted.
In one embodiment of the present invention, the construction method of the connection pool includes the following two steps. Fig. 2 shows a schematic diagram of a connection pool according to an embodiment of the invention, and a method of constructing the connection pool will be described below in connection with fig. 2. First, a priority weight for each of a plurality of historical connections is determined. As shown in fig. 2, at time t-1, the connection pool includes a plurality of unrearranged historical connections, and the priority weight may reflect the network status of the corresponding historical connection. For example, historical connections with better network conditions have higher priority weights. The so-called "history" connections in the present invention are "history" products for the connection pool that do not reflect the previous transmission situation, since these connections are not rearranged according to the previous transmission situation before the current moment. Determining the priority weight of each of the plurality of historical connections is to re-determine the priority weight of each taking into account the previous transmission.
Next, the plurality of historical connections are ranked according to the priority weights to form a connection pool comprising a plurality of current connections. As shown in fig. 2, since the priority value of the B connection in the history connection is reduced, the history connection needs to be rearranged, and the rearranged connection is shown on the right side of fig. 2, and in this case, the connection pool includes a plurality of current connections at the current time t. Those skilled in the art will appreciate that there are corresponding historical connections for a plurality of current connections in the connection pool, the current connections being merely rearrangements of the historical connections and not increasing or decreasing the number of historical connections. In addition, since the priority weights of the connections are considered when the order of the connections is arranged, that is, the network state of the connections is considered, the arranged current connection can be called according to the priority weight of each current connection in the connection pool. For example, the thick arrows on both sides in fig. 2 illustrate the action of retrieving the connection, with the top-down arrow showing the order of retrieval. It can be seen that the external device can realize that the arranged current connection is called according to the priority weight of the current connection, and the connection with higher priority weight is called preferentially. Compared with the prior art, the complexity of the calling can be reduced to O (1).
Fig. 2 shows a case where the priority value of the history connection is lowered due to poor network state thereof, and fig. 3 shows a case where the priority value of the history connection is raised. As shown in fig. 3, since the priority value of the D connection increases in the history connection, the history connection needs to be rearranged, and the rearranged connection is shown on the right side of fig. 3, and in this case, the connection pool includes a plurality of current connections at the current time t. As with the example shown in FIG. 2, there are corresponding historical connections for a plurality of current connections in the connection pool, the current connections being simply rearrangements of the historical connections and not increasing or decreasing the number of historical connections. Likewise, the thick arrows on both sides in fig. 3 illustrate the action of retrieving the connection, with the top-down arrow showing the order of retrieval. Therefore, the external device can still realize that the arranged current connection is called according to the priority weight of the current connection, and the connection with higher priority weight is called preferentially.
In one embodiment of the present invention, as shown in fig. 2 and 3, the priority weight of the history connection remains unchanged if it did not participate in the previous transmission. Connection B in fig. 2 has its priority weight changed due to participation in the previous transmission, connection D in fig. 3 has its priority weight changed due to participation in the previous transmission, and the remaining connections in fig. 2 and 3 have not participated in the previous transmission, so its priority weight remains unchanged. In some embodiments of the present invention, the network status of each connection is defaulted without great change, and the network status is reevaluated only after the network status is invoked, so that the computing resources can be greatly saved, the resource cost required by the queuing again is reduced, and the connection pool can be conveniently and rapidly formed without great change.
As shown in fig. 2 and 3, in one embodiment of the present invention, if the historical connection participates in the previous transmission (e.g., the B connection in fig. 2, the D connection in fig. 3), in order to reflect the network situation, the priority weight of the historical connection may be determined according to the historical average priority weight, the request type of the previous transmission, the message length of the previous transmission, the time consumption of the previous transmission, and the number of in-transit messages. The historical average priority weight refers to the average of the priority weights calculated each time before the previous transmission, and the detailed (re) calculation method will be described below. In general, the higher the historical average priority weight, the higher the reliability of the connection, and thus its (current) priority weight may be higher. The length of the message of the previous transmission is also an index reflecting the quality of the network involved, and normally, the longer the length of the message length of the successful transmission is, the better the quality of the network involved is, and thus the (current) priority weight may be higher. The type of request transmitted before also reflects the response of the involved connection to different types of requests, which can be adapted with different weights. For example, if the involved connection responds to a request that the network requires a higher quality, it may be reflected that the involved connection is of better quality and thus its (current) priority value may be higher.
The historical average priority weight discussed above, the length of the message previously transmitted, all affect the (current) priority weight from the front, and factors that affect the (current) priority weight from the back will be discussed below. The time consumption of the previous transmission is an index reflecting the quality of the connection involved, and if the time consumption is high, the network quality is poor, and if the time consumption is low, the network quality is good, so that the time consumption of the previous transmission can be considered in determining the (current) priority weight. In addition to this, messages sent via the connection concerned are not always available for timely collection, so that the number of messages received and the number of messages not received (or called the number of messages in transit) can also be taken into account when determining the (current) priority weight, for example the number of messages in transit can be taken into account when determining the (current) priority weight.
In one embodiment of the present invention, the priority weight is positively correlated with the historical average priority weight and the length of the previously transmitted message, and negatively correlated with the time consumption and number of in-transit messages of the previous transmission. In other words, the higher the historical average priority weight, the higher the priority weight, the longer the length of the message transmitted before, the lower the priority weight, the longer the time consumed before, and the lower the priority weight, the more messages in transit. The opposite is true. In one embodiment of the present invention, a historical average priority weight, a length of a message of a previous transmission, a time consumption of the previous transmission, and a number of in-transit messages to (current) priority weight mapping table may be established for each request type of the previous transmission.
Request type of previous transmission: transaction data
Although the historical average priority weights, (current) priority weights are shown above as being within the interval of [0,1], those skilled in the art will appreciate that the priority weights of the present invention may be of other types, and the present invention is not limited thereto. The mapping table can be set according to historical experience, and the table can be discussed and updated continuously in the actual use process, so that the relation between the request type of the previous transmission, the historical average priority weight, the message length of the previous transmission, the time consumption of the previous transmission, the number of in-transit messages and the (current) priority weight can be objectively reflected.
In one embodiment of the present invention, in order to reduce the size of the mapping table, a historical average priority value interval, a previous transmission message length interval, a previous transmission time-consuming interval, and a message number-in-transit interval-to- (current) priority value mapping table may be established for each request type transmitted previously. Compared with the numerical mapping relation, the embodiment maps the historical average priority weight, the message length of the previous transmission, the time consumption of the previous transmission and the number of the in-transit messages of one interval to the (current) priority weight, thereby greatly reducing the table look-up time and the storage cost.
In one embodiment of the present invention, the priority weight is positively correlated with the historical average priority weight and the message length of the previous transmission, and negatively correlated with the time consumption of the previous transmission and the number of in-transit messages, and the priority weight can be determined by the following formula:
where W represents a priority weight, w_av represents a historical average priority weight, req_type represents a request type of a previous transmission, req_len represents a message length of the previous transmission, cost represents a time consumption of the previous transmission, M represents a number of in-transit messages, and A, B represents a coefficient. A. The specific value of B can be examined and updated according to the actual use effect. Compared with the mapping table, the function mapping is more accurate, and can reflect the slight change of the network condition.
In one embodiment of the invention, the current connection is recalled and its historical average priority weight is redetermined by:
where W_av_new represents the redetermined historical average priority weight, N represents the cumulative number of invocations (the cumulative number of invocations before the current invocation, n+1 times if the current invocation is counted), W av The historical average priority weight representing the current connection and W represents the priority weight of the current connection. The re-determined historical average priority weights calculated in this manner may be stored for use in the next re-determination of priority weights When used, the redetermined historical average priority weight may be used directly as the historical average priority weight.
In one embodiment of the invention, the current connections in the connection pool are arranged into a linked list according to the respective priority weights, wherein the current connection with the higher priority weight is arranged before the current connection with the lower priority weight. FIG. 4 shows a schematic diagram of a connection pool according to one embodiment of the invention. As shown, connections A-E are arranged in a linked list structure according to the priority weights. Wherein each node stores a subscript (poll_index), a priority weight (W), a historical average priority weight (w_av), and a pointer (next) to the next node for each connection, each data type is shown, e.g., subscript is integer (int), priority weight is floating point type (float), and historical average priority weight is floating point type (float). As illustrated, the subscript (poll_index), priority weight (W), historical average priority weight (w_av) constitute V (a) in the storage structure of connection a, while the pointer (next) of the next node constitutes I (a) in the storage structure of connection a, which applies equally to other connections in the connection pool. Node bs may be found by I (a) in the storage structure of node a, where the priority weight (W) of node bs is smaller than (and in some cases may be equal to) the priority weight (W) of node a. Likewise, a C node may be found based on I (B) in the storage structure of the B node, and the priority weight (W) of the C node is less than (and in some cases may be equal to) the priority weight (W) … … of the B node, and so on.
Fig. 5 shows a schematic diagram of a connection pool in which node bs are rearranged due to their reduced priority weights, according to an embodiment of the invention. As shown, the priority weight of the node B is redefined in the a phase, and the previous connection pool relationship can be noted as:
A->B->C->D->E->……
specifically, I (a) in the storage structure of node a points to node B, I (B) in the storage structure of node B points to node C, I (C) in the storage structure of node C points to node D, and I (D) in the storage structure of node D points to node E … …. On the other hand, as an example, V (a) in the storage structure of the a node includes a priority weight of 0.98, V (B) in the storage structure of the B node includes a priority weight of 0.95, V (C) in the storage structure of the C node includes a priority weight of 0.91, V (D) in the storage structure of the D node includes a priority weight of 0.90, and V (E) in the storage structure of the E node includes a priority weight of 0.88 … ….
In phase a, the priority weight of the re-determined node B (or connection B) is 0.89, and thus it is necessary to reorder it. The original node B is first deleted from the linked list, and the process can be described as:
A->C->D->E->……
at this time, I (a) in the storage structure of the a node points to the C node, I (C) in the storage structure of the C node points to the D node, and I (D) in the storage structure of the D node points to the E node … …. And then comparing the re-determined priority weight of the original node B with the priority weights of other nodes in the connection pool, thereby determining the position where the original node B needs to be rearranged. Since the redetermined priority weight (0.89) of the original node B is between the priority weight (0.90) of the D node and the priority weight (0.88) of the E node, it is necessary to rearrange the original node B between the D node and the E node. Thus, in phase b shown in fig. 5, the index of D node to E node needs to be broken, and this process can be noted as:
A->C->D E->……
The deleted original node B is inserted between node D and node E in phase c, which process can be noted as:
A->C->D->B->E->……
at this time, I (a) in the storage structure of the a node points to the C node, I (C) in the storage structure of the C node points to the D node, I (D) in the storage structure of the D node points to the B node, and I (B) in the storage structure of the B node points to the E node, … ….
The whole process of node B rearrangement is finished, so that the arranged current connection can be called according to the priority weight of each current connection in the connection pool, and particularly, the current connection is called from connection A to connection A.
In one embodiment of the present invention, the current connections in the connection pool are arranged into a maximum heap structure according to respective priority weights, wherein the priority weight of the current connection corresponding to a parent node of the maximum heap structure is greater than the current connection corresponding to a child node of the parent node. FIG. 6 shows a schematic diagram of a connection pool according to one embodiment of the invention. As shown, connections a-E are arranged in a maximum heap structure with the node B being the left child of node a, the node B being the right child of node a, the node D being the left child of node B, and the node E being the right child of node B … …. In addition, each node stores a subscript, a priority weight, a historical average priority weight, and a pointer to a child node for each connection. As illustrated, the subscript, priority weight, historical average priority weight constitute V (a) in the storage structure of connection a, while the pointers of the child nodes constitute IL (a) and IR (a), respectively, in the storage structure of connection a, as well as for other connections in the connection pool. Node B can be found by IL (A) in the storage structure of node A, wherein the priority weight of node B is smaller than (and in some cases may be equal to) the priority weight of node A; in addition, the C node may be found based on IR (A) in the storage structure of the A node, and the priority weight of the C node is less than (and in some cases may be equal to) the priority weight … … of the A node, and so on.
Fig. 7 shows a schematic diagram of a connection pool in which node bs are rearranged due to their reduced priority weights, according to an embodiment of the invention. By way of example, V (A) in the storage structure of node A in FIG. 6 includes a priority weight of 0.98, V (B) in the storage structure of node B includes a priority weight of 0.95, V (C) in the storage structure of node C includes a priority weight of 0.91, V (D) in the storage structure of node D includes a priority weight of 0.90, and V (E) in the storage structure of node E includes a priority weight of 0.88 … …. If the priority weight of the redetermined node B (or connection B) is 0.89, the maximum heap structure of the connection pool may be updated as shown in fig. 7.
According to another aspect of the inventionIn one aspect, a computer readable storage medium is provided, having instructions stored therein, which when executed by a processor, cause the processor to perform any of the methods as above. Computer-readable media, as referred to herein, include any type of computer storage media which can be accessed by a general purpose or special purpose computer. For example, the computer-readable medium may include RAM, ROM, E 2 PROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other temporary or non-temporary medium that can be used to carry or store desired program code means in the form of instructions or data structures and that can be accessed by a general purpose or special purpose computer, or a general purpose or special purpose processor. As used herein, discs (disks) and disks include Compact Discs (CDs), laser discs, optical discs, digital Versatile Discs (DVDs), floppy disks, and blu-ray discs where disks usually reproduce data magnetically, while disks reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
According to another aspect of the invention, a connection pool is provided. Fig. 2 shows a schematic diagram of a connection pool according to an embodiment of the present invention, as shown in the drawing, the connection pool includes a plurality of current connections (connections a-E at right t) corresponding to a plurality of historical connections (connections a-E at left t-1), the plurality of current connections a-E at right t being formed by arranging a plurality of historical connections at left t-1 according to priority weights of the plurality of historical connections at left t-1. The multiple current connections A-E at the right side t time are used for the external calling of the arranged current connections according to the priority weight of each current connection. For example, the thick arrows on both sides in fig. 2 illustrate the action of retrieving the connection, with the top-down arrow showing the order of retrieval. It can be seen that the external device can realize that the arranged current connection is called according to the priority weight of the current connection, and the connection with higher priority weight is called preferentially. In addition, each of the plurality of historical connections has a priority weight that reflects a network state of the corresponding historical connection. For example, historical connections with better network conditions have higher priority weights. The so-called "history" connections in the present invention are "history" products for the connection pool that do not reflect the previous transmission situation, since these connections are not rearranged according to the previous transmission situation before the current moment. Determining the priority weight of each of the plurality of historical connections is to re-determine the priority weight of each taking into account the previous transmission. Fig. 2 shows a case where the priority weight of the history connection B decreases due to poor network status thereof, and fig. 3 shows a case where the priority weight of the history connection D increases.
As shown in fig. 2 and 3, in one embodiment of the present invention, the priority weight of a history connection in the connection pool remains unchanged if it did not participate in the previous transmission. Connection B in fig. 2 changes its priority weight due to participation in the previous transmission, connection D in fig. 3 also changes its priority weight due to participation in the previous transmission, and the remaining connections in the connection pool shown in fig. 2 and 3 do not participate in the previous transmission, so their priority weights remain unchanged. In some embodiments of the present invention, the network status of each connection is defaulted without great change, and the network status is reevaluated only after the network status is invoked, so that the computing resources can be greatly saved, the resource cost required by the queuing again is reduced, and the connection pool can be conveniently and rapidly formed without great change.
As shown in fig. 2 and 3, in one embodiment of the present invention, if the historical connection in the connection pool participates in the previous transmission (e.g., the B connection in fig. 2, the D connection in fig. 3), in order to reflect the network situation, the priority weight of the historical connection may be determined according to the historical average priority weight of the historical connection, the request type of the previous transmission, the message length of the previous transmission, the time consumption of the previous transmission, and the number of in-transit messages. The historical average priority weight refers to the average of the priority weights calculated each time before the previous transmission, and the detailed (re) calculation method will be described below. In general, the higher the historical average priority weight, the higher the reliability of the connection, and thus its (current) priority weight may be higher. The length of the message of the previous transmission is also an index reflecting the quality of the network involved, and normally, the longer the length of the message length of the successful transmission is, the better the quality of the network involved is, and thus the (current) priority weight may be higher. The type of request transmitted before also reflects the response of the involved connection to different types of requests, which can be adapted with different weights. For example, if the involved connection responds to a request that the network requires a higher quality, it may be reflected that the involved connection is of better quality and thus its (current) priority value may be higher.
The historical average priority weight discussed above, the length of the message previously transmitted, all affect the (current) priority weight from the front, and factors that affect the (current) priority weight from the back will be discussed below. The time consumption of the previous transmission is an index reflecting the quality of the connection involved, and if the time consumption is high, the network quality is poor, and if the time consumption is low, the network quality is good, so that the time consumption of the previous transmission can be considered in determining the (current) priority weight. In addition to this, messages sent via the connection concerned are not always available for timely collection, so that the number of messages received and the number of messages not received (or called the number of messages in transit) can also be taken into account when determining the (current) priority weight, for example the number of messages in transit can be taken into account when determining the (current) priority weight.
In one embodiment of the present invention, the priority weight is positively correlated with the historical average priority weight and the length of the previously transmitted message, and negatively correlated with the time consumption and number of in-transit messages of the previous transmission. In other words, the higher the historical average priority weight, the higher the priority weight, the longer the length of the message transmitted before, the lower the priority weight, the longer the time consumed before, and the lower the priority weight, the more messages in transit. The opposite is true. In one embodiment of the present invention, a historical average priority weight, a length of a message of a previous transmission, a time consumption of the previous transmission, and a number of in-transit messages to (current) priority weight mapping table may be established for each request type of the previous transmission.
Request type of previous transmission: transaction data
Although the historical average priority weights, (current) priority weights are shown above as being within the interval of [0,1], those skilled in the art will appreciate that the priority weights of the present invention may be of other types, and the present invention is not limited thereto. The mapping table can be set according to historical experience, and the table can be discussed and updated continuously in the actual use process, so that the relation between the request type of the previous transmission, the historical average priority weight, the message length of the previous transmission, the time consumption of the previous transmission, the number of in-transit messages and the (current) priority weight can be objectively reflected.
In one embodiment of the present invention, in order to reduce the size of the mapping table, a historical average priority value interval, a previous transmission message length interval, a previous transmission time-consuming interval, and a message number-in-transit interval-to- (current) priority value mapping table may be established for each request type transmitted previously. Compared with the numerical mapping relation, the embodiment maps the historical average priority weight, the message length of the previous transmission, the time consumption of the previous transmission and the number of the in-transit messages of one interval to the (current) priority weight, thereby greatly reducing the table look-up time and the storage cost.
In one embodiment of the present invention, the priority weight is positively correlated with the historical average priority weight and the message length of the previous transmission, and negatively correlated with the time consumption of the previous transmission and the number of in-transit messages, and the priority weight can be determined by the following formula:
where W represents a priority weight, w_av represents a historical average priority weight, req_type represents a request type of a previous transmission, req_len represents a message length of the previous transmission, cost represents a time consumption of the previous transmission, M represents a number of in-transit messages, and A, B represents a coefficient. A. The specific value of B can be examined and updated according to the actual use effect. Compared with the mapping table, the function mapping is more accurate, and can reflect the slight change of the network condition.
In one embodiment of the invention, the current connection is recalled and its historical average priority weight is redetermined by:
where W_av_new represents the redetermined historical average priority weight, N represents the cumulative number of invocations (the cumulative number of invocations before the current invocation, N+/times if the current invocation is counted), W av The historical average priority weight representing the current connection and W represents the priority weight of the current connection. The re-determined historical average priority weights calculated in this manner may be stored for use the next time the priority weights are re-determined, at which time the re-determined historical average priority weights may be used directly as the historical average priority weights.
In one embodiment of the invention, the current connections in the connection pool are arranged into a linked list according to the respective priority weights, wherein the current connection with the higher priority weight is arranged before the current connection with the lower priority weight. FIG. 4 shows a schematic diagram of a connection pool according to one embodiment of the invention. As shown, connections A-E are arranged in a linked list structure according to the priority weights. Wherein each node stores a subscript (poll_index), a priority weight (W), a historical average priority weight (w_av), and a pointer (next) to the next node for each connection, each data type is shown, e.g., subscript is integer (int), priority weight is floating point type (float), and historical average priority weight is floating point type (float). As illustrated, the subscript (poll_index), priority weight (W), historical average priority weight (w_av) constitute V (a) in the storage structure of connection a, while the pointer (next) of the next node constitutes I (a) in the storage structure of connection a, which applies equally to other connections in the connection pool. Node bs may be found by I (a) in the storage structure of node a, where the priority weight (W) of node bs is smaller than (and in some cases may be equal to) the priority weight (W) of node a. Likewise, a C node may be found based on I (B) in the storage structure of the B node, and the priority weight (W) of the C node is less than (and in some cases may be equal to) the priority weight (W) … … of the B node, and so on.
Fig. 5 shows a schematic diagram of a connection pool in which node bs are rearranged due to their reduced priority weights, according to an embodiment of the invention. As shown, the priority weight of the node B is redefined in the a phase, and the previous connection pool relationship can be noted as:
A->B->C->D->E->……
specifically, I (a) in the storage structure of node a points to node B, I (B) in the storage structure of node B points to node C, I (C) in the storage structure of node C points to node D, and I (D) in the storage structure of node D points to node E … …. On the other hand, as an example, V (a) in the storage structure of the a node includes a priority weight of 0.98, V (B) in the storage structure of the B node includes a priority weight of 0.95, V (C) in the storage structure of the C node includes a priority weight of 0.91, V (D) in the storage structure of the D node includes a priority weight of 0.90, and V (E) in the storage structure of the E node includes a priority weight of 0.88 … ….
In phase a, the priority weight of the re-determined node B (or connection B) is 0.89, and thus it is necessary to reorder it. The original node B is first deleted from the linked list, and the process can be described as:
A->C->D->E->……
at this time, I (a) in the storage structure of the a node points to the C node, I (C) in the storage structure of the C node points to the D node, and I (D) in the storage structure of the D node points to the E node … …. And then comparing the re-determined priority weight of the original node B with the priority weights of other nodes in the connection pool, thereby determining the position where the original node B needs to be rearranged. Since the redetermined priority weight (0.89) of the original node B is between the priority weight (0.90) of the D node and the priority weight (0.88) of the E node, it is necessary to rearrange the original node B between the D node and the E node. Thus, in phase b shown in fig. 5, the index of D node to E node needs to be broken, and this process can be noted as:
A->C->D E->……
The deleted original node B is inserted between node D and node E in phase c, which process can be noted as:
A->C->D->B->E->……
at this time, I (a) in the storage structure of the a node points to the C node, I (C) in the storage structure of the C node points to the D node, I (D) in the storage structure of the D node points to the B node, and I (B) in the storage structure of the B node points to the E node, … ….
The whole process of node B rearrangement is finished, so that the arranged current connection can be called according to the priority weight of each current connection in the connection pool, and particularly, the current connection is called from connection A to connection A.
In one embodiment of the present invention, the current connections in the connection pool are arranged into a maximum heap structure according to respective priority weights, wherein the priority weight of the current connection corresponding to a parent node of the maximum heap structure is greater than the current connection corresponding to a child node of the parent node. FIG. 6 shows a schematic diagram of a connection pool according to one embodiment of the invention. As shown, connections a-E are arranged in a maximum heap structure with the node B being the left child of node a, the node B being the right child of node a, the node D being the left child of node B, and the node E being the right child of node B … …. In addition, each node stores a subscript, a priority weight, a historical average priority weight, and a pointer to a child node for each connection. As illustrated, the subscript, priority weight, historical average priority weight constitute V (a) in the storage structure of connection a, while the pointers of the child nodes constitute IL (a) and IR (a), respectively, in the storage structure of connection a, as well as for other connections in the connection pool. Node B can be found by IL (A) in the storage structure of node A, wherein the priority weight of node B is smaller than (and in some cases may be equal to) the priority weight of node A; in addition, the C node may be found based on IR (A) in the storage structure of the A node, and the priority weight of the C node is less than (and in some cases may be equal to) the priority weight … … of the A node, and so on.
Fig. 7 shows a schematic diagram of a connection pool in which node bs are rearranged due to their reduced priority weights, according to an embodiment of the invention. By way of example, V (A) in the storage structure of node A in FIG. 6 includes a priority weight of 0.98, V (B) in the storage structure of node B includes a priority weight of 0.95, V (C) in the storage structure of node C includes a priority weight of 0.91, V (D) in the storage structure of node D includes a priority weight of 0.90, and V (E) in the storage structure of node E includes a priority weight of 0.88 … …. If the priority weight of the redetermined node B (or connection B) is 0.89, the maximum heap structure of the connection pool may be updated as shown in fig. 7.
In summary, the management mechanism of the connection pool based on dynamic ordering provided herein filters gray nodes and/or reduces the polling times of the connection pool by introducing the dynamic ordering mechanism, thereby improving the overall performance of the connection pool. It should be noted that some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software or in one or more hardware modules or integrated circuits or in different networks and/or processor devices and/or microcontroller devices.
The above examples are illustrative of the connection pool, method of construction thereof, and computer readable storage medium of the present invention. Although only a few embodiments of the present invention have been described, those skilled in the art will appreciate that the present invention can be embodied in many other forms without departing from the spirit or scope thereof. Accordingly, the present examples and embodiments are to be considered as illustrative and not restrictive, and the invention is intended to cover various modifications and substitutions without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (11)

1. A method of constructing a connection pool, the method comprising:
determining a priority weight for each of a plurality of historical connections in the connection pool, the priority weights reflecting network status of the corresponding historical connections;
ranking the plurality of historical connections according to the priority weights to form the connection pool including a plurality of current connections, thereby providing for external retrieval of the ranked current connections according to the priority weights of each of the current connections in the connection pool,
wherein the priority weight of the history connection remains unchanged if the history connection did not participate in a previous transmission, and wherein the priority weight of the history connection is determined at least from: historical average priority weight, request type of previous transmission, message length of previous transmission, time consumption of previous transmission and number of in-transit messages; and
Wherein the priority weight is determined by:
wherein W represents the priority weight, w_av represents the historical average priority weight, req_type represents the request type of the previous transmission, req_len represents the message length of the previous transmission, cost represents the time consumption of the previous transmission, M represents the number of in-transit messages, and A, B represents a coefficient.
2. The method of claim 1 wherein the priority weight is positively correlated with the historical average priority weight and the message length of the previous transmission and negatively correlated with the time elapsed for the previous transmission and the number of messages in transit.
3. The method of claim 1, wherein the current connection is recalled and its historical average priority weight is determined by:
where W_av_new represents the redetermined historical average priority weight, N represents the number of accumulated invocations prior to the current invocation, W av The historical average priority weight representing the current connection and W representing the priority weight of the current connection.
4. The method of claim 1, wherein the current connections in the connection pool are arranged in a linked list with respective priority weights, wherein current connections with higher priority weights are arranged before current connections with lower priority weights.
5. The method of claim 1, wherein the current connections in the connection pool are arranged in a maximum heap structure with respective priority weights, wherein a parent node of the maximum heap structure corresponds to a current connection having a priority weight greater than a current connection corresponding to a child node of the parent node.
6. A computer readable storage medium having instructions stored therein, which when executed by a processor, cause the processor to perform the method of any of claims 1-5.
7. A connection pool, the connection pool comprising:
a plurality of current connections corresponding to a plurality of historical connections, the plurality of current connections being formed by arranging the plurality of historical connections according to priority weights of the plurality of historical connections for external retrieval of the arranged current connections according to the priority weights of each of the current connections;
wherein each of the plurality of historical connections has the priority weight reflecting a network state of the corresponding historical connection, wherein the priority weight remains unchanged if the historical connection did not participate in a previous transmission, and the priority weight of the historical connection is determined from at least: historical average priority weight, request type of previous transmission, message length of previous transmission, time consumption of previous transmission and number of in-transit messages; and
Wherein the priority weight is determined by:
wherein W represents the priority weight, w_av represents the historical average priority weight, req_type represents the request type of the previous transmission, req_len represents the message length of the previous transmission, cost represents the time consumption of the previous transmission, M represents the number of in-transit messages, and A, B represents a coefficient.
8. The connection pool of claim 7, wherein the priority weight is positively correlated with the historical average priority weight and the message length of the previous transmission and negatively correlated with the time elapsed for the previous transmission and the number of in-transit messages.
9. The connection pool of claim 7, wherein the current connection is recalled and its historical average priority weight is redetermined by:
where W_av_new represents the redetermined historical average priority weight, N represents the number of accumulated invocations prior to the current invocation, W av The historical average priority weight representing the current connection and W representing the priority weight of the current connection.
10. The connection pool of claim 7, wherein the current connections in the connection pool are arranged in a linked list with respective priority weights, wherein current connections with higher priority weights are arranged before current connections with lower priority weights.
11. The connection pool of claim 7, wherein the current connections in the connection pool are arranged in a maximum heap structure with respective priority weights, wherein a parent node of the maximum heap structure corresponds to a current connection having a priority weight greater than a current connection corresponding to a child node of the parent node.
CN201911371098.0A 2019-12-24 2019-12-24 Connection pool, construction method thereof and computer readable storage medium Active CN111431817B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911371098.0A CN111431817B (en) 2019-12-24 2019-12-24 Connection pool, construction method thereof and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911371098.0A CN111431817B (en) 2019-12-24 2019-12-24 Connection pool, construction method thereof and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN111431817A CN111431817A (en) 2020-07-17
CN111431817B true CN111431817B (en) 2023-08-22

Family

ID=71546916

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911371098.0A Active CN111431817B (en) 2019-12-24 2019-12-24 Connection pool, construction method thereof and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111431817B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101414954A (en) * 2007-10-16 2009-04-22 中兴通讯股份有限公司 Business integration scheduling method for OFDMA system
CN105468619A (en) * 2014-09-03 2016-04-06 阿里巴巴集团控股有限公司 Resource distribution method and device used for database connection pool
CN108124003A (en) * 2017-12-11 2018-06-05 中盈优创资讯科技有限公司 Network management device connection processing method, apparatus and system
CN109800067A (en) * 2018-12-15 2019-05-24 中国平安人寿保险股份有限公司 Database connection optimization method, device and relevant device based on cloud monitoring

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7599321B2 (en) * 2006-03-01 2009-10-06 Freescale Semiconductor, Inc. Prioritization of connection identifiers for an uplink scheduler in a broadband wireless access communication system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101414954A (en) * 2007-10-16 2009-04-22 中兴通讯股份有限公司 Business integration scheduling method for OFDMA system
CN105468619A (en) * 2014-09-03 2016-04-06 阿里巴巴集团控股有限公司 Resource distribution method and device used for database connection pool
CN108124003A (en) * 2017-12-11 2018-06-05 中盈优创资讯科技有限公司 Network management device connection processing method, apparatus and system
CN109800067A (en) * 2018-12-15 2019-05-24 中国平安人寿保险股份有限公司 Database connection optimization method, device and relevant device based on cloud monitoring

Also Published As

Publication number Publication date
CN111431817A (en) 2020-07-17

Similar Documents

Publication Publication Date Title
CN111522636B (en) Application container adjusting method, application container adjusting system, computer readable medium and terminal device
JP5744707B2 (en) Computer-implemented method, computer program, and system for memory usage query governor (memory usage query governor)
AU2004266017B2 (en) Hierarchical management of the dynamic allocation of resources in a multi-node system
US20090006520A1 (en) Multiple Thread Pools for Processing Requests
CN106648456B (en) Dynamic copies file access method based on user's amount of access and forecasting mechanism
CN111782692B (en) Frequency control method and device
CN103312624A (en) Message queue service system and method
WO2021057108A1 (en) Data reading method, data writing method, and server
US20180165112A1 (en) Managing test services in a distributed production service environment
WO2020042612A1 (en) Method and device for storing and reading a message, server, and storage medium
CN109981768A (en) I/o multipath planning method and equipment in distributed network storage system
US7085815B2 (en) Scalable memory management of token state for distributed lock managers
US11863675B2 (en) Data flow control in distributed computing systems
US11429311B1 (en) Method and system for managing requests in a distributed system
US10862922B2 (en) Server selection for optimized malware scan on NAS
CN110209693A (en) High concurrent data query method, apparatus, system, equipment and readable storage medium storing program for executing
CN111431817B (en) Connection pool, construction method thereof and computer readable storage medium
CN111414356A (en) Data storage method and device, non-relational database system and storage medium
US11888938B2 (en) Systems and methods for optimizing distributed computing systems including server architectures and client drivers
WO2021259064A1 (en) Capacity reduction/expansion method and system for cluster, capacity reduction/expansion control terminal and medium
US20050265362A1 (en) Message relay program and message relay device
US11561777B2 (en) System and method for intelligent update flow across inter and intra update dependencies
CN110196881B (en) Block chain-based data reading and writing method and block chain network structure
CN112506875B (en) File storage method, related device and file storage system
WO2022021858A1 (en) Method and system for achieving high service availability in high-load scene in distributed system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant