Port allocation method, device, electronic device and storage medium

By dynamically acquiring and filtering the available ports of service nodes, the problem of port allocation in K8s being limited by the cluster size is solved, efficient port utilization and resource optimization are achieved, and maintenance costs are reduced.

CN113946404BActive Publication Date: 2024-10-29BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111154045.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2024-10-29
Estimated Expiration
2041-09-29

Smart Images

  • Figure CN113946404B_ABST
    Figure CN113946404B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a port allocation method, device, electronic device and storage medium, the port allocation method comprising: in response to an application deployment request, obtaining an identification information set of available ports of a service node, filtering the identification information of available ports according to the record information of allocated ports, obtaining an identification information set of a preliminary port of the service node, wherein the record information of allocated ports includes identification information of allocated but unoccupied ports, determining first identification information from the identification information set of the preliminary port, and sending the first identification information. In this way, by adopting a dynamic port allocation mechanism, available ports in a service node are automatically obtained at startup, and the services in the deployment point Pod are displayed using the preliminary ports obtained after filtering the available ports, and provided to users outside the cluster for use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of Internet technology, and in particular to a port allocation method, device, electronic device and storage medium. Background Art

[0002] K8s (Kubernetes) is a popular open source tool for managing containerized applications on cloud platforms and is widely used by a large number of Internet companies. Business applications exist in the form of deployment point Pods in K8s. After business applications are deployed in a containerized manner, how to display the services in the deployment point Pods and provide them to users outside the cluster has become a problem that K8s needs to pay attention to. Summary of the invention

[0003] The present disclosure provides a port allocation method, device, electronic device and storage medium to at least solve the problem of how to display the services in the deployment point Pod in the related technology and provide them to users outside the cluster. The technical solution of the present disclosure is as follows:

[0004] According to a first aspect of an embodiment of the present disclosure, there is provided a port allocation method, comprising:

[0005] In response to the application deployment request, obtaining an identification information set of available ports of the service node;

[0006] Filtering the identification information of available ports according to the record information of allocated ports to obtain the identification information set of the primary selected ports of the service node; the record information of allocated ports includes the identification information of allocated but unoccupied ports;

[0007] Determine first identification information from the identification information set of the preliminarily selected port;

[0008] Send the first identification information.

[0009] In some possible embodiments, before determining the first identification information from the identification information set of the preliminarily selected port, the method further includes:

[0010] The identification information set of the preliminary selected port is added to the record information of the allocated port to obtain updated record information of the allocated port.

[0011] In some possible embodiments, the method further includes:

[0012] In the updated record information of the allocated port, a preset cache time of the first identification information is set.

[0013] In some possible embodiments, after determining the first identification information from the identification information set of the preliminarily selected port, the method further includes:

[0014] Determine the second identification information in the identification information set of the primary selected port;

[0015] If the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

[0016] In some possible embodiments, in response to the application deployment request, obtaining the identification information set of the available ports of the service node includes:

[0017] In response to the application deployment request, create at least one deployment point, and obtain an identification information set of available ports of the service node;

[0018] The number of preliminarily selected ports is greater than or equal to the number of deployment points.

[0019] In some possible embodiments, the number of the first identification information is the same as the number of the created deployment points and corresponds one to one; sending the first identification information includes:

[0020] The corresponding first identification information is fed back to each deployment point of the at least one deployment point, and the deployment point corresponding to the first identification information is used to provide services for the business application by using the primary selected port corresponding to the first identification information.

[0021] According to a second aspect of an embodiment of the present disclosure, there is provided a port allocation device, comprising:

[0022] An identification acquisition module, configured to execute, in response to an application deployment request, acquiring an identification information set of an available port of a service node;

[0023] An identification filtering module is configured to filter the identification information of available ports according to the record information of allocated ports to obtain an identification information set of preliminary selected ports of the service node; the record information of allocated ports includes the identification information of allocated but unoccupied ports;

[0024] An identification determination module, configured to determine first identification information from the identification information set of the preliminarily selected port;

[0025] The identification feedback module is configured to execute sending of first identification information.

[0026] In some possible embodiments, the device further includes:

[0027] The record updating module is configured to add the identification information set of the preliminary selected port to the record information of the allocated port to obtain the updated record information of the allocated port.

[0028] In some possible embodiments, the device further includes:

[0029] The time setting module is configured to set a preset cache time of the first identification information in the updated record information of the allocated port.

