CN114048059A - Method and device for adjusting timeout time of interface, computer equipment and storage medium - Google Patents

Method and device for adjusting timeout time of interface, computer equipment and storage medium Download PDF

Info

Publication number
CN114048059A
CN114048059A CN202111432549.4A CN202111432549A CN114048059A CN 114048059 A CN114048059 A CN 114048059A CN 202111432549 A CN202111432549 A CN 202111432549A CN 114048059 A CN114048059 A CN 114048059A
Authority
CN
China
Prior art keywords
time
interface
target
timeout
request
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
CN202111432549.4A
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202111432549.4A priority Critical patent/CN114048059A/en
Publication of CN114048059A publication Critical patent/CN114048059A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • G06F11/0754Error or fault detection not based on redundancy by exceeding limits
    • G06F11/0757Error or fault detection not based on redundancy by exceeding limits by exceeding a time limit, i.e. time-out, e.g. watchdogs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection

Abstract

The embodiment of the application belongs to the technical field of internet, and relates to a method for adjusting timeout time of an interface, which comprises the steps of obtaining all interfaces corresponding to a received access request, reading first timeout time of all the interfaces, sending the access request to a server through the interfaces, pushing time-consuming data corresponding to the interfaces to a data storage end for storage and recording, obtaining time-consuming data of a target interface in a preset time period, calculating average request time consumption of the target interface based on the time-consuming data in the preset time period, determining an initial interface group where the target interface is located, sending the average request time consumption to the initial interface group, and adjusting the first timeout time of the target interface according to second timeout time and the average request time consumption of the initial interface group. The application also provides a timeout time adjusting device of the interface, computer equipment and a storage medium. In addition, the present application also relates to block chain techniques, where time consuming data can be stored. The method and the device can realize dynamic adjustment of the interface timeout time.

Description

