CN112612618A - Interface current limiting method and device, computer equipment and storage medium - Google Patents

Interface current limiting method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112612618A
CN112612618A CN202011621616.2A CN202011621616A CN112612618A CN 112612618 A CN112612618 A CN 112612618A CN 202011621616 A CN202011621616 A CN 202011621616A CN 112612618 A CN112612618 A CN 112612618A
Authority
CN
China
Prior art keywords
current limiting
interface
target
configuration information
abnormal
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.)
Granted
Application number
CN202011621616.2A
Other languages
Chinese (zh)
Other versions
CN112612618B (en
Inventor
陈斌
金向平
罗强
倪军强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Home Cloud Network Technology Co ltd
Original Assignee
Shenzhen Home Cloud Network 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 Shenzhen Home Cloud Network Technology Co ltd filed Critical Shenzhen Home Cloud Network Technology Co ltd
Priority to CN202011621616.2A priority Critical patent/CN112612618B/en
Publication of CN112612618A publication Critical patent/CN112612618A/en
Application granted granted Critical
Publication of CN112612618B publication Critical patent/CN112612618B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to an interface current limiting method, an interface current limiting device, computer equipment and a storage medium. The method comprises the following steps: receiving a browser request; acquiring target client type information corresponding to a browser request; selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information; and carrying out current limiting processing on the target interface according to the target current limiting configuration information. By adopting the method, the current limiting efficiency of the interface can be improved.

Description

Interface current limiting method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for limiting a current of an interface, a computer device, and a storage medium.
Background
With the development of computer technology, interface throttling technology has emerged, and the purpose of interface throttling is to protect the system by throttling concurrent access requests or throttling the number of requests within a time window, and once the limiting rate is reached, service, queuing or waiting can be denied. In the conventional technology, a uniform current limiting threshold is usually adopted to limit current of a certain interface. However, in the service of tobasas, the service data magnitudes of different clients are greatly different, the data volumes of some clients are large, and the performance of the corresponding interfaces is poor, so that the same interface has different performance performances when operated by different clients, and the current limiting policy is not effective due to the use of a uniform current limiting threshold, thereby causing the current limiting efficiency of the interface to be low.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an interface current limiting method, an apparatus, a computer device, and a storage medium capable of improving current limiting efficiency of an interface.
A method of interface throttling, the method comprising:
receiving a browser request;
acquiring target client type information corresponding to the browser request;
selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and carrying out current limiting processing on a target interface according to the target current limiting configuration information.
In one embodiment, the obtaining target client type information corresponding to the browser request includes:
acquiring a request context corresponding to the browser request through an interceptor;
and extracting target client type information corresponding to the browser request from the request context.
In one embodiment, the method further comprises:
acquiring a performance evaluation value of an interface;
determining an interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface;
and generating candidate current limiting configuration information corresponding to the client type information according to the interface current limiting threshold value.
In one embodiment, the method further comprises:
monitoring the performance index of the server in real time;
when the server performance index is abnormal, determining an abnormal service thread according to the abnormal type of the server performance index;
and adjusting the current limiting configuration information of the interface corresponding to the abnormal service thread.
In one embodiment, the determining an abnormal service thread according to the abnormal type of the server performance indicator includes:
when the abnormal type of the server performance index is CPU abnormal, scanning the CPU occupation proportion of all threads, if the thread occupying the highest CPU is a service thread, taking the service thread occupying the highest CPU as an abnormal service thread, and if the thread occupying the highest CPU is a non-service thread, taking the service thread with the longest execution time as the abnormal service thread;
and when the abnormal type of the server performance index is memory abnormality or thread abnormality, taking the service thread with the longest execution time as an abnormal service thread.
In one embodiment, the performing, according to the target current limiting configuration information, current limiting processing on a target interface includes:
determining a total number of requests of the browser request received by the target interface within a time window;
when the total request times of the browser request meet an interface current limiting threshold value in the target current limiting configuration information, performing current limiting processing on a target interface according to the interface current limiting threshold value;
and judging whether the total request times of the browser requests meet an interface current limiting threshold value in the target current limiting configuration information or not, wherein the adopted current limiting algorithm is a token bucket current limiting algorithm or a counter current limiting algorithm.
In one embodiment, after receiving the browser request, the method further includes:
responding to the browser request, and establishing a corresponding asynchronous query task;
and sending the task identifier of the asynchronous query task to a query terminal to indicate the query terminal to query a corresponding query result from a cache of a server based on the task identifier.
An interface current limiting device, the device comprising:
the receiving module is used for receiving a browser request;
the acquisition module is used for acquiring target client type information corresponding to the browser request;
the selection module is used for selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and the current limiting module is used for carrying out current limiting processing on a target interface according to the target current limiting configuration information.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
receiving a browser request;
acquiring target client type information corresponding to the browser request;
selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and carrying out current limiting processing on a target interface according to the target current limiting configuration information.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
receiving a browser request;
acquiring target client type information corresponding to the browser request;
selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and carrying out current limiting processing on a target interface according to the target current limiting configuration information.
The interface current limiting method, the device, the computer equipment and the storage medium receive a browser request; acquiring target client type information corresponding to a browser request; selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information; and carrying out current limiting processing on the target interface according to the target current limiting configuration information. Therefore, according to different target client types, the same interface is configured with the current limiting strategy which is adaptive to the target client type, and the current limiting processing is carried out on the interface based on the adaptive current limiting strategy. Compared with the traditional interface current limiting mode which uses a uniform current limiting threshold value for different target client types, the method ensures the high-efficiency execution of the current limiting strategy and improves the current limiting efficiency of the interface.
Drawings
FIG. 1 is a diagram illustrating an exemplary embodiment of a method for interface throttling;
FIG. 2 is a flow chart illustrating a method for interface throttling according to an embodiment;
FIG. 3 is a flow diagram illustrating exception thread query in one embodiment;
FIG. 4 is a timing diagram of asynchronous queries in one embodiment;
FIG. 5 is a flow chart illustrating a method for interface throttling in another embodiment;
FIG. 6 is a block diagram of an embodiment of an interface current limiting device;
FIG. 7 is a block diagram of an interface current limiting device according to another embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further 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 present application and are not intended to limit the present application.
The interface current limiting method provided by the application can be applied to the application environment shown in fig. 1. The application environment includes a query terminal 102 and a server 104. Query terminal 102 communicates with server 104 over a network. The query terminal 102 may specifically include a desktop terminal or a mobile terminal. The mobile terminal may specifically include at least one of a mobile phone, a tablet computer, a notebook computer, and the like. The server 104 may be implemented as a stand-alone server or as a server cluster comprised of multiple servers. Those skilled in the art will understand that the application environment shown in fig. 1 is only a part of the scenario related to the present application, and does not constitute a limitation to the application environment of the present application.
The server 104 receives the browser request sent by the query terminal 102, and acquires target client type information corresponding to the browser request. The server 104 selects target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information, and performs current limiting processing on a target interface according to the target current limiting configuration information.
In one embodiment, as shown in fig. 2, an interface throttling method is provided, which is described by taking the method as an example applied to the server 104 in fig. 1, and includes the following steps:
s202, a browser request is received.
Specifically, the query terminal may generate a browser request, please send the browser request to the server. The server may receive a browser request.
S204, obtaining the target client type information corresponding to the browser request.
The client type information is level information to which the client belongs, and for example, the client type may include a system level, an enterprise level, a user level, and the like. The target client type information is level information to which the client corresponding to the browser request belongs.
Specifically, the server may obtain the request context according to the browser request, and request the context to obtain the target client type information corresponding to the browser request.
S206, selecting the target current limiting configuration information matched with the target client type information from the preset candidate current limiting configuration information.
Specifically, the cache of the server stores candidate current limiting configuration information corresponding to each client type information. After obtaining the target client type information, the server may select target current limiting configuration information matching the target client type information from the cached candidate current limiting configuration information.
And S208, carrying out current limiting processing on the target interface according to the target current limiting configuration information.
Specifically, the target current limiting configuration information may include an interface current limiting threshold, and the server may perform current limiting processing on the target interface according to the interface current limiting threshold in the target current limiting configuration information.
In the interface current limiting method, a browser request is received; acquiring target client type information corresponding to a browser request; selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information; and carrying out current limiting processing on the target interface according to the target current limiting configuration information. Therefore, according to different target client types, the same interface is configured with the current limiting strategy which is adaptive to the target client type, and the current limiting processing is carried out on the interface based on the adaptive current limiting strategy. Compared with the traditional interface current limiting mode which uses a uniform current limiting threshold value for different target client types, the method ensures the high-efficiency execution of the current limiting strategy and improves the current limiting efficiency of the interface.
In an embodiment, the step S204, that is, the step of obtaining the target client type information corresponding to the browser request, specifically includes: acquiring a request context corresponding to a browser request through an interceptor; target client type information corresponding to the browser request is extracted from the request context.
Specifically, after receiving a browser request sent by an inquiry terminal, a server may obtain a session message of the request through an interceptor, and obtain a request context corresponding to the browser request through the session message. The request context may include client type information, business thread identification, and interface information. In turn, the server may extract target client type information corresponding to the browser request from the request context.
In one embodiment, the session message may be a session id or TOKEN.
In the embodiment, the obtaining efficiency of the target client type information is improved by obtaining the request context and extracting the target client type information from the request context.
In one embodiment, the interface current limiting method further includes: acquiring a performance evaluation value of an interface; determining an interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface; and generating candidate current limiting configuration information corresponding to the client type information according to the interface current limiting threshold value.
Specifically, the developer may perform performance evaluation on each interface according to experience, and set the performance evaluation value of the interface. The server can obtain the performance evaluation value of the interface and determine the interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface. It is understood that the higher the performance evaluation value of the interface is, the higher the determined interface current limit threshold corresponding to the client type information may be. Further, the server may generate candidate throttling configuration information corresponding to the client type information according to the interface throttling threshold.
In the above embodiment, the interface current limiting threshold is determined by the performance evaluation value of the interface, so that the interface current limiting threshold is more reasonable, and the interface efficiency is further improved.
In one embodiment, the interface current limiting method further includes: monitoring the performance index of the server in real time; when the performance index of the server is abnormal, determining an abnormal service thread according to the abnormal type of the performance index of the server; and adjusting the current limiting configuration information of the interface corresponding to the abnormal service thread.
Specifically, the server may monitor the server performance index in real time through the monitoring task, and when the server performance index is abnormal, for example, the server performance index exceeds a set warning threshold, the server may determine, according to the abnormal type of the server performance index, an abnormal service thread that causes the server performance index to be abnormal. The server may determine an interface corresponding to the abnormal traffic thread and adjust current limiting configuration information of the interface corresponding to the abnormal traffic thread.
In one embodiment, the server performance metrics may include CPU (Central Processing Unit), memory, and thread count.
In the above embodiment, the performance index of the server is monitored in real time, so that the performance state of the server is known in real time, and further when the performance index of the server is abnormal, the abnormal service thread can be determined in time, the current limiting configuration information of the interface corresponding to the abnormal service thread is adjusted, and the current limiting efficiency of the interface is further improved.
In one embodiment, the step of determining the abnormal service thread according to the abnormal type of the server performance index specifically includes: when the abnormal type of the performance index of the server is CPU abnormal, scanning the CPU occupation proportion of all threads, if the thread occupying the highest CPU is a service thread, taking the service thread occupying the highest CPU as an abnormal service thread, and if the thread occupying the highest CPU is a non-service thread, taking the service thread with the longest execution time as the abnormal service thread; and when the abnormal type of the server performance index is memory abnormality or thread abnormality, taking the service thread with the longest execution time as an abnormal service thread.
The business thread refers to a thread processing business logic, and the non-business thread refers to a thread not processing the business logic.
Specifically, in one embodiment, as shown in fig. 3, the server may monitor the performance index of the server in real time through the monitoring task, and when the type of the abnormality of the performance index of the server is CPU abnormality, the server may scan the CPU occupation ratios of all threads. The type of the thread is different, the name format of the thread is different, and the server can determine a business thread and a non-business thread according to the name format of the thread. If the thread occupying the highest CPU is a service thread, the server can take the service thread occupying the highest CPU as an abnormal service thread, and if the thread occupying the highest CPU is a non-service thread, the server can take the service thread with the longest execution time as the abnormal service thread. When the abnormal type of the server performance index is memory abnormality or thread abnormality, the server can take the service thread with the longest execution time as an abnormal service thread. The server can find the corresponding request context according to the ID of the service thread, namely the service thread identifier, and further, the server can determine the interface information according to the request context, determine the corresponding interface and dynamically adjust the current-limiting configuration information for the corresponding interface as the request context comprises the client type information, the service thread identifier and the interface information.
In one embodiment, the non-business threads may include GC (Garbage Collection) threads, HTTP (Hypertext Transfer Protocol) asynchronous cleaning threads, and the like.
In the embodiment, the abnormal service thread is quickly inquired through different abnormal types of the performance indexes of the server, so that the interface current limiting threshold value of the abnormal interface corresponding to the abnormal service thread can be adjusted in time. The current limiting efficiency of the interface is further improved by dynamically adjusting the current limiting threshold of the interface.
In an embodiment, step S208, namely, the step of performing current limiting processing on the target interface according to the target current limiting configuration information specifically includes: determining the total number of requests of the browser requests received by the target interface in the time window; when the total request times of the browser request meet an interface current limiting threshold value in the target current limiting configuration information, performing current limiting processing on a target interface according to the interface current limiting threshold value; the current limiting algorithm adopted for judging whether the total request times of the browser requests meet the interface current limiting threshold value in the target current limiting configuration information is a token bucket current limiting algorithm or a counter current limiting algorithm.
Specifically, the server may count the total request times of the browser requests received by the target interface within the time window, and compare the total request times of the browser requests with the interface current limiting threshold in the target current limiting configuration information. When the total request times of the browser request meet the interface current limiting threshold value in the target current limiting configuration information, the server can perform current limiting processing on the target interface according to the interface current limiting threshold value. The current limiting algorithm adopted for judging whether the total request times of the browser requests meet the interface current limiting threshold value in the target current limiting configuration information is a token bucket current limiting algorithm or a counter current limiting algorithm.
It can be understood that if the throttling algorithm is the token bucket throttling algorithm, a value corresponding to an interface throttling threshold is stored in the cache during initialization, the cache value is decremented by 1 every time the server receives a browser request, if a browser request is processed, the cache value is incremented by 1, and when the cache value is decremented to 0, the browser request is limited. If the current limiting algorithm is the counter current limiting algorithm, conversely, when a browser request is received, the initialization value of the server cache is 0, when a browser request is received, the cache value is added with 1, and when the cache value reaches the interface current limiting threshold value, the browser request is limited.
In one embodiment, either the token bucket throttling algorithm or the counter throttling algorithm may be implemented by a distributed cache Redis (Remote Dictionary Server).
In the above embodiment, the total number of requests of the browser request received in the time window is compared with the interface current limiting threshold in the target current limiting configuration information, and the current limiting processing is performed on the target interface according to the interface current limiting threshold, so that the interface current limiting efficiency is improved. Whether the total number of requests requested by the browser meets an interface current limiting threshold value in the target current limiting configuration information is judged through a token bucket current limiting algorithm or a counter current limiting algorithm, so that the current limiting algorithm is more flexible to use.
In an embodiment, in step S202, that is, after the step of receiving the browser request, the interface throttling method specifically further includes: responding to a browser request, and establishing a corresponding asynchronous query task; and sending the task identifier of the asynchronous query task to the query terminal to instruct the query terminal to query the corresponding query result from the cache of the server based on the task identifier.
Specifically, the server may respond to the browser request, establish a corresponding asynchronous query task, and send a task identifier of the asynchronous query task to the query terminal. Meanwhile, the server can execute asynchronous query tasks and cache query results. The query terminal can query the corresponding query result from the cache of the server based on the task identifier.
In one embodiment, as shown in FIG. 4, a browser may be run in the query terminal, and a Web (World Wide Web) application and an asynchronous query task application may be run in the server. The query terminal can send a browser request to the web application through the browser, and the web application can initiate asynchronous query task calling to the asynchronous query task application after receiving the browser request and return the corresponding task identifier to the browser. Meanwhile, the server can execute asynchronous query tasks and write query results into the cache. The browser can obtain the query result from the cache of the server according to the task identifier. And if the browser does not inquire the inquiry result corresponding to the task identifier, re-inquiring at an interval of 3 seconds until the corresponding inquiry result is obtained.
In the embodiment, the performance problems of the interfaces are reflected on the server side in a centralized manner by executing the asynchronous query task, so that the performance problems of the interfaces are prevented from being reflected on the query terminal side, the centralized discovery and processing of the performance problems of the interfaces are facilitated, and the interface current limiting efficiency is further improved.
In one embodiment, as shown in fig. 5, the server may generate and cache candidate current limiting configuration information according to the performance evaluation value of the interface through the console, and it may be understood that the candidate current limiting configuration information is stored in a bound manner with corresponding client type information. When the server receives a browser request sent by the inquiry terminal, the request context of the interface can be obtained through the interceptor. The server can obtain the target client type information according to the request context and obtain the corresponding target current limiting configuration information from the cache. The server can judge whether the total request times of the browser requests received by the corresponding interface in the time window exceed the interface current limiting threshold value according to the target current limiting configuration information. And when the total request times of the browser request exceed the interface current limiting threshold, carrying out current limiting processing or directly carrying out fusing processing on the interface. Meanwhile, when the server monitors that the application is started, the performance monitoring timing task can be started at the same time, and the performance index of the server is monitored through the performance monitoring timing task. The server can screen out the interface associated with the abnormal service thread according to the performance index of the server, and dynamically adjust the interface corresponding to the interface to adjust the current-limiting configuration information.
It should be understood that although the various steps of fig. 2 are shown in order, the steps are not necessarily performed in order. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in fig. 2 may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 6, there is provided an interface current limiting apparatus 600, including: a receiving module 601, an obtaining module 602, a selecting module 603 and a current limiting module 604, wherein:
the receiving module 601 is configured to receive a browser request.
An obtaining module 602, configured to obtain target client type information corresponding to the browser request.
A selecting module 603, configured to select target current limiting configuration information matching the target client type information from preset candidate current limiting configuration information.
And the current limiting module 604 is configured to perform current limiting processing on the target interface according to the target current limiting configuration information.
In one embodiment, the obtaining module 602 is further configured to obtain, through the interceptor, a request context corresponding to the browser request; target client type information corresponding to the browser request is extracted from the request context.
In one embodiment, the current limit module 604 is further configured to determine a total number of requests of the browser request received by the target interface within a time window; when the total request times of the browser request meet an interface current limiting threshold value in the target current limiting configuration information, performing current limiting processing on a target interface according to the interface current limiting threshold value; the current limiting algorithm adopted for judging whether the total request times of the browser requests meet the interface current limiting threshold value in the target current limiting configuration information is a token bucket current limiting algorithm or a counter current limiting algorithm.
Referring to fig. 7, in one embodiment, the interface current limiting apparatus 600 further includes: a generation module 605, an adjustment module 606, and a query module 607, wherein:
a generating module 605, configured to obtain a performance evaluation value of the interface; determining an interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface; and generating candidate current limiting configuration information corresponding to the client type information according to the interface current limiting threshold value.
An adjusting module 606, configured to monitor a server performance index in real time; when the performance index of the server is abnormal, determining an abnormal service thread according to the abnormal type of the performance index of the server; and adjusting the current limiting configuration information of the interface corresponding to the abnormal service thread.
A query module 607, configured to respond to a browser request and establish a corresponding asynchronous query task; and sending the task identifier of the asynchronous query task to the query terminal to instruct the query terminal to query the corresponding query result from the cache of the server based on the task identifier.
In one embodiment, the adjusting module 606 is further configured to scan CPU occupation ratios of all threads when the exception type of the server performance index is CPU exception, if the thread occupying the highest CPU is a service thread, take the service thread occupying the highest CPU as an exception service thread, and if the thread occupying the highest CPU is a non-service thread, take the service thread having the longest execution time as an exception service thread; and when the abnormal type of the server performance index is memory abnormality or thread abnormality, taking the service thread with the longest execution time as an abnormal service thread.
The interface current limiting device receives a browser request; acquiring target client type information corresponding to a browser request; selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information; and carrying out current limiting processing on the target interface according to the target current limiting configuration information. Therefore, according to different target client types, the same interface is configured with the current limiting strategy which is adaptive to the target client type, and the current limiting processing is carried out on the interface based on the adaptive current limiting strategy. Compared with the traditional interface current limiting mode which uses a uniform current limiting threshold value for different target client types, the method ensures the high-efficiency execution of the current limiting strategy and improves the current limiting efficiency of the interface.
For specific limitations of the interface current limiting device, reference may be made to the above limitations of the interface current limiting method, which is not described herein again. The modules in the interface current limiting device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be the server 104 in fig. 1 described above, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing interface current limiting data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an interface current limiting method.
Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
receiving a browser request;
acquiring target client type information corresponding to a browser request;
selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and carrying out current limiting processing on the target interface according to the target current limiting configuration information.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring a request context corresponding to a browser request through an interceptor;
target client type information corresponding to the browser request is extracted from the request context.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring a performance evaluation value of an interface;
determining an interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface;
and generating candidate current limiting configuration information corresponding to the client type information according to the interface current limiting threshold value.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
monitoring the performance index of the server in real time;
when the performance index of the server is abnormal, determining an abnormal service thread according to the abnormal type of the performance index of the server;
and adjusting the current limiting configuration information of the interface corresponding to the abnormal service thread.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
when the abnormal type of the performance index of the server is CPU abnormal, scanning the CPU occupation proportion of all threads, if the thread occupying the highest CPU is a service thread, taking the service thread occupying the highest CPU as an abnormal service thread, and if the thread occupying the highest CPU is a non-service thread, taking the service thread with the longest execution time as the abnormal service thread;
and when the abnormal type of the server performance index is memory abnormality or thread abnormality, taking the service thread with the longest execution time as an abnormal service thread.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
determining the total number of requests of the browser requests received by the target interface in the time window;
when the total request times of the browser request meet an interface current limiting threshold value in the target current limiting configuration information, performing current limiting processing on a target interface according to the interface current limiting threshold value;
the current limiting algorithm adopted for judging whether the total request times of the browser requests meet the interface current limiting threshold value in the target current limiting configuration information is a token bucket current limiting algorithm or a counter current limiting algorithm.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
responding to a browser request, and establishing a corresponding asynchronous query task;
and sending the task identifier of the asynchronous query task to the query terminal to instruct the query terminal to query the corresponding query result from the cache of the server based on the task identifier.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
receiving a browser request;
acquiring target client type information corresponding to a browser request;
selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and carrying out current limiting processing on the target interface according to the target current limiting configuration information.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a request context corresponding to a browser request through an interceptor;
target client type information corresponding to the browser request is extracted from the request context.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a performance evaluation value of an interface;
determining an interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface;
and generating candidate current limiting configuration information corresponding to the client type information according to the interface current limiting threshold value.
In one embodiment, the computer program when executed by the processor further performs the steps of:
monitoring the performance index of the server in real time;
when the performance index of the server is abnormal, determining an abnormal service thread according to the abnormal type of the performance index of the server;
and adjusting the current limiting configuration information of the interface corresponding to the abnormal service thread.
In one embodiment, the computer program when executed by the processor further performs the steps of:
when the abnormal type of the performance index of the server is CPU abnormal, scanning the CPU occupation proportion of all threads, if the thread occupying the highest CPU is a service thread, taking the service thread occupying the highest CPU as an abnormal service thread, and if the thread occupying the highest CPU is a non-service thread, taking the service thread with the longest execution time as the abnormal service thread;
and when the abnormal type of the server performance index is memory abnormality or thread abnormality, taking the service thread with the longest execution time as an abnormal service thread.
In one embodiment, the computer program when executed by the processor further performs the steps of:
determining the total number of requests of the browser requests received by the target interface in the time window;
when the total request times of the browser request meet an interface current limiting threshold value in the target current limiting configuration information, performing current limiting processing on a target interface according to the interface current limiting threshold value;
the current limiting algorithm adopted for judging whether the total request times of the browser requests meet the interface current limiting threshold value in the target current limiting configuration information is a token bucket current limiting algorithm or a counter current limiting algorithm.
In one embodiment, the computer program when executed by the processor further performs the steps of:
responding to a browser request, and establishing a corresponding asynchronous query task;
and sending the task identifier of the asynchronous query task to the query terminal to instruct the query terminal to query the corresponding query result from the cache of the server based on the task identifier.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. An interface current limiting method, the method comprising:
receiving a browser request;
acquiring target client type information corresponding to the browser request;
selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and carrying out current limiting processing on a target interface according to the target current limiting configuration information.
2. The method of claim 1, wherein obtaining target client type information corresponding to the browser request comprises:
acquiring a request context corresponding to the browser request through an interceptor;
and extracting target client type information corresponding to the browser request from the request context.
3. The method of claim 1, further comprising:
acquiring a performance evaluation value of an interface;
determining an interface current limiting threshold corresponding to the client type information according to the performance evaluation value of the interface;
and generating candidate current limiting configuration information corresponding to the client type information according to the interface current limiting threshold value.
4. The method of claim 3, further comprising:
monitoring the performance index of the server in real time;
when the server performance index is abnormal, determining an abnormal service thread according to the abnormal type of the server performance index;
and adjusting the current limiting configuration information of the interface corresponding to the abnormal service thread.
5. The method of claim 4, wherein determining an abnormal business thread according to the abnormal type of the server performance indicator comprises:
when the abnormal type of the server performance index is CPU abnormal, scanning the CPU occupation proportion of all threads, if the thread occupying the highest CPU is a service thread, taking the service thread occupying the highest CPU as an abnormal service thread, and if the thread occupying the highest CPU is a non-service thread, taking the service thread with the longest execution time as the abnormal service thread;
and when the abnormal type of the server performance index is memory abnormality or thread abnormality, taking the service thread with the longest execution time as an abnormal service thread.
6. The method of claim 3, wherein the throttling the target interface according to the target throttling configuration information comprises:
determining a total number of requests of the browser request received by the target interface within a time window;
when the total request times of the browser request meet an interface current limiting threshold value in the target current limiting configuration information, performing current limiting processing on a target interface according to the interface current limiting threshold value;
and judging whether the total request times of the browser requests meet an interface current limiting threshold value in the target current limiting configuration information or not, wherein the adopted current limiting algorithm is a token bucket current limiting algorithm or a counter current limiting algorithm.
7. The method of any of claims 1-6, wherein after receiving the browser request, the method further comprises:
responding to the browser request, and establishing a corresponding asynchronous query task;
and sending the task identifier of the asynchronous query task to a query terminal to indicate the query terminal to query a corresponding query result from a cache of a server based on the task identifier.
8. An interface current limiting apparatus, comprising:
the receiving module is used for receiving a browser request;
the acquisition module is used for acquiring target client type information corresponding to the browser request;
the selection module is used for selecting target current limiting configuration information matched with the target client type information from preset candidate current limiting configuration information;
and the current limiting module is used for carrying out current limiting processing on a target interface according to the target current limiting configuration information.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 7 are implemented by the processor when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202011621616.2A 2020-12-30 2020-12-30 Interface current limiting method and device, computer equipment and storage medium Active CN112612618B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011621616.2A CN112612618B (en) 2020-12-30 2020-12-30 Interface current limiting method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011621616.2A CN112612618B (en) 2020-12-30 2020-12-30 Interface current limiting method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112612618A true CN112612618A (en) 2021-04-06
CN112612618B CN112612618B (en) 2022-07-19

Family

ID=75249514

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011621616.2A Active CN112612618B (en) 2020-12-30 2020-12-30 Interface current limiting method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112612618B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113489702A (en) * 2021-06-29 2021-10-08 网易(杭州)网络有限公司 Interface current limiting method and device and electronic equipment
CN114553791A (en) * 2022-01-19 2022-05-27 浙江百应科技有限公司 External interface current limiting method and device, electronic equipment and storage medium
CN114979012A (en) * 2022-05-31 2022-08-30 济南浪潮数据技术有限公司 Network flow current limiting method, system, device and computer storage medium
CN115118785A (en) * 2022-08-29 2022-09-27 太平金融科技服务(上海)有限公司深圳分公司 Server resource protection method, apparatus, device, medium, and program product
CN115190177A (en) * 2022-07-29 2022-10-14 中国工商银行股份有限公司 Request processing method, apparatus, computer device, storage medium, and program product
CN115190177B (en) * 2022-07-29 2024-06-04 中国工商银行股份有限公司 Request processing method, apparatus, computer device, storage medium, and program product

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8392558B1 (en) * 2011-03-22 2013-03-05 Amazon Technologies, Inc. System and method for determining overload state for service requests
US20170272371A1 (en) * 2016-03-21 2017-09-21 Alibaba Group Holding Limited Flow control in connection with an access request
CN108306874A (en) * 2018-01-29 2018-07-20 口碑(上海)信息技术有限公司 Service interface accesses current-limiting method and device
CN108418764A (en) * 2018-02-07 2018-08-17 深圳壹账通智能科技有限公司 Current-limiting method, device, computer equipment and storage medium
CN108566304A (en) * 2018-04-26 2018-09-21 努比亚技术有限公司 Interface control method, electronic equipment and computer readable storage medium
CN109787908A (en) * 2018-12-13 2019-05-21 平安普惠企业管理有限公司 Server current-limiting method, system, computer equipment and storage medium
CN110224943A (en) * 2019-05-29 2019-09-10 掌阅科技股份有限公司 Traffic service current-limiting method, electronic equipment and computer storage medium based on URL
CN110611623A (en) * 2019-08-30 2019-12-24 江苏苏宁物流有限公司 Current limiting method and device
CN110753131A (en) * 2019-11-04 2020-02-04 网易(杭州)网络有限公司 Microservice distributed current limiting method and device, storage medium and electronic equipment
CN111443962A (en) * 2020-03-31 2020-07-24 海南新软软件有限公司 Transaction limiting method and device
CN111447150A (en) * 2020-02-29 2020-07-24 中国平安财产保险股份有限公司 Access request current limiting method, server and storage medium
CN111478857A (en) * 2019-01-24 2020-07-31 北京嘀嘀无限科技发展有限公司 Interface current limiting control method and device and electronic equipment

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8392558B1 (en) * 2011-03-22 2013-03-05 Amazon Technologies, Inc. System and method for determining overload state for service requests
US20170272371A1 (en) * 2016-03-21 2017-09-21 Alibaba Group Holding Limited Flow control in connection with an access request
CN108306874A (en) * 2018-01-29 2018-07-20 口碑(上海)信息技术有限公司 Service interface accesses current-limiting method and device
CN108418764A (en) * 2018-02-07 2018-08-17 深圳壹账通智能科技有限公司 Current-limiting method, device, computer equipment and storage medium
CN108566304A (en) * 2018-04-26 2018-09-21 努比亚技术有限公司 Interface control method, electronic equipment and computer readable storage medium
CN109787908A (en) * 2018-12-13 2019-05-21 平安普惠企业管理有限公司 Server current-limiting method, system, computer equipment and storage medium
CN111478857A (en) * 2019-01-24 2020-07-31 北京嘀嘀无限科技发展有限公司 Interface current limiting control method and device and electronic equipment
CN110224943A (en) * 2019-05-29 2019-09-10 掌阅科技股份有限公司 Traffic service current-limiting method, electronic equipment and computer storage medium based on URL
CN110611623A (en) * 2019-08-30 2019-12-24 江苏苏宁物流有限公司 Current limiting method and device
CN110753131A (en) * 2019-11-04 2020-02-04 网易(杭州)网络有限公司 Microservice distributed current limiting method and device, storage medium and electronic equipment
CN111447150A (en) * 2020-02-29 2020-07-24 中国平安财产保险股份有限公司 Access request current limiting method, server and storage medium
CN111443962A (en) * 2020-03-31 2020-07-24 海南新软软件有限公司 Transaction limiting method and device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113489702A (en) * 2021-06-29 2021-10-08 网易(杭州)网络有限公司 Interface current limiting method and device and electronic equipment
CN114553791A (en) * 2022-01-19 2022-05-27 浙江百应科技有限公司 External interface current limiting method and device, electronic equipment and storage medium
CN114979012A (en) * 2022-05-31 2022-08-30 济南浪潮数据技术有限公司 Network flow current limiting method, system, device and computer storage medium
CN115190177A (en) * 2022-07-29 2022-10-14 中国工商银行股份有限公司 Request processing method, apparatus, computer device, storage medium, and program product
CN115190177B (en) * 2022-07-29 2024-06-04 中国工商银行股份有限公司 Request processing method, apparatus, computer device, storage medium, and program product
CN115118785A (en) * 2022-08-29 2022-09-27 太平金融科技服务(上海)有限公司深圳分公司 Server resource protection method, apparatus, device, medium, and program product

Also Published As

Publication number Publication date
CN112612618B (en) 2022-07-19

Similar Documents

Publication Publication Date Title
CN112612618B (en) Interface current limiting method and device, computer equipment and storage medium
CN107832126B (en) Thread adjusting method and terminal thereof
CN110489447B (en) Data query method and device, computer equipment and storage medium
CN110049130B (en) Service deployment and task scheduling method and device based on edge computing
CN108256114B (en) Document online preview method and device, computer equipment and storage medium
US20150213134A1 (en) Data query method and system and storage medium
CN110247856B (en) Server resource release method and device
CN110519409B (en) Domain name dynamic configuration method, device, equipment and storage medium
CN110471749B (en) Task processing method, device, computer readable storage medium and computer equipment
CN111800459A (en) Asynchronous processing method, device and system for download task and storage medium
CN108449237B (en) Network performance monitoring method and device, computer equipment and storage medium
CN111641563B (en) Flow self-adaption method and system based on distributed scene
CN112689007B (en) Resource allocation method, device, computer equipment and storage medium
CN110602169A (en) Service calling method and device, computer equipment and storage medium
CN110943934A (en) Service request processing method, system, terminal and readable storage medium
EP1762069B1 (en) Method of selecting one server out of a server set
CN112153170A (en) Method, device and equipment for accessing server and storage medium
CN109981779B (en) Service providing method, server and computer storage medium
CN110769045A (en) Data processing method, data processing device, computer equipment and storage medium
CN114465959A (en) Interface dynamic flow control method and device, computer equipment and storage medium
CN112969172B (en) Communication flow control method based on cloud mobile phone
CN114172892A (en) File uploading method and device
CN110648052B (en) Wind control decision method and device, computer equipment and storage medium
JPWO2021119216A5 (en)
CN111274029A (en) Cluster scheduling method and device

Legal Events

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