[0030] In some possible embodiments, the apparatus further includes an identification deletion module configured to execute:

[0031] Determine the second identification information in the identification information set of the primary selected port;

[0032] If the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

[0033] In some possible embodiments, the identification acquisition module is configured to execute:

[0034] In response to the application deployment request, create at least one deployment point, and obtain an identification information set of available ports of the service node;

[0035] The number of preliminarily selected ports is greater than or equal to the number of deployment points.

[0036] In some possible embodiments, the number of the first identification information is the same as the number of the created deployment points and corresponds one to one; the identification feedback module is configured to execute:

[0037] The corresponding first identification information is fed back to each deployment point of the at least one deployment point, and the deployment point corresponding to the first identification information is used to provide services for the business application by using the primary selected port corresponding to the first identification information.

[0038] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the above port allocation method.

[0039] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of a server, the server is enabled to execute the above port allocation method.

[0040] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a readable storage medium, at least one processor of a computer device reading and executing the computer program from the readable storage medium, so that the device executes the above-mentioned port allocation method.

[0041] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0042] In response to the application deployment request, the identification information set of the available ports of the service node is obtained, the identification information of the available ports is filtered according to the record information of the allocated ports, and the identification information set of the preliminary selected ports of the service node is obtained. The record information of the allocated ports includes the identification information of the ports that have been allocated but not occupied. The first identification information is determined from the identification information set of the preliminary selected ports, and the first identification information is sent. In this way, by adopting the dynamic port allocation mechanism, the available ports in the service node are automatically obtained at startup, and the services in the deployment point Pod are displayed using the preliminary selected ports obtained after filtering the available ports, and provided to users outside the cluster.

[0043] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0045] Figure 1 is a schematic diagram of an implementation environment according to an exemplary embodiment;

[0046] Figure 2 is a flow chart showing a port allocation method according to an exemplary embodiment;

[0047] Figure 3 is a flow chart showing a port allocation method according to an exemplary embodiment;

[0048] Figure 4 is a flow chart showing a port allocation method according to an exemplary embodiment;

[0049] Figure 5 is a structural schematic diagram of a port allocation according to an exemplary embodiment;

[0050] Figure 6 is a block diagram of a port allocation device according to an exemplary embodiment;

[0051] Figure 7 It is a block diagram of an electronic device for port allocation according to an exemplary embodiment. DETAILED DESCRIPTION

[0052] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0053] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0054] See also Figure 1 , Figure 1 is a schematic diagram of an application environment according to an exemplary embodiment. Figure 1 As shown, the application environment is suitable for the K8s cluster of the service management platform. Among them, K8s is a popular open source tool for managing containerized applications on cloud platforms and is widely used by a large number of Internet companies. Business applications exist in the form of deployment points Pod in K8s. The K8s cluster is a collection of nodes corresponding to computing, processing, and storage respectively. K8s can use these node resources to run various container-based applications. The application environment may include a server cluster 01 and a terminal device 02.

[0055] In an optional embodiment, the server cluster 01 may include multiple service nodes 011, each service node 011 may respond to an application deployment request, obtain an identification information set of available ports of the service node, filter the identification information of available ports according to the record information of allocated ports, obtain the identification information set of the preliminary selected ports of the service node, the record information of allocated ports includes the identification information of allocated but unoccupied ports, determine the first identification information from the identification information set of the preliminary selected ports, and send the first identification information. The server cluster 01 may be a server cluster or distributed system composed of multiple physical servers as shown in FIG. (1), or may be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0056] In an optional embodiment, the terminal device 02 may send an application deployment request to the service node 011 in the server cluster 01, and the application deployment request carries business application information, so that the service node 011 in the server cluster 01 may provide the first identification information of the service port based on the application deployment request, so that the primary port corresponding to the first identification information is used as the target port of the service node to serve the business application on the terminal device 02. Specifically, the terminal device 02 includes but is not limited to electronic devices such as smart phones, desktop computers, tablet computers, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, smart wearable devices, etc. Optionally, the operating system running on the electronic device may include but is not limited to Android system, IOS system, Linux system, Windows system, Unix system, etc.

[0057] In addition, it should be noted that Figure 1 What is shown is only an application environment provided by the present disclosure. In the embodiments of the present specification, the server cluster 01 and the terminal device 02 may be directly or indirectly connected via wired or wireless communication, and the present disclosure does not make any limitation thereto.