Method and device for adjusting timeout time of interface, computer equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a method and an apparatus for adjusting timeout time of an interface, a computer device, and a storage medium.
Background
With the development of internet technology and the improvement of internet service capability, various system applications are developed vigorously, various data interactions exist among a plurality of systems, and the data access amount faced by a plurality of application services is also increased sharply. Application services usually access data through interfaces, and the whole micro service system usually has a uniform interface timeout setting, but the uniform default timeout setting cannot meet the requirements of some special service scenarios, such as: upload or download larger files, etc. If the overtime time is prolonged uniformly, the overtime fusing effect cannot be achieved, resource occupation is caused, and service blockage is caused.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for adjusting timeout of an interface, a computer device, and a storage medium, so as to solve the technical problem of uniform setting of timeout of an interface in the related art.
In order to solve the foregoing technical problem, an embodiment of the present application provides a method for adjusting timeout time of an interface, which adopts the following technical solutions:
receiving an access request, acquiring all interfaces corresponding to the access request, and reading first timeout time of all the interfaces;
according to the first timeout time, the access request is sent to a server through the interface, and time-consuming data corresponding to the interface is pushed to a data storage end to be stored and recorded;
determining a target interface, and acquiring time-consuming data of the target interface within a preset time period as target time-consuming data;
calculating the average request time consumption of the target interface in the preset time period based on the target time consumption data;
determining an initial interface group where the target interface is located, and sending the average request consumed time to the initial interface group;
and adjusting the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request consumed time.
Further, the step of determining a target interface and acquiring time-consuming data of the target interface within a preset time period as target time-consuming data includes:
according to a preset timing mechanism, when set time is reached, a timing task corresponding to the set time is obtained and used as a target timing task;
determining a target interface according to the execution parameters of the target timing task;
and acquiring the time-consuming data in the preset time period from the data storage terminal based on the target interface to serve as target time-consuming data.
Further, the step of determining an initial interface group where the target interface is located and sending the average request time consumption to the initial interface group includes:
acquiring interface parameters of the target interface, and acquiring an initial interface group where the target interface is located according to the interface parameters;
and packaging the interface parameters and the average request consumed time to a message queue, and sending the average request consumed time to the corresponding initial interface group through the message queue.
Further, the step of adjusting the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request elapsed time includes:
comparing the second timeout time to the average request elapsed time;
when the average request consumed time is not within the second timeout time range, inquiring a corresponding target interface group according to the average request consumed time;
adjusting the target interface from the initial interface group to the target interface group.
Further, after the step when the average request elapsed time is not within the second timeout time range, the method further comprises:
determining whether the associated party corresponding to the target timing task is abnormal;
and when the correlation party is abnormal, determining whether to adjust the target interface to the target interface group according to the priority of the target timing task.
Further, after the step of sending the access request to the server through the interface, the method further includes:
and acquiring the access content corresponding to the access request through the calling link of the server.
Further, after the step of receiving the access request and acquiring all interfaces corresponding to the access request, the method further includes:
and determining to execute queuing operation or releasing operation on the access request according to the current flow limiting state of all the interfaces, and storing the interface response time of the access request as time-consuming data into a response time queue when the access request is released.
In order to solve the foregoing technical problem, an embodiment of the present application further provides an apparatus for adjusting timeout time of an interface, which adopts the following technical solutions:
the first acquisition module is used for receiving an access request, acquiring all interfaces corresponding to the access request and reading first timeout time of all the interfaces;
the first sending module is used for sending the access request to a server through the interface according to the first timeout time, and pushing time-consuming data corresponding to the interface to a data storage end for storage and recording;
the second acquisition module is used for determining a target interface and acquiring time-consuming data of the target interface within a preset time period as target time-consuming data;
the calculation module is used for calculating the average request time consumption of the target interface in the preset time period based on the target time consumption data;
the second sending module is used for determining an initial interface group where the target interface is located and sending the average request consumed time to the initial interface group;
and the adjusting module is used for adjusting the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request consumed time.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:
the computer device comprises a memory and a processor, wherein the memory is stored with computer readable instructions, and the processor executes the computer readable instructions to realize the steps of the timeout adjusting method of the interface.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:
the computer readable storage medium has stored thereon computer readable instructions which, when executed by a processor, implement the steps of the timeout adjusting method of the interface as described above.
Compared with the prior art, the embodiment of the application mainly has the following beneficial effects:
according to the method, all interfaces corresponding to an access request are obtained by receiving the access request, first timeout time of all the interfaces is read, the access request is sent to a server through the interfaces according to the first timeout time, time-consuming data corresponding to the interfaces are pushed to a data storage end to be stored and recorded, a target interface is determined, the time-consuming data of the target interface in a preset time period are obtained and serve as target time-consuming data, average request time consumption of the target interface in the preset time period is calculated based on the target time-consuming data, an initial interface group where the target interface is located is determined, the average request time consumption is sent to the initial interface group, and the first timeout time of the target interface is adjusted according to second timeout time of the initial interface group and the average request time consumption; according to the method and the device, the average request consumed time of the target interface in the preset time period is calculated, the overtime of the target interface is adjusted according to the average request consumed time, the dynamic adjustment of the interface overtime can be realized, the problem that the request link is occupied for a long time due to the fact that the overtime is uniformly set is avoided, resources can be further rapidly released, and the interface service is optimized.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a timeout time adjustment method for an interface according to the present application;
FIG. 3 is a block diagram illustrating an embodiment of a timeout adjusting apparatus of an interface according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of a computer device according to the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
The present application provides a method for adjusting timeout of an interface, which can be applied to a system architecture 100 shown in fig. 1, where the system architecture 100 can include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that the timeout adjusting method for an interface provided in the embodiments of the present application is generally executed by a server/terminal device, and accordingly, the timeout adjusting apparatus for an interface is generally disposed in the server/terminal device.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continuing reference to FIG. 2, a flowchart of one embodiment of a timeout time adjustment method for an interface according to the present application is shown, comprising the steps of:
step S201, receiving the access request, obtaining all interfaces corresponding to the access request, and reading the first timeout time of all interfaces.
The interface is a user access interface, and a user accesses the service corresponding to the interface through the interface. Each service is provided with a corresponding interface, each interface is provided with an interface overtime time, if the calling time of a certain service interface exceeds the interface overtime time, the overtime is fused, the interface calling of the service is fused, resources are released, and service blocking is avoided.
The access request is a service request initiated by the user terminal to the server through the interface, where the access request may be a URL (Uniform Resource Locator) request, or may be other requests including a specified Resource address, and is not limited herein.
The service accessed by the user can be determined according to the access request, and then the interface for service calling is obtained, because the overtime time of the interface is pre-configured and stored in a key-value (key value pair) mode, namely, the interface corresponds to the overtime time one by one.
In this embodiment, the first timeout time of the interface configuration may be directly read. The first timeout time may be a timeout time of the ue, where the ue makes an access request to the server, and if the timeout occurs (i.e. the interface response time of the access request exceeds the first timeout time), the ue may actively disconnect the link and release the interface resource.
It should be understood that one service may correspond to multiple interfaces, and the first timeout time of an interface may be set according to the service, the access frequency, the interface response duration, and the like, for example, for a service for querying big data, the query time of such a service is longer, and there are usually some reports and situations of computation scenarios, so the first timeout time may be set to be longer than that of a general service, such as 3s, for a message class of a home page, Banner, an information-related service, the timeout time of such a service is relatively shorter, and if a long-time access request is not fused, the resource is occupied, so the first timeout time may be set to be relatively shorter, such as 1 s.
It should be noted that, in this embodiment, the interfaces are placed in the interface group, and the overtime fusing time is the overtime of the interface group. Fusing is essentially an overload protection mechanism, and if a certain target service is slow to call or has a large amount of timeout, the target service is fused, that is, for a subsequent call request aiming at the target service, a call failure is directly returned, so as to quickly release resources. And if the target service condition is improved, the call is recovered.
Step S202, according to the first timeout, the access request is sent to the server through the interface, and the time-consuming data corresponding to the interface is pushed to the data storage end to be stored and recorded.
In this embodiment, the access request is sent to the server through the interface, and the server obtains the corresponding service through the third party and returns the service to the user terminal. And determining that the access request is disconnected or the access request is successful according to the interface response time and the first timeout time. Regardless of disconnection of the access request or success of the access request, interface time-consuming data corresponding to the access request is asynchronously pushed to the data storage terminal, and the data storage terminal records actual time consumption of each interface.
The data storage end can adopt an ES (elastic search, data analysis engine) and is used for storing interface time-consuming data, separating the interface time-consuming data and creating an index to obtain time-consuming data to be inquired, and inquiring the time-consuming data to be inquired according to an interface time-consuming data inquiry request to obtain target time-consuming data.
Asynchronous push refers to a reporting operation performed simultaneously without affecting the main process under the condition of not affecting the access request, and the reported information includes but is not limited to information such as an interface request path, time-consuming data (i.e., interface response time of the access request), and a request user terminal IP.
Step S203, determining a target interface, and acquiring time-consuming data of the target interface within a preset time period as target time-consuming data.
Specifically, according to a preset timing mechanism, when the set time is reached, a timing task corresponding to the set time is obtained as a target timing task, a target interface is determined according to execution parameters of the target timing task, and time-consuming data in a preset time period is obtained from a data storage end based on the target interface and is used as the target time-consuming data.
In this embodiment, a timing task is preset, and the execution time of the timing task can be obtained according to the execution parameters of the timing task, where the execution parameters include, but are not limited to, task content, execution time, execution interface, and the like. The timing mechanism includes a timer for setting an execution time of the timed task, and when the set time of the timer (the execution time of the timed task set by the timer) is reached, the timed task corresponding to the execution time is acquired as a target timed task.
When the timing task is configured, the calling interface of the timing task can be determined according to the specific service of the timing task, so that the interface parameter of the interface to be called can be configured into the execution parameter of the timing task, and after the target timing task is obtained, all target interfaces required by the execution of the target timing task can be obtained according to the execution parameter of the target timing task.
The preset time period may be a time period between the execution time of the current timing task and the execution time of the next timing task, and for the first timing task, the preset time period is a time period before the first timing task starts, for example, 1 hour before the first timing task starts.
Before the timing task is executed or in the execution interval, other access requests are called for the interface, the interface time-consuming data before the timing task is executed or in the execution interval are sent to the data storage end for storage and recording, and the time-consuming data in the preset time period can be obtained from the data storage end according to the target interface.
The embodiment can improve the efficiency of acquiring time-consuming data.
It is emphasized that to further ensure privacy and security of the time-consuming data, the time-consuming data may also be stored in a node of a blockchain.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
And step S204, calculating the average request time consumption of the target interface in a preset time period based on the target time consumption data.
Specifically, the average request consumed time of each target interface is calculated according to the consumed time data of the target interface in a preset time period, which is queried from the data storage end by the target interface, for example, the preset time period is 1h, and the consumed time data of a certain target interface in the preset time period is 2.0s, 2.5s, 2.3s and 2.6s, respectively, so that the average consumed time data of the target interface is (2.0+2.5+2.3+2.6)/4 is 2.35 s.
Step S205, determine the initial interface group where the target interface is located, and send the average request time consumption to the initial interface group.
Specifically, interface parameters of a target interface are obtained, an initial interface group where the target interface is located is obtained according to the interface parameters, the interface parameters and the average request consumed time are packaged to a message queue, and the average request consumed time is sent to the corresponding initial interface group through the message queue.
In this embodiment, an initial interface group where the target interface is located may be obtained according to interface parameters of the target interface, where the interface parameters include an interface identifier, interface group parameters, and the like. The interface group is an interface set which divides the interfaces according to preset rules, and the preset rules include but are not limited to the operation, the access frequency, the interface response time and the like.
For example, one timing task corresponds to one application service, an interface of the application service may be in different interface groups, for example, a target timing task is a big data query task, an interface of a big data report has A, B, C, where an average request duration of an a interface is 4s, an average request duration of a B interface is 3s, an average request duration of a C interface is 1s, and an interface group exists in the timing task: the interface division is performed according to the interface response time, namely 1s interface group (I1), 3s interface group (I3) and 4s interface group (I4).
In this embodiment, the interface parameters and the average request time are encapsulated in a Message Queue (MQ), and the average request time is sent to the corresponding initial interface group in the form of the Message Queue to notify the initial interface group where the target interface is located.
The message queue is a data structure of "first-in first-out" in an underlying data structure, and means that data (messages) to be transmitted are placed in a queue, message transmission is realized by using a queue mechanism, a producer (data storage terminal) generates messages and places the messages in the queue, and then the messages are processed by a consumer (interface group), and the consumer (interface group) can pull the messages to a specified queue or subscribe to a corresponding queue, and an MQ server pushes the messages to the specified queue.
According to the embodiment, the average request time is sent in the form of the message queue, and the message sending efficiency and the message sending accuracy can be improved.
Step S206, according to the second overtime of the initial interface group and the average request time consumption, adjusting the first overtime of the target interface.
In this embodiment, the second timeout time is an interface group timeout time, which may be adjusted within a period of time, or may be preset when interface allocation definition is initialized, it should be understood that the interface group timeout time is not greater than the preset timeout time of the application service, for example, the interface group timeout time is 3 seconds, and the average time consumed for a service access request response of an interface list in the interface group is 2 to 3 seconds.
And adjusting the first timeout time of the target interface, specifically, adjusting the target interface from the initial interface group to the target interface group.
According to the method and the device, the average request consumed time of the target interface in the preset time period is calculated, the overtime of the target interface is adjusted according to the average request consumed time, the dynamic adjustment of the interface overtime can be realized, the problem that the request link is occupied for a long time due to the fact that the overtime is uniformly set is avoided, resources can be further rapidly released, and the interface service is optimized.
In some optional implementations of this embodiment, the step of adjusting the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request elapsed time includes:
and comparing the second timeout time with the average request consumed time, and when the average request consumed time is not within the second timeout time range, inquiring the corresponding target interface group according to the average request consumed time, and adjusting the target interface from the initial interface group to the target interface group.
In this embodiment, the second timeout time of the initial interface group where the target interface is located is compared with the average request consumed time within the preset time period of the target interface, and when the average request consumed time is not within the second timeout time range of the initial interface group, it is found that the average request consumed time of the target interface falls into some other interface group, the interface group is the target interface group, and the target interface is adjusted from the initial interface group to the target interface group.
For example, the initial interface group where the interface A is located is I4, and the timeout time range of the interface group I4 is 3s < TI4Is less than or equal to 4s, and the average request time in the preset time period is 2.8s, then the time-out time range of the interface group I3 is fallen (2s < T)I3No more than 3s), at this time, the interface A is adjusted from the interface group I4 to the interface group I3, the overtime fusing time of the interface A is the overtime time corresponding to the interface group I3, and the interface A path stored in the original interface group I4 is deleted. As another example, the initial interface group in which interface B is located is I2 (second timeout period: 1s < T)I32s) and the average request time in the preset time period is 2.8s, the time-out time range of the interface group I3 is fallen (2s < T)I3Not more than 3s), at this time, the interface B is adjusted from the interface group I2 to the interface group I3, the overtime fusing time of the interface B is the overtime time corresponding to the interface group I3, and the interface B path stored in the original interface group I2 is deleted.
It should be noted that the time-out time of the interface may be adjusted manually, and the time-out time may be adjusted automatically.
In this embodiment, the first timeout time of the target interface is adjusted according to the comparison result between the second timeout time of the initial interface group where the target interface is located and the average request consumed time within the preset time period of the target interface, so that the dynamic adjustment of the interface timeout time can be realized, and the interface service is optimized.
In some optional implementations, after the step of not being within the second timeout time range when the average request elapsed time, the method further includes:
and determining whether the associated party corresponding to the target timing task is abnormal or not, and determining whether to adjust the target interface to the target interface group or not according to the priority of the target timing task when the associated party is abnormal.
The related party is a third-party platform for the service terminal to acquire the service according to the access request or the timing task. After the average request time consumption of the target interface falls into the timeout time range of other interface groups, whether an association party is abnormal is detected, if the timeout time is lengthened due to the fact that the association party is abnormal, whether the timeout time of the target interface is adjusted is determined according to the priority of the target timing task, the priority is within a preset level, it is indicated that the service of the target timing task needs to be kept normal and the target timing task cannot be disconnected, the target interface is adjusted to the target interface group, for example, assuming that the interface A starts to be the average request time consumption of 2.8 seconds, the timing task is within a preset time period, the statistical average request time consumption is 3.5 seconds, the association party service is abnormal after confirmation, but the service is a core link and cannot be disconnected, the timeout time of the interface A is manually adjusted to be 4s, and the interface A is adjusted from I3 to I4.
It should be understood that the adjustment of the interface timeout time due to the occurrence of the anomaly of the associated party is short, and after the associated party returns to normal, the timeout time callback of the interface can be completed, that is, the average request time consumption of the interface a within the preset time period of the timing task calculation is returned to the original 2.8 seconds, the timeout time of the interface is readjusted to 3s, so that the subsequent 3s mass requests are prevented from occupying resources, and the application request is prevented from being blocked.
In addition, if the priority of the target timing task is not within the preset level, the interface adjustment is not needed, the interface returns to normal when the average interface request consumes time, and then the corresponding target timing task is executed.
The embodiment determines whether to adjust the timeout time of the target interface according to the priority of the target timing task, so that interruption of important services can be avoided, and the services are guaranteed to be normal.
In some optional implementations, after the step of sending the access request to the server through the interface, the method further includes:
and acquiring the access content corresponding to the access request through a calling link of the server.
And after the access request is successfully sent to the server, acquiring access content corresponding to the access request through a calling link of the server, and returning the access content to the user terminal, so that the user acquires corresponding request service.
In some optional implementation manners of this embodiment, after the steps of receiving the access request and obtaining all interfaces corresponding to the access request, the method further includes:
and determining to execute queuing operation or releasing operation on the access request according to the current flow limiting state of all the interfaces, and storing the interface response time of the access request as time-consuming data into a response time queue when the access request is released.
Specifically, for each access request, checking whether all interfaces corresponding to the access request need current limiting, if so, checking whether the access request is in a ready queue, if so, releasing the access request, and when a server returns a response, storing the interface response time of the access request into a response time queue to finish the access; if the current limiting state of all the interfaces is not in the ready queue, judging the current limiting state of all the interfaces, if the current limiting state is 'current limiting opening', putting the 1/2 interface into the ready queue, and putting the other 1/2 interfaces into a waiting queue; and if the state is 'the current limit is already opened', putting all the interfaces into a waiting queue, restoring the releasing of the interfaces of the waiting queue, and releasing the corresponding access requests.
The embodiment can realize automatic management and control of the interface flow and avoid service blockage.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
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 associated with computer readable instructions, which can be stored in a computer readable storage medium, and when executed, the processes of the embodiments of the methods described above can be included. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 3, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a timeout adjusting apparatus for an interface, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 4, the timeout adjusting apparatus 300 of the interface according to this embodiment includes: a first obtaining module 301, a first sending module 302, a second obtaining module 303, a calculating module 304, a second sending module 305, and an adjusting module 306. Wherein:
the first obtaining module 301 is configured to receive an access request, obtain all interfaces corresponding to the access request, and read first timeout time of all the interfaces;
the first sending module 302 is configured to send the access request to a server through the interface according to the first timeout time, and push time-consuming data corresponding to the interface to a data storage end for storage and recording;
the second obtaining module 303 is configured to determine a target interface, and obtain time-consuming data of the target interface within a preset time period as target time-consuming data;
the calculating module 304 is configured to calculate an average request elapsed time of the target interface in the preset time period based on the target elapsed time data;
the second sending module 305 is configured to determine an initial interface group where the target interface is located, and send the average request time consumption to the initial interface group;
the adjusting module 306 is configured to adjust the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request elapsed time.
It is emphasized that to further ensure privacy and security of the time-consuming data, the time-consuming data may also be stored in a node of a blockchain.
According to the overtime adjusting device of the interface, the average request consumed time of the target interface in the preset time period is calculated, the overtime of the target interface is adjusted according to the average request consumed time, the dynamic adjustment of the overtime of the interface can be achieved, the problem that the request link is occupied for a long time due to the fact that the overtime is uniformly set is avoided, resources can be further released rapidly, and interface service is optimized.
In this embodiment, the second obtaining module 303 is further configured to:
according to a preset timing mechanism, when set time is reached, a timing task corresponding to the set time is obtained and used as a target timing task;
determining a target interface according to the execution parameters of the target timing task;
and acquiring the time-consuming data in the preset time period from the data storage terminal based on the target interface to serve as target time-consuming data.
The embodiment can improve the efficiency of acquiring time-consuming data.
In this embodiment, the second sending module 305 is further configured to:
acquiring interface parameters of the target interface, and acquiring an initial interface group where the target interface is located according to the interface parameters;
and packaging the interface parameters and the average request consumed time to a message queue, and sending the average request consumed time to the corresponding initial interface group through the message queue.
According to the embodiment, the average request time is sent in the form of the message queue, and the message sending efficiency and the message sending accuracy can be improved.
In this embodiment, the adjusting module 306 includes a comparing unit, a querying unit, and an adjusting unit, where:
the comparison unit is used for comparing the second timeout time with the average request time;
the query unit is used for querying a corresponding target interface group according to the average request consumed time when the average request consumed time is not within the second timeout time range;
the adjusting unit is used for adjusting the target interface from the initial interface group to the target interface group.
The embodiment can realize the dynamic adjustment of the interface timeout time and optimize the interface service.
In some optional implementation manners of this embodiment, the adjusting module 306 further includes a determining unit, configured to determine whether an associated party corresponding to the target timing task is abnormal; and when the correlation party is abnormal, determining whether to adjust the target interface to the target interface group according to the priority of the target timing task.
The embodiment can avoid the interruption of important services and ensure the normal services.
In this embodiment, the apparatus 300 for adjusting timeout of an interface further includes a third obtaining module, configured to obtain, through the call link of the server, access content corresponding to the access request.
In some optional implementation manners of this embodiment, the apparatus 300 for adjusting timeout time of an interface further includes a determining module, configured to determine to perform a queuing operation or a releasing operation on the access request according to the current flow limiting states of all the interfaces, and store the interface response time of the access request as time-consuming data into a response time queue when the access request is released.
The embodiment can realize automatic management and control of the interface flow and avoid service blockage.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 4, fig. 4 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 4 comprises a memory 41, a processor 42, a network interface 43 communicatively connected to each other via a system bus. It is noted that only computer device 4 having components 41-43 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 4. Of course, the memory 41 may also include both internal and external storage devices of the computer device 4. In this embodiment, the memory 41 is generally used for storing an operating system installed in the computer device 4 and various types of application software, such as computer readable instructions of a timeout adjusting method of an interface. Further, the memory 41 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 42 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is configured to execute computer readable instructions stored in the memory 41 or process data, for example, computer readable instructions for executing a timeout adjusting method of the interface.
The network interface 43 may comprise a wireless network interface or a wired network interface, and the network interface 43 is generally used for establishing communication connection between the computer device 4 and other electronic devices.
In this embodiment, the step of the method for adjusting the timeout period of the interface according to the above embodiment is implemented when the processor executes the computer readable instructions stored in the memory, and by calculating the average request consumed time of the target interface within the preset time period and adjusting the timeout period of the target interface according to the average request consumed time, the dynamic adjustment of the timeout period of the interface can be implemented, thereby avoiding the problem that the request link is occupied for a long time due to the unified setting of the timeout period, further quickly releasing resources, and optimizing the interface service.
The present application further provides another embodiment, that is, a computer-readable storage medium is provided, where computer-readable instructions are stored, and the computer-readable instructions are executable by at least one processor, so that the at least one processor performs the steps of the method for adjusting the timeout period of the interface, and by calculating an average request consumed time of a target interface within a preset time period and adjusting the timeout period of the target interface according to the average request consumed time, dynamic adjustment of the timeout period of the interface can be achieved, a problem that a request link is occupied for a long time due to setting the timeout period in a unified manner is avoided, resources can be further released quickly, and interface services are optimized.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. A method for adjusting timeout of an interface, comprising the steps of:
receiving an access request, acquiring all interfaces corresponding to the access request, and reading first timeout time of all the interfaces;
according to the first timeout time, the access request is sent to a server through the interface, and time-consuming data corresponding to the interface is pushed to a data storage end to be stored and recorded;
determining a target interface, and acquiring time-consuming data of the target interface within a preset time period as target time-consuming data;
calculating the average request time consumption of the target interface in the preset time period based on the target time consumption data;
determining an initial interface group where the target interface is located, and sending the average request consumed time to the initial interface group;
and adjusting the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request consumed time.
2. The method according to claim 1, wherein the step of determining a target interface and obtaining time-consuming data of the target interface within a preset time period as the target time-consuming data comprises:
according to a preset timing mechanism, when set time is reached, a timing task corresponding to the set time is obtained and used as a target timing task;
determining a target interface according to the execution parameters of the target timing task;
and acquiring the time-consuming data in the preset time period from the data storage terminal based on the target interface to serve as target time-consuming data.
3. The method according to claim 1, wherein the step of determining an initial interface group where the target interface is located and sending the average request time to the initial interface group comprises:
acquiring interface parameters of the target interface, and acquiring an initial interface group where the target interface is located according to the interface parameters;
and packaging the interface parameters and the average request consumed time to a message queue, and sending the average request consumed time to the corresponding initial interface group through the message queue.
4. The method according to claim 1, wherein the step of adjusting the first timeout period of the target interface according to the second timeout period of the initial interface group and the average request elapsed time comprises:
comparing the second timeout time to the average request elapsed time;
when the average request consumed time is not within the second timeout time range, inquiring a corresponding target interface group according to the average request consumed time;
adjusting the target interface from the initial interface group to the target interface group.
5. The method of claim 4, further comprising, after the step of when the average request elapsed time is not within the second timeout period:
determining whether the associated party corresponding to the target timing task is abnormal;
and when the correlation party is abnormal, determining whether to adjust the target interface to the target interface group according to the priority of the target timing task.
6. The method for adjusting timeout of interface of claim 1, further comprising, after the step of sending the access request to the server through the interface:
and acquiring the access content corresponding to the access request through the calling link of the server.
7. The method for adjusting timeout of an interface according to claim 1, wherein after the step of receiving an access request and acquiring all interfaces corresponding to the access request, the method further comprises:
and determining to execute queuing operation or releasing operation on the access request according to the current flow limiting state of all the interfaces, and storing the interface response time of the access request as time-consuming data into a response time queue when the access request is released.
8. An apparatus for adjusting timeout time of an interface, comprising:
the first acquisition module is used for receiving an access request, acquiring all interfaces corresponding to the access request and reading first timeout time of all the interfaces;
the first sending module is used for sending the access request to a server through the interface according to the first timeout time, and pushing time-consuming data corresponding to the interface to a data storage end for storage and recording;
the second acquisition module is used for determining a target interface and acquiring time-consuming data of the target interface within a preset time period as target time-consuming data;
the calculation module is used for calculating the average request time consumption of the target interface in the preset time period based on the target time consumption data;
the second sending module is used for determining an initial interface group where the target interface is located and sending the average request consumed time to the initial interface group;
and the adjusting module is used for adjusting the first timeout time of the target interface according to the second timeout time of the initial interface group and the average request consumed time.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor which when executed implements the steps of the timeout time adjustment method of the interface of any one of claims 1 to 7.
10. A computer-readable storage medium, having computer-readable instructions stored thereon, which, when executed by a processor, implement the steps of the timeout time adjustment method of the interface of any one of claims 1 to 7.
CN202111432549.4A 2021-11-29 2021-11-29 Method and device for adjusting timeout time of interface, computer equipment and storage medium Pending CN114048059A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111432549.4A CN114048059A (en) 2021-11-29 2021-11-29 Method and device for adjusting timeout time of interface, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111432549.4A CN114048059A (en) 2021-11-29 2021-11-29 Method and device for adjusting timeout time of interface, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114048059A true CN114048059A (en) 2022-02-15

