CN117376263A - Method and device for processing request, electronic equipment and computer readable storage medium - Google Patents

Method and device for processing request, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN117376263A
CN117376263A CN202311301607.9A CN202311301607A CN117376263A CN 117376263 A CN117376263 A CN 117376263A CN 202311301607 A CN202311301607 A CN 202311301607A CN 117376263 A CN117376263 A CN 117376263A
Authority
CN
China
Prior art keywords
service
service request
parameters
processing
token bucket
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311301607.9A
Other languages
Chinese (zh)
Inventor
陈诗杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311301607.9A priority Critical patent/CN117376263A/en
Publication of CN117376263A publication Critical patent/CN117376263A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/215Flow control; Congestion control using token-bucket
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/20Traffic policing

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The disclosure provides a method and a device for processing a request, electronic equipment and a computer readable storage medium, and relates to the technical field of data, in particular to the technical fields of network communication, data flow limiting, service flow limiting and the like. The specific implementation scheme is as follows: responding to a service request sent by a receiving client, and determining a service interface corresponding to the service request; acquiring the current limiting parameters of the current limiter corresponding to the service interface, and processing the service request according to the current limiting parameters; wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.

Description

Method and device for processing request, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of data technologies, and in particular, to the technical fields of network communications, data throttling, service throttling, and so on. In particular, the disclosure relates to a method and apparatus for request processing, an electronic device, and a computer-readable storage medium.
Background
In the network communication process, in order to avoid that the request frequency of the system or the execution frequency of part of functions in the system exceeds the frequency limit of the system due to sudden flow surge, and the whole system is not available, some current limiting strategies are needed to be adopted to limit the part of requests to access the system, so that the normal operation of the system is ensured.
Disclosure of Invention
The present disclosure provides a method and apparatus for request processing, an electronic device, and a computer-readable storage medium.
According to a first aspect of the present disclosure, there is provided a method of request processing, the method comprising:
responding to a service request sent by a receiving client, and determining a service interface corresponding to the service request;
acquiring the current limiting parameters of the current limiter corresponding to the service interface, and processing the service request according to the current limiting parameters;
wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.
According to a second aspect of the present disclosure, there is provided an apparatus for request processing, the apparatus comprising:
the request receiving module is used for responding to the received service request sent by the client and determining a service interface corresponding to the service request;
the request processing module is used for acquiring the flow limiting parameters of the flow limiter corresponding to the service interface and processing the service request according to the flow limiting parameters;
wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of requesting processing.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method of request processing described above.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method of request processing described above.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a flow diagram of a method of request processing provided by an embodiment of the present disclosure;
FIG. 2 is a flow diagram of partial steps of another method of request processing provided by an embodiment of the present disclosure;
FIG. 3 is a flow diagram of partial steps of another method of request processing provided by an embodiment of the present disclosure;
FIG. 4 is a flow chart of some steps of another method of request processing provided by an embodiment of the present disclosure;
FIG. 5 is a flow diagram of partial steps of another method of request processing provided by an embodiment of the present disclosure;
FIG. 6 is a process diagram of one particular embodiment of a method of request processing provided by an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of an apparatus for processing a request according to an embodiment of the disclosure;
fig. 8 is a block diagram of an electronic device for implementing a method of request processing of an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In some related technologies, the flow limiting parameters are uniformly configured on the interfaces of the system, and the flow of the interfaces of the system is limited. However, in an actual service scenario, different interfaces have different service flows due to different complexity of service functions, if the same flow limiting parameters are adopted for flow limiting, the maximum flow of the service depends on the interface with the worst performance, and the service capability of the system is affected.
The embodiments of the present disclosure provide a method and apparatus for processing a request, an electronic device, and a computer readable storage medium, which aim to solve at least one of the above technical problems in the prior art.
The method for processing a request provided by the embodiments of the present disclosure may be performed by an electronic device such as a terminal device or a server, where the terminal device may be a vehicle-mounted device, a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, or the like, and the method may be implemented by a processor invoking computer readable program instructions stored in a memory. Alternatively, the method may be performed by a server.
Fig. 1 shows a flowchart of a method for processing a request according to an embodiment of the present disclosure. As shown in fig. 1, the method may include step S110, step S120.
In step S110, in response to receiving a service request sent by a client, determining a service interface corresponding to the service request;
in step S120, obtaining a current limiting parameter of a current limiter corresponding to the service interface, and processing the service request according to the current limiting parameter;
wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.
For example, the request processing method provided by the embodiment of the present disclosure may be applied to a server, where the server may include one or more distributed servers, and each server may receive a service request sent from a client connected thereto by a wired or wireless manner.
The server of the server may have one or more service interfaces, the service interfaces are used for accessing service requests, and the functional modules of the server are used for processing service requests obtained through the service interfaces.
In some possible implementations, in step S110, after receiving the service request sent by the client, the server determines, according to specific information of the service request, a service interface to which the service request needs to be accessed as a service interface corresponding to the service request.
In some possible implementations, after determining the service interface corresponding to the service request, it is determined whether the service request is provided with a current limiter.
Restrictors are very important components to improve service stability and can be used to limit request rates and protect services from service overload. In some related art, the restrictor may be implemented based on a restrictor algorithm (e.g., fixed window, sliding window, leaky bucket, token bucket, etc.).
The current limiter in the request processing method provided by the embodiment of the disclosure is a current limiter realized based on a token bucket algorithm, namely a current limiter based on a token bucket.
In some possible implementations, the flow limiter of the service interface may be preset according to the attribute (such as complexity) of the service function corresponding to the service interface.
In some possible implementations, in step S120, in a case where a flow restrictor based on a token bucket is registered for a service interface corresponding to a service request, a flow restricting parameter of the flow restrictor is acquired.
The flow limiting parameters of the flow limiter comprise token bucket parameters of a token bucket corresponding to the flow limiter.
In some possible implementations, the token bucket parameters of the token bucket corresponding to the restrictor may include the size of the token bucket (i.e., the upper limit of the number of resource tokens that the token bucket may include), the rate at which the token bucket generates resource tokens, the number of resource tokens remaining in the token bucket, and the token bucket expiration time (once the token bucket expiration time is zero, the token bucket is refreshed or filled).
In some possible implementations, the flow restriction parameters of the flow restrictor may also include an identification name that distinguishes the flow restrictor from unique identifications of other flow restrictors.
In some possible implementations, the current limiting parameters of the current limiter may further include a predefined current limiting method, which may be used to perform current limiting processing on the service request.
In some possible implementations, processing the service request according to the throttling parameter of the flow limiter may be determining whether the service request needs to be throttled according to a relationship between resources required for the service request and resource tokens of a token bucket of the flow limiter.
Under the condition that the service request needs to be limited, the service request can be limited according to a predefined limiting method, and the service request can be directly refused to access the service interface.
In the case that the service request does not need to be limited, the service request can be directly accessed to the service interface so that the functional module of the service end can process the service request.
In some possible implementations, the current limit parameters of the current limiter registered by all service interfaces of the server may be stored in the current limiter database.
In some possible implementations, the obtaining the current limiting parameter of the current limiter may be searching in a current limiter database according to an identification name of a unique identification of the current limiter, and obtaining the current limiting parameter of the current limiter.
In some possible implementations, the restrictor database may be specifically a persistent middleware corresponding to the server and client.
In the method for processing the request provided by the embodiment of the disclosure, the service request is processed by acquiring the current limiting parameters of the current limiter set by the service interface corresponding to the service request, and as different current limiters can be set by different service interfaces, different service interfaces can have different current limiting parameters to process the service request, so that different current limiting requirements of different service interfaces are met. Furthermore, in the method for processing a request provided by the embodiment of the disclosure, the restrictor is a restrictor based on a token bucket algorithm, and processes a service request according to token bucket parameters of the restrictor, so that the service request can be subjected to flow limiting processing in time under the condition that the state of the token bucket does not meet the service request, and the service request processing efficiency of a service interface is improved.
The method for processing a request provided by the embodiment of the present disclosure is specifically described below.
As described above, in some possible implementations, the flow limiter of the service interface may be preset according to the attribute (such as complexity) of the service function corresponding to the service interface.
Figure 2 shows a flow diagram of one implementation of a limiter for a preset traffic interface. As shown in fig. 2, the flow restrictor of the preset service interface may include step S210, step S220.
In step S210, determining a current limiting parameter corresponding to the service interface according to the attribute of the service function corresponding to the service interface;
in step S220, a flow limiter is set for the service interface according to the flow limiting parameters.
In some possible implementations, in step S210, it may be that a worker at the service end determines, according to experience, a current limiting parameter corresponding to the service interface according to an attribute of a service function corresponding to the service interface.
The service function corresponding to the service interface may be a service function of a functional unit that processes a service request accessed by the service interface.
The attributes of the business function may include attributes related to the ability of the business function to process business requests, such as the complexity of the business function, the upper limit of service traffic that the business function may process, and the like.
In some possible implementations, determining the flow restriction parameter corresponding to the service interface according to the attribute of the service function corresponding to the service interface may be determining the size of the token bucket according to the upper limit of the service traffic processed by the service interface, and determining the rate at which the resource token is generated by the token bucket according to the complexity of the service function corresponding to the service interface.
In some possible implementations, the throttling method can also be set according to the information such as the type of the service request processed by the service interface, so as to perform the throttling processing on the service request
In some possible implementations, in step S220, setting a restrictor for the service interface according to the restrictor parameter may be registering the restrictor implemented based on the token bucket algorithm according to the restrictor parameter determined in step S210, and generating an identification name of a unique identification of the restrictor.
The flow limiter is arranged according to the attribute of the service function corresponding to the service interface, so that the flow limiter accords with the service function of the service interface, the flow limiter is more matched with the service interface, the influence on the service function of the service interface is reduced to the greatest extent, and the service request processing efficiency of the service interface is improved.
As described above, in some possible implementations, the flow restriction parameters of the flow restrictor include token bucket parameters of a token bucket to which the flow restrictor corresponds. In some possible implementations, the token bucket parameters of the token bucket corresponding to the restrictor may include a size of the token bucket (i.e., an upper limit on a number of resource tokens that the token bucket may include), a rate at which the token bucket generates resource tokens, a number of remaining resource tokens of the token bucket, and a token bucket expiration time (i.e., a remaining waiting time for the token bucket to reacquire tokens).
In some possible implementations, the flow restriction parameters of the flow restrictor may also include an identification name that distinguishes the flow restrictor from unique identifications of other flow restrictors.
In some possible implementations, the current limiting parameters of the current limiter may further include a predefined current limiting method, which may be used to perform current limiting processing on the service request.
In some possible implementations, the current limiting parameters of the current limiter of the preset service interface may be stored in a current limiter database, and the identification name of the unique identification of the current limiter is used as an index, so that the service end can obtain the current limiting parameters of the current limiter from the current limiter database.
Fig. 3 shows a flow diagram of one implementation of retrieving the flow restriction parameters of the flow restrictor from the flow restrictor database, as shown in fig. 3, may include step S310.
In step S310, the current limiting parameters are obtained from the current limiter database according to the identifier of the current limiter corresponding to the service interface.
In some possible implementations, in step S310, after determining the flow limiter corresponding to the service interface, an identifier name of a unique identifier of the flow limiter is determined, and the flow limiting parameter of the flow limiter is obtained by searching in the flow limiter database according to the identifier name as a search term.
In some possible implementations, the current limiter corresponding to the service interface is not stored in the current limiter database when the service interface is time due to storage errors and the like, that is, the current limiting parameters of the current limiter corresponding to the service interface are not stored in the current limiter data, the current limiting parameters of the current limiter corresponding to the service interface can be obtained through program reading and the like, and the unique identification name of the current limiter is used as retrieval, and the current limiting parameters of the current limiter are stored in the current limiter database.
Obviously, the speed and efficiency of acquiring the flow restriction parameters of the flow restrictor by database reading are higher than the flow restriction parameters of the flow restrictor by reading. The non-stored current limiter in the current limiter database is stored in the current limiter database, so that the current limiter database can be expanded, the current limiting parameters of the current limiter can be obtained through the current limiter database through the database reading when the current limiter is used again, and the efficiency of obtaining the current limiting parameters of the current limiter is improved.
In some possible implementations, after the current limiting parameters of the current limiter are obtained, the service request is processed according to the current limiting parameters.
Fig. 4 is a flow diagram of one implementation of processing a service request according to a throttling parameter in the case where the token bucket parameter includes the number of resource tokens remaining in the token bucket. As shown in fig. 4, step S410, step S420, step S430 may be included.
In step S410, the number of resource tokens required for the service request is acquired;
in step S420, the service request is accessed to the service interface if the number of resource tokens required by the service request is not greater than the number of resource tokens remaining in the token bucket;
in step S430, in the case that the number of resource tokens required for the service request is greater than the number of resource tokens remaining in the token bucket, the service request is subjected to the throttling process.
In some possible implementations, in step S410, the number of resource tokens required for the service request may be determined according to the traffic required for the service request and the traffic corresponding to each resource token.
In some possible implementations, the number of resource tokens required by the service request may also be preset by the client at the client, and the information included as the service request is sent to the server together with the service request.
In some possible implementations, in a case where the service request does not configure the required number of resource tokens, the default service request configured number of resource tokens of the service end may be used as the required number of resource tokens of the service request.
In some possible implementations, in step S420, if the number of resource tokens required by the service request is not greater than the number of remaining resource tokens in the token bucket, it is indicated that the number of remaining resource tokens in the token bucket can meet the requirement of the service request, that is, the service interface can normally process the service request, and there is no need to perform the throttling processing on the service request, so the service request can be directly accessed to the service interface.
In some possible implementations, in step S430, if the number of resource tokens required for the service request is greater than the number of remaining resource tokens in the token bucket, it is indicated that the number of remaining resource tokens in the token bucket cannot meet the requirement of the service request, that is, the service interface cannot normally process the service request, and the service request needs to be subjected to throttling processing.
In some possible implementations, the flow limiting processing of the service request may be to intercept the service request, end the service request in advance, and avoid the influence of the service request on the service interface.
In some possible implementations, in a case where the throttling parameter includes a predefined throttling method, the throttling the service request may be performed using the predefined throttling method.
Because the predefined flow limiting method is determined according to the attribute of the service function of the service interface, the influence on the service request and the service function of the service interface can be reduced to the greatest extent by using the predefined flow limiting method to perform flow limiting processing on the service request.
In some possible implementations, the number of resource tokens required by the service request may be compared with the size of the token bucket, where the number of resource tokens required by the service request is greater than the size of the token bucket, which indicates that if the service request is not subject to throttling or degradation, the resource tokens of the token bucket are not used and cannot meet the requirements of the service request, so that the traffic request may be directly subject to throttling or degradation.
In some possible implementations, step S430 may be continued after the number of resource tokens required to use the service request is compared with the size of the token bucket.
In some possible implementations, where the token bucket parameters include token bucket expiration time, it may be determined from the token bucket expiration time whether throttling or downgrading of the service request may be avoided by waiting for the token bucket to fill with tokens.
Fig. 5 shows a flow diagram of one specific implementation of determining whether waiting is needed according to the token bucket expiration time in the case that the token bucket parameters include the token bucket expiration time, and as shown in fig. 5, may include step S510 and step S520.
In step S510, when the number of resource tokens required by the service request is greater than the number of remaining resource tokens in the token bucket, obtaining a waiting time corresponding to the service request;
in step S520, in the case where the token bucket expiration time is greater than the waiting time, the traffic request is subjected to the flow limiting process.
In some possible implementations, in step S510, the waiting time corresponding to the service request may be preset by the client, and the server obtains the waiting time corresponding to the service request by parsing the service request along with sending the service request to the server.
The waiting time corresponding to the service request can also be set in the current limiting parameter of the current limiter.
In some possible implementations, if the token bucket expiration time is greater than the waiting time, in step S520, indicating that it is impossible to obtain enough tokens again within the waiting time, the service request may be directly rejected, or a predefined downgrading method may be invoked to downgrade the service request.
By judging the expiration time and the waiting time of the token bucket, invalid waiting of the service request can be reduced, and the processing efficiency of the service request is improved.
In some possible implementations, the method of request processing provided by the embodiments of the present disclosure may be implemented based on AOP (Aspect Oriented Programming, facet-tangent plane programming), i.e., after receiving a service request, before the service request accesses the service interface, the AOP facet logic is entered to perform the method of request processing provided by the embodiments of the present disclosure.
Through AOP, on one hand, the attention of a developer to the inside of the current limiter can be reduced, on the other hand, the multiplexing of codes can be reduced, and the maintenance difficulty and redundancy of the codes are reduced, so that the operation efficiency of current limiting and degradation is improved.
Fig. 6 is a process schematic diagram of a specific embodiment of a method for implementing request processing according to an embodiment of the present disclosure based on AOP, and as shown in fig. 6, the method for processing a request according to an embodiment of the present disclosure may be applied to a server cluster, where the server cluster may include multiple servers.
If the service end receives a service request initiated by a user through the client end and the corresponding service interface marks the use of the flow limiter, the service end enters AOP section logic before formally entering service processing of the service request, section codes are executed, and flow limiting verification is carried out.
Wherein the parameters of the flow restrictor may include: the restrictor uniquely identifies the name limiterName; token bucket size limit size; the token bucket expiration time limitexpire (refill the token bucket once it expires); the request requires token size permission; time timeout for which the request can wait (if the token is insufficient, allowing the request to retrieve the token within the timeout time); custom degradation method (optional parameters): if the token is not available, the downgrade method may be invoked by reflection or other means. If the downgrade method parameter is not set, the request is denied by default.
The server side sends a database request for obtaining the current limiting parameters of the current limiter to the current limiter database, if the current limiter database does not store the identified current limiter, the current limiter is initialized and filled with tokens, and meanwhile, a timing task is set or an expiration time is set (determined according to the type of the database).
And after obtaining the parameters of the flow limiter, entering flow limiting logic, judging whether the residual tokens of the token bucket meet the tokens required by the request, if yes, not entering flow limiting, accessing the service acquisition request into the service interface, taking the tokens, and normally executing the service method. If not, the token is not taken, whether the timeout parameter is set is checked, and if the update remaining waiting time is set, the token is reacquired. If timeout < limitexpire, it is stated that it is no longer possible to obtain enough tokens within the timeout, the custom demotion method is directly rejected or invoked.
In the event that no token is taken and the latency exceeds timeout, and the custom demotion method is configured, the custom demotion method is invoked by reflection or other means. If the custom degradation method is not configured, defaulting to rejection.
Based on the same principle as the method shown in fig. 1, fig. 7 shows a schematic structural diagram of an apparatus for processing a request provided by an embodiment of the present disclosure, and as shown in fig. 7, the apparatus 70 for processing a request may include:
a request receiving module 710, configured to determine a service interface corresponding to a service request in response to receiving the service request sent by the client;
The request processing module 720 is configured to obtain a flow limiting parameter of a flow limiter corresponding to the service interface, and process the service request according to the flow limiting parameter;
wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.
In the device for processing the request provided by the embodiment of the disclosure, the service request is processed by acquiring the current limiting parameters of the current limiter set by the service interface corresponding to the service request, and as different current limiters can be set by different service interfaces, different service interfaces can have different current limiting parameters to process the service request, so that different current limiting requirements of different service interfaces are met. Furthermore, in the device for processing a request provided in the embodiment of the present disclosure, the restrictor is a restrictor based on a token bucket algorithm, and processes a service request according to token bucket parameters of the restrictor, so that the service request can be subjected to flow limiting processing in time under the condition that the state of the token bucket does not satisfy the service request, and the service request processing efficiency of a service interface is improved.
In some possible implementations, the token bucket parameters include a number of resource tokens remaining in the token bucket; the request processing module 720 includes: the residual token unit is used for acquiring the number of resource tokens required by the service request; the interface access unit is used for accessing the service request to the service interface under the condition that the number of the resource tokens required by the service request is not more than the number of the residual resource tokens of the token bucket; and the flow limiting processing unit is used for carrying out flow limiting processing on the service request under the condition that the number of the resource tokens required by the service request is larger than the number of the residual resource tokens of the token bucket.
In some possible implementations, the token bucket parameters include token bucket expiration times; the current limiting processing unit includes: an expiration time subunit, configured to obtain a waiting time corresponding to the service request when the number of resource tokens required by the service request is greater than the number of remaining resource tokens in the token bucket; and carrying out flow limiting processing on the service request under the condition that the expiration time of the token bucket is longer than the waiting time.
In some possible implementations, the current limiting parameters include a predefined current limiting method; the flow limiting processing unit is used for carrying out flow limiting processing on the service request by using a predefined flow limiting method.
In some possible implementations, the request processing module 720 includes: the database unit is used for acquiring the current limiting parameters from the current limiter database according to the identifiers of the current limiters corresponding to the service interfaces; storing flow limiting parameters of at least one flow limiter in the flow limiter data; and the request processing unit is used for processing the service request according to the flow limiting parameters of the flow limiter corresponding to the service interface.
In some possible implementations, the database unit is further configured to: under the condition that the flow limiting parameters of the flow limiter corresponding to the service interface are not stored in the flow limiter database, the flow limiting parameters of the flow limiter corresponding to the service interface are obtained and stored in the flow limiter database.
In some possible implementations, the request processing module 720 is further configured to: based on the section-oriented programming access section, the flow limiting parameters of the flow limiter corresponding to the service interface are obtained, and the service request is processed according to the flow limiting parameters.
In some possible implementations, the apparatus for processing a request further includes: the flow limiter setting module is used for determining flow limiting parameters corresponding to the service interfaces according to the attributes of the service functions corresponding to the service interfaces; and setting a flow limiter for the service interface according to the flow limiting parameters.
It will be appreciated that the above-described modules of the apparatus for request processing in the embodiments of the present disclosure have functions of implementing the respective steps of the method for request processing in the embodiment shown in fig. 1. The functions can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above. The modules may be software and/or hardware, and each module may be implemented separately or may be implemented by integrating multiple modules. The functional description of each module of the above apparatus for processing a request may be specifically referred to the corresponding description of the method for processing a request in the embodiment shown in fig. 1, which is not repeated herein.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related user personal information all conform to the regulations of related laws and regulations, and the public sequence is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
The electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of request processing as provided by the embodiments of the present disclosure.
Compared with the prior art, the electronic equipment processes the service request by acquiring the current limiting parameters of the current limiter set by the service interface corresponding to the service request, and as different current limiters can be set by different service interfaces, different service interfaces can have different current limiting parameters to process the service request, and different current limiting requirements of different service interfaces are met. Furthermore, the flow limiter is based on a token bucket algorithm, and processes the service request according to token bucket parameters of the flow limiter, so that the flow limiting process can be performed on the service request in time under the condition that the state of the token bucket does not meet the service request, and the service request processing efficiency of the service interface is improved.
The readable storage medium is a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform a method of request processing as provided by embodiments of the present disclosure.
Compared with the prior art, the readable storage medium processes the service request by acquiring the flow limiting parameters of the flow limiter set by the service interface corresponding to the service request, and as different flow limiters can be set by different service interfaces, different service interfaces can have different flow limiting parameters to process the service request, and different flow limiting requirements of different service interfaces are met. Furthermore, the flow limiter is based on a token bucket algorithm, and processes the service request according to token bucket parameters of the flow limiter, so that the flow limiting process can be performed on the service request in time under the condition that the state of the token bucket does not meet the service request, and the service request processing efficiency of the service interface is improved.
The computer program product comprises a computer program which, when executed by a processor, implements a method of request processing as provided by embodiments of the present disclosure.
Compared with the prior art, the computer program product processes the service request by acquiring the flow limiting parameters of the flow limiter set by the service interface corresponding to the service request, and as different flow limiters can be set by different service interfaces, different service interfaces can have different flow limiting parameters to process the service request, and different flow limiting requirements of different service interfaces are met. Furthermore, the flow limiter is based on a token bucket algorithm, and processes the service request according to token bucket parameters of the flow limiter, so that the flow limiting process can be performed on the service request in time under the condition that the state of the token bucket does not meet the service request, and the service request processing efficiency of the service interface is improved.
Fig. 8 illustrates a schematic block diagram of an example electronic device 800 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 8, the apparatus 800 includes a computing unit 801 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 802 or a computer program loaded from a storage unit 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
Various components in device 800 are connected to I/O interface 805, including: an input unit 806 such as a keyboard, mouse, etc.; an output unit 807 such as various types of displays, speakers, and the like; a storage unit 808, such as a magnetic disk, optical disk, etc.; and a communication unit 809, such as a network card, modem, wireless communication transceiver, or the like. The communication unit 809 allows the device 800 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 801 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 801 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the method of service request provided by the embodiments of the present disclosure. For example, in some embodiments, the methods of service request provided by embodiments of the present disclosure may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 800 via ROM 802 and/or communication unit 809. When a computer program is loaded into RAM 803 and executed by computing unit 801, one or more steps of the method of service request described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured by any other suitable means (e.g., by means of firmware) to perform the method of service request provided by the embodiments of the present disclosure.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (19)