[0058] Figure 2 is a flow chart of a port allocation method according to an exemplary embodiment. Figure 2 As shown, the port allocation method can be applied to electronic devices such as servers and service nodes in a server cluster, and includes the following steps.

[0059] In step S201, in response to an application deployment request, an identification information set of available ports of a service node is obtained.

[0060] In the embodiments of the present disclosure, the application environment mentioned above can be applicable to the K8s cluster of the service management platform. Optionally, the K8s cluster can include one or more service nodes. In this case, the application deployment request can be initiated by a business application on the terminal device. After the terminal device and the service cluster establish a communication link, in some possible embodiments, after the server node in the service cluster that can provide the corresponding service (undertaken by a server or a device in the K8s cluster) receives the application deployment request issued by the business application, it can first determine the available ports of the service node itself, and then determine the identification information of these available ports to obtain an identification information set.

[0061] In some embodiments, in response to the application deployment request, the service node also creates one or more deployment point pods.

[0062] In some possible embodiments, a service node may have many ports, and the above-mentioned available ports refer to unoccupied ports in the service node that can provide services.

[0063] In the embodiment of the present disclosure, in step S201, the service node can respond to the application deployment request issued by the business application. In one example, a port allocation program is deployed on the service node, and the program is used to obtain the identification information set of the available ports of the service node. Specifically, the service node can respond to the application deployment request issued by the business application, start the above-mentioned port allocation program, and use the port allocation program to obtain the identification information set of the available ports of the service node.