Family

ID=80211638

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111432549.4A Pending CN114048059A (en) 2021-11-29 2021-11-29 Method and device for adjusting timeout time of interface, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114048059A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115277606A (en) * 2022-08-01 2022-11-01 成都安恒信息技术有限公司 Method for optimizing DRBD data synchronization

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115277606A (en) * 2022-08-01 2022-11-01 成都安恒信息技术有限公司 Method for optimizing DRBD data synchronization
CN115277606B (en) * 2022-08-01 2023-11-24 成都安恒信息技术有限公司 Method for optimizing DRBD data synchronization

Similar Documents

Publication Publication Date Title
CN109684358B (en) Data query method and device
CN111414334A (en) File fragment uploading method, device, equipment and storage medium based on cloud technology
CN111813573B (en) Communication method of management platform and robot software and related equipment thereof
CN112162965B (en) Log data processing method, device, computer equipment and storage medium
CN109039817B (en) Information processing method, device, equipment and medium for flow monitoring
CN112468409A (en) Access control method, device, computer equipment and storage medium
EP3506599B1 (en) Method for synchronizing contact information, apparatus and medium
CN114048059A (en) Method and device for adjusting timeout time of interface, computer equipment and storage medium
US20230269304A1 (en) Method and apparatus for processing notification trigger message
CN114490715A (en) Data extraction method and device, electronic equipment and storage medium
CN114615325A (en) Message pushing method and device, computer equipment and storage medium
US10250515B2 (en) Method and device for forwarding data messages
CN112994934B (en) Data interaction method, device and system
CN114374657A (en) Data processing method and device
CN114520807A (en) File uploading and downloading method and device, computer equipment and storage medium
CN113761433A (en) Service processing method and device
CN110134547B (en) Middleware-based repeated data deleting method and related device
CN110019671B (en) Method and system for processing real-time message
CN112002352A (en) Random music playing method and device, computer equipment and storage medium
CN113114611A (en) Method and device for managing blacklist
CN114650252B (en) Routing method and device based on enterprise service bus and computer equipment
CN116861455B (en) Event data processing method, system, electronic device and storage medium
CN114915652B (en) Message pushing method and device, electronic equipment and storage medium
CN116775670A (en) Data interaction method and device, electronic equipment and readable storage medium
CN117061497A (en) Data providing 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