Disclosure of Invention
Embodiments of the present invention provide a service fusing method, apparatus, device, and storage medium, which can reduce resource occupation and prevent system crash.
In one aspect, an embodiment of the present invention provides a service fusing method, where the method includes:
receiving a service access request, wherein the service access request comprises identification information of a service to be accessed;
determining whether the service to be accessed corresponds to a service fusing rule or not according to the identification information of the service to be accessed;
and if the service to be accessed corresponds to the service fusing rule, fusing the service access request according to the service fusing rule.
In one embodiment of the invention, the fusing of the service access request according to the service fusing rule comprises the following steps:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
and if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, fusing the service access requests.
In one embodiment of the invention, the fusing of the service access request according to the service fusing rule comprises the following steps:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
and if the execution times reach the retry times specified by the service fusing rule, fusing the service access request.
In one embodiment of the invention, the fusing of the service access request according to the service fusing rule comprises the following steps:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
if the execution times reach the retry times specified by the service fusing rule, fusing the service access request;
if the number of the requests for accessing the service to be accessed does not reach the number of the requests specified by the service fusing rule, judging whether the number of the service requests in the request queue corresponding to the service to be accessed reaches the number of the request queues specified by the service fusing rule or not;
and if the service request number in the request queue corresponding to the service to be accessed is judged to reach the request queue number specified by the service fusing rule, fusing the service access request.
In an embodiment of the present invention, the service fusing method provided in the embodiment of the present invention further includes:
and receiving the service fusing rule sent by the server.
In an embodiment of the present invention, the service fusing method provided in the embodiment of the present invention further includes:
receiving Pod information corresponding to a service sent by a server;
and accessing the Pod corresponding to the service to be accessed through the agent Sidecar container according to the Pod information.
In another aspect, an embodiment of the present invention provides a service fusing apparatus, including:
the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving a service access request which comprises identification information of a service to be accessed;
the determining module is used for determining whether the service to be accessed corresponds to the service fusing rule or not according to the identification information of the service to be accessed;
and the fusing module is used for fusing the service access request according to the service fusing rule if the service to be accessed corresponds to the service fusing rule.
In an embodiment of the present invention, the fusing module is specifically configured to:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
and if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, fusing the service access requests.
In an embodiment of the present invention, the fusing module is specifically configured to:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
and if the execution times reach the retry times specified by the service fusing rule, fusing the service access request.
In an embodiment of the present invention, the fusing module is specifically configured to:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
if the execution times reach the retry times specified by the service fusing rule, fusing the service access request;
if the number of the requests for accessing the service to be accessed does not reach the number of the requests specified by the service fusing rule, judging whether the number of the service requests in the request queue corresponding to the service to be accessed reaches the number of the request queues specified by the service fusing rule or not;
and if the service request number in the request queue corresponding to the service to be accessed is judged to reach the request queue number specified by the service fusing rule, fusing the service access request.
In an embodiment of the present invention, the receiving module is further configured to:
and receiving the service fusing rule sent by the server.
In an embodiment of the present invention, the receiving module is further configured to:
and receiving the Pod information corresponding to the service sent by the server.
The service fusing device provided by the embodiment of the invention further comprises:
and the access module is used for accessing the Pod corresponding to the service to be accessed through the agent Sidecar container according to the Pod information.
In another aspect, an embodiment of the present invention provides a service fusing apparatus, where the apparatus includes: a memory, a processor, and a computer program stored on the memory and executable on the processor;
the processor implements the service fusing method provided by the embodiment of the invention when executing the computer program.
In another aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the service fusing method provided in the embodiment of the present invention.
According to the service fusing method, device, equipment and medium provided by the embodiment of the invention, the service access request is fused, so that the resources occupied by the service access request can be reduced, and further the system breakdown can be prevented.
Detailed Description
Features and exemplary embodiments of various aspects of the present invention will be described in detail below, and in order to make objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not to be construed as limiting the invention. It will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present invention by illustrating examples of the present invention.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
In order to solve the problem of the prior art, embodiments of the present invention provide a service fusing method, apparatus, device, and storage medium. The following first describes a service fusing method provided by an embodiment of the present invention.
Fig. 1 is a flowchart illustrating a service fusing method according to an embodiment of the present invention. The service fusing method may include:
s101: a service access request is received.
The service access request includes identification information of the service to be accessed.
S102: and determining whether the service to be accessed corresponds to the service fusing rule or not according to the identification information of the service to be accessed.
S103: and if the service to be accessed corresponds to the service fusing rule, fusing the service access request according to the service fusing rule.
In one embodiment of the present invention, the fuse refers to a protection measure adopted in the system to prevent the whole system from being out of order due to the overload phenomenon of the service caused by some reasons.
In one embodiment of the invention, the service access request may be blown by deleting the service access request.
According to the service fusing method provided by the embodiment of the invention, the service access requests are fused, so that the number of the service access requests for accessing the service is reduced, the resources occupied by the service access requests can be reduced, and further the system breakdown can be prevented.
In one embodiment of the invention, when the service access request is fused according to the service fusing rule, whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule can be judged; and if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, fusing the service access requests.
For example, assume that the maximum number of requests to access a service to be accessed is specified in the service fusing rule.
And when the number of the requests for accessing the service to be accessed does not reach the maximum request number, sending the service access request to the service to be accessed, and responding the service access request by the service to be accessed.
And when the number of the requests for accessing the service to be accessed reaches the maximum request number, fusing the service access request, and deleting the service access request, so that the number of the service access requests for accessing the service is reduced, and the resources occupied by the service access requests are reduced.
In one embodiment of the invention, when the service access request is fused according to the service fusing rule, whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule can be judged; if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule; and if the execution times reach the retry times specified by the service fusing rule, fusing the service access request.
For example, assume that the service fusing rule specifies a maximum number of requests to access the service to be accessed and a maximum number of retries.
And when the number of the requests for accessing the service to be accessed does not reach the maximum request number, sending the service access request to the service to be accessed, and responding the service access request by the service to be accessed.
When the number of the requests for accessing the service to be accessed reaches the maximum number of the requests and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the maximum retry times, continuously judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
and when judging whether the number of the requests for accessing the service to be accessed reaches the execution times of the request number specified by the service fusing rule and reaches the maximum retry times, fusing the service access request and deleting the service access request, so that the number of the service access requests for accessing the service is reduced, and the resources occupied by the service access requests are reduced. In addition, whether the execution times reach the maximum retry times or not is controlled to continuously execute and judge whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule or not, and the success rate of requesting the service to be accessed can be improved.
In one embodiment of the invention, when the service access request is fused according to the service fusing rule, whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule can be judged; if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule; if the execution times reach the retry times specified by the service fusing rule, fusing the service access request; if the number of the requests for accessing the service to be accessed does not reach the number of the requests specified by the service fusing rule, judging whether the number of the service requests in the request queue corresponding to the service to be accessed reaches the number of the request queues specified by the service fusing rule or not; and if the service request number in the request queue corresponding to the service to be accessed is judged to reach the request queue number specified by the service fusing rule, fusing the service access request.
Illustratively, assume that the service fusing rule specifies a maximum number of requests to access the service to be accessed, a maximum number of retries, and a maximum number of request queues.
And when the number of the requests for accessing the service to be accessed does not reach the maximum request number, judging whether the number of the service requests in the request queue corresponding to the service to be accessed reaches the maximum request queue number.
And when the service access request number in the request queue corresponding to the service to be accessed is judged to reach the maximum request queue number, fusing the service access request, and deleting the service access request, so that the service access request number for accessing the service is reduced, and the resources occupied by the service access request are reduced.
And when the service access request quantity in the request queue corresponding to the service to be accessed is judged to be less than the maximum request queue quantity, storing the service access request into the request queue corresponding to the service to be accessed, and further enabling the service to be accessed to obtain the service access request from the corresponding request queue and respond.
And when the number of the requests for accessing the service to be accessed reaches the maximum number of the requests and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the maximum retry times, continuously judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule.
And when judging whether the number of the requests for accessing the service to be accessed reaches the execution times of the request number specified by the service fusing rule and reaches the maximum retry times, fusing the service access request and deleting the service access request, so that the number of the service access requests for accessing the service is reduced, and the resources occupied by the service access requests are reduced.
In an embodiment of the present invention, the service fusing method provided in the embodiment of the present invention may further include: and receiving the service fusing rule sent by the server.
In one embodiment of the invention, the service fusing rule may include: the maximum request number for accessing the service to be accessed, the maximum retry times for accessing the service to be accessed and the maximum request queue number in the request queue corresponding to the service to be accessed.
In an embodiment of the present invention, the service fusing method provided in the embodiment of the present invention may further include: receiving Pod information corresponding to a service sent by a server; and accessing the Pod corresponding to the service to be accessed through the agent Sidecar container according to the Pod information.
The Pod is a basic unit of the kubernets system, is a minimum component created or deployed by a user, and is also a resource object for running a containerized application on the kubernets system. Kubernets is an open source for managing containerized applications on multiple hosts in a cloud platform, and its goal is to make containerized application deployment simple and efficient.
By the embodiment of the invention, the Pod which needs to be accessed when accessing other services can be judged, and the condition that the service Pod cannot be accessed due to change can be avoided.
The service fusing method provided by the embodiment of the invention is described below with reference to specific examples. Fig. 2 is a schematic structural diagram illustrating a service fusing provided by an embodiment of the present invention.
Firstly, a server/management end is deployed in a service cluster and used for issuing a service fusing rule. And simultaneously, deploying a proxy Sidecar container in the corresponding Pod of the service, wherein the proxy Sidecar container is used for processing the service fusing rule and intercepting the inlet flow and the outlet flow by modifying the address table (iptables) rule of the Pod. And the access control outside the service cluster is realized by deploying a single Sidecar container to serve as an entrance, the Sidecar container corresponds to the service inside the service cluster according to external request information, and the traffic interception and service fusing rule processing is carried out.
In an embodiment of the present invention, the user may create the service fusing rule through the server/management end, and the server/management end issues the service fusing rule configured by the user to the Sidecar container.
In one embodiment of the present invention, the sdecar container may send the address of its corresponding Pod, its corresponding service name and role to the server/administrator. And the server/management terminal determines the service fusing rule which needs to be issued to the Sidecar container according to the information sent by the Sidecar container, issues the determined service fusing rule to the Sidecar container, or notifies the Sidecar container to pull the required service fusing rule and configure the service fusing rule.
For example, assume that a certain Sidecar container corresponds to service A, which depends on service B. Determining that the service fusing rule needing to be issued to the Sidecar container is the service fusing rule corresponding to the service B, and issuing the service fusing rule corresponding to the service B to the Sidecar container.
When a user requests the ingress Sidecar container service or deploys the Sidecar container service to access service B, the service access request first goes to the Sidecar container, which determines whether service B corresponds to the service fusing rule. And at the moment, determining that the service B corresponds to the service fusing rule, and fusing the service access request according to the service fusing rule corresponding to the service B.
In an embodiment of the present invention, the service fusing rule corresponding to the service B may include: the maximum number of requests for accessing service B, the maximum retry number for accessing service B, and the maximum number of request queues in the request queue corresponding to service B.
Specifically, when the number of requests for accessing the service B does not reach the maximum number of requests, it is determined whether the number of service requests in the request queue corresponding to the service B reaches the maximum number of request queues.
And when the service request number in the request queue corresponding to the service B is judged to reach the maximum request queue number, fusing the service access request, and deleting the service access request, so that the service access request number for accessing the service B is reduced, and the resources occupied by the service access request are reduced.
And when the service request quantity in the request queue corresponding to the service B is judged to be less than the maximum request queue quantity, storing the service access request into the request queue corresponding to the service B, and further enabling the service B to acquire the service access request from the request queue corresponding to the service B and respond.
When the number of requests for accessing the service B reaches the maximum number of requests and the number of executions for determining whether the number of requests for accessing the service B reaches the number of requests specified by the service fusing rule does not reach the maximum number of retries, it is continuously determined whether the number of requests for accessing the service B reaches the number of requests specified by the service fusing rule.
And when judging whether the number of the requests for accessing the service B reaches the execution times of the request number specified by the service fusing rule and reaches the maximum retry times, fusing the service access request and deleting the service access request, so that the number of the service access requests for accessing the service B is reduced, and the resources occupied by the service access requests are reduced.
In an embodiment of the present invention, the server/manager may obtain Pod information corresponding to all services in the service cluster in real time by monitoring an Application Programming Interface (API) of the kubernets, and send the Pod information to the Sidecar container, so that the Sidecar container may determine a Pod that needs to be accessed when accessing other services, and a situation that the Pod corresponding to the service is changed and cannot be accessed may not occur.
In an embodiment of the present invention, when the Sidecar container determines that the fusing processing is not required for the service access request, the Pod corresponding to the service to be accessed may be determined according to a Uniform Resource Locator (URL) of the service access request, a HyperText Transfer Protocol (HTTP) header (Head), identification information of the service to be accessed, and partition information, and the access may be performed according to a set routing rule.
According to the service fusing method provided by the embodiment of the invention, the service access requests are fused, so that the number of the service access requests for accessing the service is reduced, the resources occupied by the service access requests can be reduced, and further the system breakdown can be prevented.
Corresponding to the above method embodiments, the embodiment of the present invention further provides a service fusing apparatus. As shown in fig. 3, fig. 3 is a schematic structural diagram of a service fusing device according to an embodiment of the present invention. The service fusing apparatus may include:
the receiving module 301 is configured to receive a service access request, where the service access request includes identification information of a service to be accessed.
The determining module 302 is configured to determine whether the service to be accessed corresponds to the service fusing rule according to the identification information of the service to be accessed.
And the fusing module 303 is configured to fuse the service access request according to the service fusing rule if the service to be accessed corresponds to the service fusing rule.
In an embodiment of the present invention, the fusing module 303 may be specifically configured to:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
and if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, fusing the service access requests.
In an embodiment of the present invention, the fusing module 303 may be specifically configured to:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
and if the execution times reach the retry times specified by the service fusing rule, fusing the service access request.
In an embodiment of the present invention, the fusing module 303 may be specifically configured to:
judging whether the number of requests for accessing the service to be accessed reaches the number of requests specified by the service fusing rule;
if the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule, and the execution times of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule does not reach the retry times specified by the service fusing rule, continuing to execute the step of judging whether the number of the requests for accessing the service to be accessed reaches the number of the requests specified by the service fusing rule;
if the execution times reach the retry times specified by the service fusing rule, fusing the service access request;
if the number of the requests for accessing the service to be accessed does not reach the number of the requests specified by the service fusing rule, judging whether the number of the service requests in the request queue corresponding to the service to be accessed reaches the number of the request queues specified by the service fusing rule or not;
and if the service request number in the request queue corresponding to the service to be accessed is judged to reach the request queue number specified by the service fusing rule, fusing the service access request.
In an embodiment of the present invention, the receiving module 301 may further be configured to:
and receiving the service fusing rule sent by the server.
In an embodiment of the present invention, the receiving module 301 may further be configured to:
receiving Pod information corresponding to a service sent by a server;
the service fusing device provided by the embodiment of the invention further comprises:
and the access module is used for accessing the Pod corresponding to the service to be accessed through the agent Sidecar container according to the Pod information.
According to the service fusing device provided by the embodiment of the invention, the service access request is fused, so that the resources occupied by the service access request can be reduced, and further the system breakdown can be prevented.
FIG. 4 is a block diagram illustrating an exemplary hardware architecture of a computing device capable of implementing the service fusing method and apparatus according to embodiments of the invention. As shown in fig. 4, computing device 400 includes an input device 401, an input interface 402, a central processor 403, a memory 404, an output interface 405, and an output device 406. The input interface 402, the central processing unit 403, the memory 404, and the output interface 405 are connected to each other through a bus 410, and the input device 401 and the output device 406 are connected to the bus 410 through the input interface 402 and the output interface 405, respectively, and further connected to other components of the computing device 400.
Specifically, the input device 401 receives input information from the outside and transmits the input information to the central processor 403 through the input interface 402; the central processor 403 processes the input information based on computer-executable instructions stored in the memory 404 to generate output information, stores the output information temporarily or permanently in the memory 404, and then transmits the output information to the output device 406 through the output interface 405; output device 406 outputs the output information outside of computing device 400 for use by a user.
That is, the computing device shown in fig. 4 may also be implemented as a service fusing device, which may include: a memory storing computer-executable instructions; and a processor, which when executing computer-executable instructions, may implement the service fusing method and apparatus provided by embodiments of the present invention.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium has computer program instructions stored thereon; the computer program instructions, when executed by a processor, implement a service fusing method provided by embodiments of the present invention.
It is to be understood that the invention is not limited to the specific arrangements and instrumentality described above and shown in the drawings. A detailed description of known methods is omitted herein for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications and additions or change the order between the steps after comprehending the spirit of the present invention.
The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, plug-in, function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted by a data signal carried in a carrier wave over a transmission medium or a communication link. A "machine-readable medium" may include any medium that can store or transfer information. Examples of a machine-readable medium include electronic circuits, semiconductor memory devices, ROM, flash memory, Erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, Radio Frequency (RF) links, and so forth. The code segments may be downloaded via computer networks such as the internet, intranet, etc.
It should also be noted that the exemplary embodiments mentioned in this patent describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, may be performed in an order different from the order in the embodiments, or may be performed simultaneously.
As described above, only the specific embodiments of the present invention are provided, and it can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system, the module and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. It should be understood that the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the present invention, and these modifications or substitutions should be covered within the scope of the present invention.