[0064] In some possible embodiments, the business application may be a social application, a shopping application, or an audio and video application (etc.

[0065] In the embodiment of the present disclosure, the identification information of the available port in the above identification information set may be a unique identifier of the port, such as a preset port number, or a preset identifier.

[0066] The following example illustrates that when the K8s cluster receives an application deployment request from a business application, it can determine the service node that can provide the corresponding service and notify the service node so that the service node can use the port detection instance (port allocation program) of the service node itself to obtain the identification information set of the available ports. Assuming that 5 available ports are detected, the identification information of the 5 available ports can be obtained, such as 20001, 20002, 20003, 20004 and 20005, and finally an identification information set containing these 5 identification information is obtained.

[0067] In the embodiment of the present disclosure, the simultaneous detection of multiple available ports in step S201 can be referred to as batch acquisition of available ports. The reason for batch acquisition of available ports is that the port is detected to be occupied by a business application for a long period of time, and there is a risk of being occupied by other business applications starting services during this period. In this case, batch acquisition can provide sufficient port resources for subsequent port verification and filtering.

[0068] In step S203, the identification information of available ports is filtered according to the record information of allocated ports to obtain the identification information set of the primary selected ports of the service node; the record information of allocated ports includes the identification information of allocated but unoccupied ports.

[0069] In the disclosed embodiment, there is a certain time interval between the allocation of a preliminary port to a certain business application and the actual occupation of the preliminary port. For example, the time point when the preliminary port is allocated to business application A is 9 o'clock, but the time when the preliminary port is actually occupied by business application A may be 9:01. The above situation will inevitably lead to the following situation: there are ports that have been allocated but not occupied in the available ports. In order to avoid repeatedly allocating the same port to the previous and subsequent business applications in a short period of time to a certain extent, and reduce the situation of port conflicts, in the disclosed embodiment, the service node can filter the identification information set of the available ports according to the record information of the allocated ports to obtain the identification information set of the preliminary ports of the service node. In other words, the service node can delete the identification information of the allocated but unoccupied ports from the identification information set to avoid the situation of port conflicts that may occur later.

[0070] Continuing to elaborate based on the above example, assuming that the record information of the allocated port includes the identification information 20003 and 20004 of the available ports, after updating the identification information set of the available ports (i.e., after deleting the identification information 20003 and 20004), the identification information set of the preliminary ports of the service node (20001, 20002 and 20005) can be obtained.

[0071] In some possible embodiments, before filtering the identification information set of the available ports according to the record information of the allocated ports, the availability of the available ports can also be verified to avoid errors caused by other reasons when detecting the available ports. Optionally, the availability can be verified by using telnet technology, so that it can be ensured that the identification information set of the determined available ports does not contain, or tries not to contain, the identification information of the occupied ports, thereby ensuring that the subsequent ports can smoothly provide services for business applications. In specific use, telnet+port number or telnet+domain name+port number can be used to determine whether a certain port is available.

[0072] In some possible embodiments, the record information of the allocated ports may be presented in a table form, such as Table (1), or in a text form, or in other forms. Optionally, the presentation form is not limited in the embodiments of the present disclosure.

[0073] Table (1): Record information of allocated ports

[0074] 20003 20004 20006 20007 20008

[0075] In some other possible embodiments, the record information of the allocated port can be cached in a preset storage area of ​​the service node itself, so that when filtering the identification information set of the available ports, it can be extracted from the preset storage area. Optionally, in the embodiment of the present disclosure, the record information of the allocated port can be cached with the help of node local files, or Redis and other mechanisms.

[0076] In the disclosed embodiment, in order to prevent the primary selected ports corresponding to subsequent business applications from being repeatedly allocated the same port in a short period of time, resulting in port conflicts, and also to provide data support for subsequent port filtering, the service node can cache the identification information set of the primary selected port in the record information of the allocated port, and obtain the updated record information of the allocated port as shown in Table (2).

[0077] Table (2): Record information of allocated ports

[0078] 20003 20004 20006 20007 20008 20001 20002 20005

[0079] In some possible embodiments, as mentioned above, there is a certain time interval between the allocation of a preliminary port to a certain service application and the actual determination of the preliminary port as a target port and the occupation of the preliminary port. In order to prevent the identification information of the preliminary port that ultimately does not become the target port from being stored in the record information of the allocated port and not being released, a preset cache time of each identification information in the identification information set of the preliminary port in the updated record information of the allocated port can be set, that is, in the updated record information of the allocated port, a preset cache time of the first identification information is set, as shown in Table (3):

[0080] Table (3): Record information of allocated ports

[0081] 20003 1min 20004 1min 20006 1min 20007 1.5min 20008 1.5min 20001 3min 20002 3min 20005 3min

[0082] Optionally, the above-mentioned preset cache time can be determined according to an empirical value, or according to the actual situation of each business application, and is not limited here.

[0083] In step S205, first identification information is determined from the identification information set of the initially selected port.

[0084] The above has analyzed the reasons for obtaining available ports in batches. Therefore, there may be unused ports in the available ports obtained in batches or the filtered preliminary selected ports. At this time, the service node can determine the first identification information from the identification information set of the preliminary selected ports.

[0085] To continue to explain based on the above example, although the identification information of the three preliminary ports 20001, 20002 and 20005 is determined, ultimately only one port is needed to meet the needs of the business application. Therefore, a first identification information, such as 20001, can be determined from the identification information of the three preliminary ports (20001, 20002 and 20005).

[0086] In step S207, first identification information is sent.

[0087] In some possible embodiments, the service node may feed back the first identification information 20001 to a deployment point created above, so that the primary port corresponding to the first identification information 20001 is used as the target port of the service node, thereby providing services for the business application.

[0088] In some possible embodiments, there is still some identification information of some preliminary selected ports that is not finally determined as the first identification information. In order to prevent the preliminary selected ports corresponding to the identification information that is not determined as the first identification information from being indefinitely frozen in the record information of the allocated ports, resulting in a waste of port resources, the embodiment of the present disclosure further provides a port allocation method. Figure 3 is a flow chart of a port allocation method according to an exemplary embodiment. Figure 3 As shown, the following steps are included:

[0089] In step S301: second identification information in the identification information set of the initially selected port is determined. The second identification information is information in the identification information set of the initially selected port except the first identification information.

[0090] To continue to explain based on the above example, if the first identification information determined in the identification information of the three initially selected ports (20001, 20002 and 20005) is 20001, the second identification information may be 20002 and 20005.

[0091] In step S303, if the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

[0092] In the disclosed embodiment, the storage time of the second identification information in the updated record information of the allocated port can be counted from the moment when the identification information set of the preliminary port is cached to the record information of the allocated port. Optionally, since the service node will inevitably determine the first identification information from the identification information set of the preliminary port within the preset cache time period. Therefore, after the first identification information has been determined, if the second identification information is still stored in the updated record information of the allocated port, it will inevitably delay the provision of available ports for subsequent business applications, thereby affecting the efficiency of the K8s cluster. Based on this, when the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the service node can delete the second identification information from the updated record information of the allocated port, that is, release the port represented by the second identification information.

[0093] In the disclosed embodiment, the above-mentioned port allocation method can be applied to the HostNetwork port allocation service in the K8s cluster of the service cluster management platform. Of course, it can also be flexibly applied to other port allocation services of other clusters.

[0094] In the related technology, when the deployment point Pod sets HostNetwork: When it is set to "yes", all containers in the Pod are directly exposed to the network environment of the host machine. At this time, the Pod address of the Pod is the address of the node where it is located. For the Pod started when HostNetwork is set to "yes" under the same deployment Deployment, only one Pod can be started on each node. In other words, the number of copies of the Pod started in HostNetwork mode cannot be more than the number of target nodes. The target node refers to the node selected when starting the Pod. If not selected, the number of target nodes is the number of all available nodes in the cluster. When the number of copies is greater than the number of target nodes, the extra Pods will always be in a waiting state or even an error state, because no nodes that can be scheduled can be found.

[0095] In order to overcome the problems presented in the related art, the embodiment of the present disclosure also provides a detailed port allocation method. Figure 4 is a flow chart showing a port allocation method according to an exemplary embodiment. Figure 5 is a schematic diagram showing a structure of port allocation according to an exemplary embodiment. Figure 4 and Figure 5 As shown, the following steps are included:

[0096] In step S401, in response to an application deployment request, at least one deployment point is created, and an identification information set of available ports of a service node is obtained; wherein the number of the initially selected ports is greater than or equal to the number of deployment points.

[0097] In the disclosed embodiment, based on the size of the traffic of the business application, after determining the service node, the service node can create one or more deployment point pods on the service node, and each deployment point pod needs to correspond to a port. In this way, the problem of port allocation being limited by the size of the cluster can be solved. For example, only one deployment point Pod can be started on each service node mentioned above, which can improve the scalability, stability and utilization of cluster resources of the service. Since the deployment points and the number of deployment points are determined based on the traffic required by the business application, the greater the traffic required by the business application, the greater the number of deployment points. Therefore, in order to meet the requirement that each deployment point has its corresponding port, the number of initially selected ports needs to be greater than or equal to the number of deployment points.

[0098] In step S403, the availability of the available ports is detected.

[0099] In step S405, the identification information of available ports is filtered according to the record information of allocated ports to obtain the identification information set of the primary selected ports of the service node; the record information of allocated ports includes the identification information of allocated but unoccupied ports.

[0100] In step S407, the identification information set of the initially selected port is added to the record information of the allocated port to obtain updated record information of the allocated port.

[0101] In step S409, the preset cache time of the first identification information is set in the updated record information of the allocated port.

[0102] In step S411, first identification information is determined from the identification information set of the initially selected port.

[0103] In the embodiment of the present application, the number of first identification information is the same as the number of created deployment points and corresponds one to one.

[0104] In step S413, the corresponding first identification information is fed back to each deployment point in the at least one deployment point, and the deployment point corresponding to the first identification information is used to provide services for the business application by using the primary selected port corresponding to the first identification information.

[0105] Optionally, the at least one deployment point refers to one deployment point or multiple deployment points. Optionally, the number of deployment points can be determined according to the traffic of the business application.

[0106] To continue to elaborate based on the above example, if there are multiple deployment points, for example, 2 deployment point pods. First, the service node can create these two deployment point pods in response to the application deployment request issued by the business application, and these two deployment points can respectively send requests for available ports to the service node. The service node can perform steps S403-S411 based on these two deployment point pods, and finally determine the respective first identification information for these two deployment point pods, and feed back the determined first identification information to the corresponding deployment point pod. In other words, the server's work of allocating the primary ports corresponding to the first identification information to the two deployment points is independent of each other and does not interfere with each other.

[0107] Specifically, the service node determines the first identification information of the first deployment point in the two deployment point pods as 20001, and the first identification information of the second deployment point as 20002, and then can feedback the first identification information to the two deployment points respectively. The first deployment point can use the primary selected port corresponding to the first identification information 20001 to provide services for the business application, and the second deployment point can use the primary selected port corresponding to the first identification information 20002 to provide services for the business application. Figure 5 The target port shown in is the preliminary port corresponding to the first identification information 20001 corresponding to the first deployment point and the preliminary port corresponding to the first identification information 20002 corresponding to the second deployment point. In this way, the embodiment of the present disclosure adopts a dynamic port allocation mechanism to automatically obtain available ports in the cluster at startup, without any additional mechanism to maintain the port pool, which greatly reduces the maintenance cost of services and cluster resources.

[0108] In step S415: second identification information in the identification information set of the initially selected port is determined.

[0109] Continuing to explain based on the above example, if the first identification information determined in the identification information of the three preliminary selected ports (20001, 20002 and 20005) is 20001 and 20002 respectively, then for the first deployment point, its second identification information can be 20002 and 20005, and for the second deployment point, its second identification information can be 20001 and 20005.

[0110] In step S417, if the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

[0111] In the disclosed embodiment, the above implementation contents are all operated on the premise of deploying the port allocation program on the service node. If there are multiple service nodes in the service cluster, the port allocation program can be deployed on each service node. Each service node can implement all the schemes involved in the embodiment of the present application with the cooperation of the port allocation program. In this case, even if the scale of the service node in the service cluster changes, because there is a one-to-one correspondence between the port allocation program and the service node, it will not affect the service node in use.

[0112] In summary, the disclosed embodiment provides sufficient port resources for subsequent port verification and filtering by acquiring available ports in batches, and avoids repeated allocation of the same port to previous and subsequent business applications in a short period of time to a certain extent through filtering measures for available ports, thereby reducing the risk of port conflicts, so that the target port can be determined from the preliminary ports in the subsequent period to provide services for business applications. In this way, it can not only solve the problem that port allocation in related technologies is limited by the scale of the cluster, and improve the scalability and stability of services and the utilization rate of cluster resources, but also adopt a dynamic port allocation mechanism to automatically obtain available ports in the cluster at startup, without the need for any additional mechanism to maintain the port pool, thereby greatly reducing the maintenance cost of services and cluster resources.

[0113] Figure 6 is a block diagram of a port allocation device according to an exemplary embodiment. Figure 6 The device includes an identification acquisition module 601, an identification filtering module 602, an identification determination module 603 and an identification feedback module 604, wherein:

[0114] The identification acquisition module 601 is configured to execute, in response to the application deployment request, an identification information set of available ports of the service node;

[0115] The identification filtering module 602 is configured to filter the identification information of the available ports according to the record information of the allocated ports to obtain the identification information set of the preliminary selected ports of the service node; the record information of the allocated ports includes the identification information of the allocated but unoccupied ports;

[0116] The identification determination module 603 is configured to determine the first identification information from the identification information set of the preliminarily selected port;

[0117] The identification feedback module 604 is configured to execute sending the first identification information.

[0118] In some possible embodiments, the device further includes:

[0119] The record updating module is configured to add the identification information set of the preliminary selected port to the record information of the allocated port to obtain the updated record information of the allocated port.

[0120] In some possible embodiments, the device further includes:

[0121] The time setting module is configured to set a preset cache time of the first identification information in the updated record information of the allocated port.

[0122] In some possible embodiments, the apparatus further includes an identification deletion module configured to execute:

[0123] Determine the second identification information in the identification information set of the primary selected port;

[0124] If the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

[0125] In some possible embodiments, the identification acquisition module is configured to execute:

[0126] In response to the application deployment request, create at least one deployment point, and obtain an identification information set of available ports of the service node;

[0127] The number of preliminarily selected ports is greater than or equal to the number of deployment points.

[0128] In some possible embodiments, the number of the first identification information is the same as the number of the created deployment points and corresponds one to one; the identification feedback module is configured to execute:

[0129] The corresponding first identification information is fed back to each deployment point of the at least one deployment point, and the deployment point corresponding to the first identification information is used to provide services for the business application by using the primary selected port corresponding to the first identification information.

[0130] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0131] Figure 7 is a block diagram of an electronic device for port allocation or image recognition according to an exemplary embodiment. The electronic device may be a terminal device, and its internal structure diagram may be as shown in FIG. Figure 7As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal device through a network connection. When the computer program is executed by the processor, a method for determining an image defect filling network or processing an image defect is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0132] Those skilled in the art will understand that Figure 7 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present disclosure, and does not constitute a limitation on the electronic device to which the scheme of the present disclosure is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0133] In an exemplary embodiment, an electronic device is further provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the port allocation method in the embodiment of the present disclosure.