1. A method of request processing, comprising:
responding to a service request sent by a receiving client, and determining a service interface corresponding to the service request;
acquiring the current limiting parameters of the current limiter corresponding to the service interface, and processing the service request according to the current limiting parameters;
wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.
2. The method of claim 1, wherein the token bucket parameters comprise a number of token bucket remaining resource tokens;
the obtaining the current limiting parameter of the current limiter corresponding to the service interface, and processing the service request according to the current limiting parameter includes:
acquiring the number of resource tokens required by the service request;
accessing the service request to the service interface under the condition that the number of the resource tokens required by the service request is not greater than the number of the residual resource tokens of the token bucket;
and carrying out flow limiting processing on the service request under the condition that the number of the resource tokens required by the service request is larger than the number of the residual resource tokens of the token bucket.
3. The method of claim 2, wherein the token bucket parameters comprise token bucket expiration times;
and in the case that the number of the resource tokens required by the service request is greater than the number of the residual resource tokens of the token bucket, performing the flow limiting processing on the service request, including:
acquiring waiting time corresponding to the service request under the condition that the number of resource tokens required by the service request is larger than the number of residual resource tokens of the token bucket;
And carrying out flow limiting processing on the service request under the condition that the expiration time of the token bucket is longer than the waiting time.
4. The method of claim 2, wherein the current limiting parameter comprises a predefined current limiting method;
the flow limiting processing for the service request comprises the following steps: and carrying out flow limiting processing on the service request by using a predefined flow limiting method.
5. The method of claim 1, wherein the obtaining the current limiting parameter of the current limiter corresponding to the service interface, and processing the service request according to the current limiting parameter, comprises:
acquiring the current limiting parameters from a current limiter database according to the identifiers of the current limiters corresponding to the service interfaces; storing flow limiting parameters of at least one flow limiter in the flow limiter data;
and processing the service request according to the flow limiting parameters of the flow limiter corresponding to the service interface.
6. The method of claim 5, wherein the obtaining the current limiting parameter in the current limiter database according to the identifier of the current limiter corresponding to the service interface includes:
and under the condition that the current limiting parameters of the current limiter corresponding to the service interface are not stored in the current limiter database, acquiring the current limiting parameters of the current limiter corresponding to the service interface, and storing the current limiting parameters into the current limiter database.
7. The method of claim 1, wherein the obtaining the current limiting parameter of the current limiter corresponding to the service interface, and processing the service request according to the current limiting parameter, comprises:
and based on the cut-plane-oriented programming access cut plane, acquiring the flow limiting parameters of the flow limiter corresponding to the service interface, and processing the service request according to the flow limiting parameters.
8. The method of claim 1, wherein before the determining, in response to receiving the service request sent by the client, the service interface corresponding to the service request, further comprises:
determining the corresponding flow limiting parameters of the service interface according to the attribute of the service function corresponding to the service interface;
and setting a current limiter for the service interface according to the current limiting parameters.
9. An apparatus for request processing, comprising:
the request receiving module is used for responding to the received service request sent by the client and determining a service interface corresponding to the service request;
the request processing module is used for acquiring the flow limiting parameters of the flow limiter corresponding to the service interface and processing the service request according to the flow limiting parameters;
wherein the restrictor is a token bucket based restrictor, and the restrictor parameters of the restrictor include token bucket parameters of the restrictor.
10. The apparatus of claim 9, wherein the token bucket parameters comprise a number of token bucket remaining resource tokens;
the request processing module includes:
the residual token unit is used for acquiring the number of resource tokens required by the service request;
an interface access unit, configured to access the service request to the service interface when the number of resource tokens required by the service request is not greater than the number of remaining resource tokens in the token bucket;
and the flow limiting processing unit is used for carrying out flow limiting processing on the service request under the condition that the number of the resource tokens required by the service request is larger than the number of the residual resource tokens of the token bucket.
11. The apparatus of claim 10, wherein the token bucket parameters comprise token bucket expiration times;
the current limiting processing unit includes:
an expiration time subunit, configured to obtain a waiting time corresponding to the service request when the number of resource tokens required by the service request is greater than the number of remaining resource tokens in the token bucket; and carrying out flow limiting processing on the service request under the condition that the expiration time of the token bucket is longer than the waiting time.
12. The apparatus of claim 10, wherein the current limiting parameter comprises a predefined current limiting method;
the flow limiting processing unit is used for carrying out flow limiting processing on the service request by using a predefined flow limiting method.
13. The apparatus of claim 9, wherein the request processing module comprises:
the database unit is used for acquiring the current limiting parameters from a current limiter database according to the identifiers of the current limiters corresponding to the service interfaces; storing flow limiting parameters of at least one flow limiter in the flow limiter data;
and the request processing unit is used for processing the service request according to the flow limiting parameters of the flow limiter corresponding to the service interface.
14. The apparatus of claim 13, wherein the database unit is further configured to:
and under the condition that the current limiting parameters of the current limiter corresponding to the service interface are not stored in the current limiter database, acquiring the current limiting parameters of the current limiter corresponding to the service interface, and storing the current limiting parameters into the current limiter database.
15. The apparatus of claim 9, wherein the request processing module is further to:
and based on the cut-plane-oriented programming access cut plane, acquiring the flow limiting parameters of the flow limiter corresponding to the service interface, and processing the service request according to the flow limiting parameters.
16. The apparatus of claim 9, wherein the means for requesting processing further comprises:
the flow limiter setting module is used for determining flow limiting parameters corresponding to the service interfaces according to the attributes of the service functions corresponding to the service interfaces; and setting a current limiter for the service interface according to the current limiting parameters.
17. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
18. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-8.
19. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-8.
CN202311301607.9A 2023-10-09 2023-10-09 Method and device for processing request, electronic equipment and computer readable storage medium Pending CN117376263A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311301607.9A CN117376263A (en) 2023-10-09 2023-10-09 Method and device for processing request, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311301607.9A CN117376263A (en) 2023-10-09 2023-10-09 Method and device for processing request, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN117376263A true CN117376263A (en) 2024-01-09