[0134] In an exemplary embodiment, a storage medium is further provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the port allocation method in the embodiment of the present disclosure.

[0135] In an exemplary embodiment, a computer program product containing instructions is also provided. The computer program product includes a computer program. The computer program is stored in a readable storage medium. At least one processor of a computer device reads and executes the computer program from the readable storage medium, so that the device executes the above-mentioned port allocation method.

[0136] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present disclosure can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0137] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0138] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A port allocation method, It is characterized in that include: In response to the application deployment request, obtaining an identification information set of available ports of the service node; Filter the identification information of the available ports according to the record information of the allocated ports to obtain an identification information set of the primary selected ports of the service node; The record information of the allocated ports includes identification information of the allocated but unoccupied ports; Determining first identification information from the identification information set of the initially selected port; Send the first identification information.

2. The port allocation method according to claim 1, It is characterized in that Before determining the first identification information from the identification information set of the preliminarily selected port, the method further includes: The identification information set of the initially selected port is added to the record information of the allocated port to obtain updated record information of the allocated port.

3. The port allocation method according to claim 2, It is characterized in that The method further comprises: In the updated record information of the allocated port, a preset cache time of the first identification information is set.

4. The port allocation method according to claim 3, It is characterized in that After determining the first identification information from the identification information set of the preliminarily selected port, the method further includes: Determine second identification information in the identification information set of the initially selected port; If the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

5. The port allocation method according to any one of claims 1 to 4, It is characterized in that The step of obtaining the identification information set of the available ports of the service node in response to the application deployment request includes: In response to the application deployment request, create at least one deployment point, and obtain an identification information set of available ports of the service node; The number of the initially selected ports is greater than or equal to the number of the deployment points.

6. The port allocation method according to claim 5, It is characterized in that The number of the first identification information is the same as the number of the created deployment points and corresponds one to one; and sending the first identification information includes: The corresponding first identification information is fed back to each deployment point of the at least one deployment point, and the deployment point corresponding to the first identification information is used to provide services for the business application by using the primary selected port corresponding to the first identification information.

7. A port allocation device, It is characterized in that include: An identification acquisition module, configured to execute, in response to an application deployment request, acquiring an identification information set of an available port of a service node; an identification filtering module, configured to filter the identification information of the available ports according to the record information of the allocated ports, and obtain the identification information set of the preliminary selected ports of the service node; the record information of the allocated ports includes the identification information of the allocated but unoccupied ports; an identification determination module, configured to determine first identification information from the identification information set of the preliminarily selected port; The identification feedback module is configured to execute sending of the first identification information.

8. The port allocation device according to claim 7, It is characterized in that The device also includes: The record updating module is configured to add the identification information set of the preliminary selected port to the record information of the allocated port to obtain updated record information of the allocated port.