Family

ID=89399541

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311301607.9A Pending CN117376263A (en) 2023-10-09 2023-10-09 Method and device for processing request, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN117376263A (en)

Similar Documents

Publication Publication Date Title
EP4167541A1 (en) Method and apparatus of configuring a cloud server resource, electronic device and medium
CN110650209A (en) Method and device for realizing load balance
CN115421922A (en) Current limiting method, device, equipment, medium and product of distributed system
CN113946816A (en) Cloud service-based authentication method and device, electronic equipment and storage medium
CN113778644A (en) Task processing method, device, equipment and storage medium
CN113761565B (en) Data desensitization method and device
CN116527652A (en) Method, device, equipment and medium for determining file format conversion path
CN117376263A (en) Method and device for processing request, electronic equipment and computer readable storage medium
WO2020000724A1 (en) Method, electronic device and medium for processing communication load between hosts of cloud platform
CN115550413A (en) Data calling method and device, service gateway and storage medium
CN113900731B (en) Request processing method, device, equipment and storage medium
CN113703793B (en) Application installation method, device, equipment and medium for cloud mobile phone
CN114374657A (en) Data processing method and device
CN113890906A (en) Call forwarding method and device, electronic equipment and computer readable storage medium
CN113535416A (en) Method and device for realizing reentrant distributed lock, electronic equipment and storage medium
CN112527802B (en) Soft link method and device based on key value database
CN113360258B (en) Data processing method, device, electronic equipment and storage medium
CN110933122A (en) Method, apparatus, and computer storage medium for managing server
CN115840604B (en) Data processing method, device, electronic equipment and computer readable storage medium
CN116915711A (en) Method, device, equipment and storage medium for expanding and protecting downstream service of dispatch service
CN117632545A (en) Data sharing method and device of business system and electronic equipment
CN115801763A (en) File transmission method and device, electronic equipment and storage medium
CN115915113A (en) Method and device for determining number segment association equipment and storage medium
CN117149402A (en) Task response method, device and equipment under microkernel operating system
CN116032686A (en) Multi-terminal data interaction method, device and equipment

Legal Events

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