9. The port allocation device according to claim 8, It is characterized in that The device also includes: The time setting module is configured to set a preset cache time of the first identification information in the updated record information of the allocated port.

10. The port allocation device according to claim 9, It is characterized in that The apparatus further comprises an identification deletion module configured to execute: Determine second identification information in the identification information set of the initially selected port; If the storage time of the second identification information in the updated record information of the allocated port is greater than or equal to the preset cache time corresponding to the second identification information, the second identification information is deleted from the updated record information of the allocated port.

11. The port allocation device according to any one of claims 7 to 10, It is characterized in that The identification acquisition module is configured to execute: In response to the application deployment request, create at least one deployment point, and obtain an identification information set of available ports of the service node; The number of the initially selected ports is greater than or equal to the number of the deployment points.

12. The port allocation device according to claim 11, It is characterized in that The number of the first identification information is the same as the number of the created deployment points and corresponds one to one; the identification feedback module is configured to execute: The corresponding first identification information is fed back to each deployment point of the at least one deployment point, and the deployment point corresponding to the first identification information is used to provide services for the business application by using the primary selected port corresponding to the first identification information.

13. An electronic device, It is characterized in that include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the port allocation method according to any one of claims 1 to 6.

14. A storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the port allocation method according to any one of claims 1 to 6.

15. A computer program product, It is characterized in that The computer program product comprises a computer program, which is stored in a readable storage medium. At least one processor of a computer device reads and executes the computer program from the readable storage medium, so that the device performs the port allocation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Task allocation method, pod initialization method and related devices

    CN110427249A

  • Computer-executable method, system, and computer program product for balanced port provisioning using filtering in a data storage system

    US10067794B1