A service resource calling method and device, electronic equipment and storage medium

CN123011553APending Publication Date: 2026-10-30THE PEOPLES BANK OF CHINA NAT CLEARING CENT
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611182586.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

然而,在实际业务场景中不同资源调用请求的响应时间长短不同,单一连接池模式下,响应时间较长的慢请求会长期占用连接池资源,导致连接池内可用连接数量减少,当响应时间较短的快请求并发量较高时,可能因无法获取空闲连接而等待,进而造成快请求响应延迟,甚至引发整个服务的性能瓶颈

Benefits of technology

[0008]本发明实施例提供的一种服务资源调用方法、装置、电子设备及存储介质,通过基于资源调用请求确定目标资源对应的调用请求快慢类型,能够实现响应时间较长的慢请求和响应时间较短的快请求的分类;本发明实施例进一步基于所述调用请求快慢类型从目标服务对应的多个候选连接池中确定出目标连接池和通过所述目标连接池将所述资源调用请求转发至所述目标服务,能够实现快慢请求的资源隔离和分类处理,使得慢请求不再占用快请求的连接资源,有效避免慢请求对快请求的性能影响,显著提升微服务调用其他服务时的调用效率和稳定性;此外,分类处理模式使请求调用的性能更可预测,快请求和慢请求的问题可独立排查,降低了故障定位难度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011553A_ABST
    Figure CN123011553A_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a service resource calling method and device, electronic equipment and a storage medium. The method comprises the following steps: determining a calling request fast / slow type corresponding to a target resource based on a resource calling request, wherein the resource calling request is a calling request for calling the target resource on a target service; determining a target connection pool from a plurality of candidate connection pools corresponding to the target service based on the calling request fast / slow type; and forwarding the resource calling request to the target service through the target connection pool, so as to call the target resource through the target service. The embodiments of the present application can improve the calling performance when micro services call other services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of microservices, and more particularly to a method, apparatus, electronic device, and storage medium for invoking service resources. Background Technology

[0002] In a microservice architecture, a complete business system consists of multiple independently deployed and interdependent microservices, each frequently calling resources from other microservices. The connection pool, as a core component of microservice calls, manages network connections between services. In existing microservice architectures, most service calls use a single connection pool model, meaning all resource call requests between services share the same connection pool resources. However, in real-world business scenarios, different resource call requests have varying response times. Under a single connection pool model, slow requests with longer response times will occupy connection pool resources for extended periods, reducing the number of available connections. When the concurrency of fast requests with shorter response times is high, they may wait due to the inability to obtain idle connections, causing delays in fast request responses and potentially leading to performance bottlenecks for the entire service. Summary of the Invention

[0003] This invention provides a service resource invocation method, apparatus, electronic device, and storage medium, which can improve the invocation performance of microservices when invoking other services.

[0004] In a first aspect, embodiments of the present invention provide a service resource invocation method, including: The speed type of the call request corresponding to the target resource is determined based on the resource call request, wherein the resource call request is a call request used to call the target resource on the target service; The target connection pool is determined from multiple candidate connection pools corresponding to the target service based on the call request speed type; and The resource call request is forwarded to the target service through the target connection pool, so that the target resource can be called through the target service.

[0005] In a second aspect, embodiments of the present invention provide a service resource invocation apparatus, comprising: The speed type acquisition module is used to determine the speed type of the call request corresponding to the target resource based on the resource call request, wherein the resource call request is a call request used to call the target resource on the target service; The target connection pool acquisition module is used to determine the target connection pool from multiple candidate connection pools corresponding to the target service based on the call request speed type; and The request forwarding module is used to forward the resource call request to the target service through the target connection pool, so as to call the target resource through the target service.

[0006] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the service resource invocation method as described in any of the embodiments of the present invention.

[0007] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the service resource invocation method as described in any of the embodiments of the present invention.

[0008] This invention provides a service resource invocation method, apparatus, electronic device, and storage medium. By determining the speed type of the invocation request corresponding to the target resource based on the resource invocation request, it can classify slow requests with long response times and fast requests with short response times. Furthermore, this invention determines a target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the invocation request and forwards the resource invocation request to the target service through the target connection pool. This enables resource isolation and classification processing of fast and slow requests, ensuring that slow requests no longer occupy the connection resources of fast requests, effectively avoiding the performance impact of slow requests on fast requests, and significantly improving the invocation efficiency and stability when microservices call other services. In addition, the classification processing mode makes the performance of request invocation more predictable, and problems with fast and slow requests can be investigated independently, reducing the difficulty of fault location. Attached Figure Description

[0009] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 This is a flowchart illustrating a service resource invocation method provided in an embodiment of the present invention; Figure 2 This is another flowchart illustrating the service resource invocation method provided in this embodiment of the invention; Figure 3 This is another flowchart illustrating the service resource invocation method provided in this embodiment of the invention; Figure 4 This is a schematic diagram of a service resource invocation device provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0011] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0012] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0013] Figure 1 This is a flowchart illustrating a service resource invocation method provided in an embodiment of the present invention. This embodiment is applicable to various microservices in a microservice architecture business system. The method can be executed by the service resource invocation device provided in this embodiment, which can be implemented in software and / or hardware. In a specific embodiment, the device can be integrated into an electronic device, such as a computer or server. The following embodiments will illustrate this using the integration of the device into an electronic device as an example. (Reference) Figure 1 The method may specifically include the following steps: Step 101: Determine the speed type of the call request corresponding to the target resource based on the resource call request. The resource call request is a call request used to invoke the target resource on the target service. This step enables the classification of slow requests with long response times and fast requests with short response times, which in turn facilitates the determination of the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request, thus achieving resource isolation and classification processing for fast and slow requests.

[0014] Specifically, the above request speed types can be understood as a classification method used to reflect the request response speed of the corresponding resource call request.

[0015] Optionally, the call request speed type includes fast request and slow request.

[0016] Specifically, the above-mentioned call request speed types can also include normal requests.

[0017] Optionally, the process of determining the call request speed type corresponding to the target resource based on the resource call request includes: extracting the resource path from the resource call request; and determining the call request speed type corresponding to the target resource based on the mapping relationship between the resource path and the corresponding call request speed type.

[0018] Specifically, a request classification information table can be pre-established to store the resource paths, corresponding call request speed types, and corresponding mapping relationships of each service resource that needs to be called on the target service.

[0019] Specifically, the aforementioned request classification information table can be a static table or a dynamic table.

[0020] Specifically, when the requested classification information table is a dynamic table, the classification information table can be updated periodically.

[0021] Specifically, when the request classification information table is a static table, the speed of the call request corresponding to each service resource can be determined based on the request response time when calling the corresponding service resource within a set historical time period, or it can be determined based on the developer's experience.

[0022] Specifically, the process of determining the call request speed type corresponding to the target resource based on the mapping relationship between the resource path and the corresponding call request speed type may include: querying the request classification information table based on the resource path to obtain the call request speed type corresponding to the target resource.

[0023] In a specific example, this embodiment of the invention is applied to a scenario where a channel microservice in a small-amount payment system calls downstream services. All business messages in the small-amount payment system are distributed through the channel microservice. Different messages are sent to different microservices to achieve physical service call isolation. However, core transaction messages are all sent to the same downstream microservice, PayServer. Transaction messages include single and batch transactions, as well as two-party and three-party messages. The request classification information table is configured as a static table, as shown in Table 1: Table 1 In one optional instance, the resource path "payserver / 121" is extracted from the resource call request. The request classification information is queried to find that the request speed type corresponding to the resource path "payserver / 121" is a fast request. Therefore, the speed type of the call request corresponding to the target resource is determined to be a fast request.

[0024] In an optional instance, the resource path " / payserver / 381" in the resource call request is extracted, and the request classification information is queried to find that the request speed type corresponding to the resource path " / payserver / 381" is a slow request.

[0025] Step 102: Determine the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request. This step facilitates forwarding the call request to the target server through the target connection pool.

[0026] Optionally, the above-mentioned candidate connection pools include: a request connection pool and a slow request connection pool.

[0027] Optionally, the fast request connection pool and the slow request connection pool are configured such that: the connection timeout of the fast request connection pool is less than the connection timeout of the slow request connection pool; the minimum number of connections in the fast request connection pool is greater than the minimum number of connections in the slow request connection pool; and the maximum number of connections in the fast request connection pool is greater than the maximum number of connections in the slow request connection pool.

[0028] Specifically, the connection reuse rate of the fast request connection pool and the slow request connection pool can be configured such that the connection reuse rate of the fast request connection pool is greater than that of the slow request connection pool.

[0029] Optionally, the multiple candidate connection pools include a general connection pool, the maximum number of connections in the general connection pool being greater than the maximum number of connections in the slow request connection pool but less than the maximum number of connections in the fast request connection pool.

[0030] Specifically, the candidate connection pool can also include only the fast request connection pool and the general connection pool.

[0031] Specifically, the connection timeout of the general connection pool can be greater than the connection timeout of the fast request pool and less than the connection timeout of the slow request connection pool; the minimum number of connections in the general connection pool can be greater than the minimum number of connections in the slow request connection pool and less than the minimum number of connections in the fast request connection pool.

[0032] Specifically, the connection reuse rate of a general connection pool can be greater than that of a slow request connection pool, but less than that of a fast request connection pool.

[0033] Specifically, the connection timeout of the general connection pool can also be equal to the connection timeout of the slow request connection pool, and the minimum number of connections in the general connection pool can also be equal to the minimum number of connections in the slow request connection pool.

[0034] Optionally, in scenarios where the channel microservice of a small-amount payment system calls downstream services, the fast request connection pool, slow request connection pool, and general connection pool can be configured as follows: Fast request connection pool: minimum number of connections 5, maximum number of connections 20, connection timeout 500 milliseconds; Slow request connection pool: minimum number of connections 3, maximum number of connections 10, connection timeout 5 seconds; General request pool: minimum number of connections 3, maximum number of connections 15, connection timeout 5 seconds.

[0035] It is understood that the three types of connection pools in this embodiment of the invention can be configured with parameters independently according to the characteristics of the request type. The fast request connection pool focuses on response speed, while the slow request connection pool focuses on resource stability. This avoids the compromise of single connection pool parameter configuration, improves the utilization efficiency of connection resources, and reduces unnecessary resource overhead.

[0036] Optionally, the process of determining the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request includes: if the speed type of the call request is a fast request, then the fast request connection pool is determined as the target connection pool; if the speed type of the call request is a slow request, then the slow request connection pool is determined as the target connection pool.

[0037] Specifically, when the candidate connection pools only include fast request connection pools and general connection pools, the process of determining the target connection pool from multiple candidate connection pools corresponding to the target service based on the call request speed type can include: if the call request speed type is fast request, then the fast request connection pool is determined as the target connection pool; if the call request speed type is slow request, then the general request pool is determined as the target connection pool.

[0038] Specifically, the process of determining the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request may also include: if the speed type of the call request is a normal request, then the general connection pool is determined as the target connection pool.

[0039] Step 103 forwards the resource call request to the target service through the target connection pool, so that the target resource can be called through the target service. Building upon steps 101 and 102, this step achieves resource isolation and categorized processing for fast and slow requests. This prevents slow requests from consuming the connection resources of fast requests, effectively avoiding the performance impact of slow requests on fast requests, and significantly improving the call efficiency and stability when microservices call other services. Furthermore, the categorized processing mode makes the performance of request calls more predictable, and problems with fast and slow requests can be investigated independently, reducing the difficulty of fault localization.

[0040] Specifically, the process of forwarding resource call requests to the target service through the target connection pool may include: obtaining an idle connection from the target connection pool, assembling and encapsulating the request data in the resource call request, and forwarding the encapsulated request data to the target service through the idle connection.

[0041] In one optional specific instance, for a resource call request with the resource path "payserver / 121", an idle connection is obtained from the fast request connection pool. The request data in the resource call request is formatted and encapsulated. The encapsulated request data is then forwarded to the target service through the idle connection in the fast request connection pool. After receiving a response 100 milliseconds later, the connection in the fast request connection pool is released.

[0042] In one optional specific instance, for a resource call request with the resource path " / payserver / 381", an idle connection is obtained from the slow request connection pool. The request data in the resource call request is formatted and encapsulated. The encapsulated request data is then forwarded to the target service through the idle connection in the slow request connection pool. After receiving the response 1 second later, the connection in the slow request connection pool is released.

[0043] The following further describes the service resource invocation method provided by embodiments of the present invention. For example... Figure 2 As shown, the service resource invocation method provided in this embodiment of the invention may include the following steps: Step 201: In response to the resource call request, determine whether the speed type of the call request corresponding to the target resource is known.

[0044] It is understandable that in scenarios where the speed of a call request for each service resource is determined by the request response time when the corresponding service resource is called within a historical period of a set duration, if the total historical duration has not yet reached the set duration, the speed of the call request may be unknown.

[0045] Specifically, the process of determining whether the call request speed type corresponding to the target resource is known may include: extracting the resource path from the resource call request, and querying the request classification information table based on the resource path to see if there is a corresponding call request speed type; if there is a corresponding call request speed type in the classification information table, it is determined that the call request speed type corresponding to the target resource is known; if there is no corresponding call request speed type in the classification information table, it is determined that the call request speed type corresponding to the target resource is unknown.

[0046] Step 202: If the speed type of the call request corresponding to the target resource is unknown, the resource call request is forwarded to the target service through the general connection pool, and the response time of this request for the target resource is obtained.

[0047] Optionally, if the speed of the call request corresponding to the target resource is known, step 203 can be skipped and step 204 can be started directly.

[0048] In a specific instance, resource call requests are forwarded to the target service multiple times through a general connection pool, and the corresponding request response times are recorded, for example, 3 seconds for the first time, 2.5 seconds for the second time, and 4 seconds for the third time.

[0049] Step 203: When the number of times the target resource is called is not less than the number threshold, or when the total recording time of the number of times the target resource is called is not less than the first duration threshold, determine the call request speed type corresponding to the target resource based on the response time of each request when the target resource is called by the microservice request.

[0050] Specifically, the above-mentioned number threshold and first duration threshold can be set based on empirical data. For example, the number threshold can be set to 50 times, and the first duration threshold can be set to 10 minutes.

[0051] In a specific instance, when the total recording time for the number of times the target resource is called reaches 10 minutes and the number of times the target resource is called is 60, the call request speed type corresponding to the target resource is determined based on the response time of each request when the target resource is called by the microservice.

[0052] Specifically, if the total response time of the target resource when it is called by a microservice is not less than the second time threshold, the speed of the call request corresponding to the target resource can be determined based on the response time of each request when the target resource is called by a microservice.

[0053] Specifically, the aforementioned second duration threshold can be set based on empirical data, for example, it can be set to 5 minutes.

[0054] Optionally, the process of determining the call request speed type corresponding to the target resource based on the response time of each request when the target resource is called by a microservice includes: determining the call request speed type corresponding to the target resource based on the average response time of each request and the response time threshold.

[0055] Specifically, the aforementioned response time threshold may include one value or multiple values.

[0056] Optionally, the above response time thresholds include fast request time thresholds and slow request time thresholds.

[0057] Specifically, the fast request duration threshold and slow request duration threshold mentioned above can be set based on experience. For example, the fast request duration threshold can be set to 0.5-1 seconds, and the slow request duration threshold can be set to 2-3 seconds.

[0058] Optionally, the process of determining the call request speed type corresponding to the target resource based on the response time of each request when the target resource is called by a microservice includes: if the average response time of each request is not greater than the fast request time threshold, then the call request speed type corresponding to the target resource is determined to be a fast request.

[0059] Optionally, the process of determining the speed type of the call request corresponding to the target resource based on the response time of each request when the target resource is called by the microservice includes: if the average response time of each request is greater than the slow request time threshold, then the speed type of the call request corresponding to the target resource is determined to be a slow request.

[0060] In a specific instance, the average response time for each request is 3.5 seconds, which is greater than the slow request time threshold of 3 seconds. Therefore, the call request type corresponding to the target resource is determined to be a slow request.

[0061] Specifically, the speed of the request to the target resource can be determined based on the median of the response time of each request or other characteristic values.

[0062] Optionally, the process of determining the speed type of the call request corresponding to the target resource based on the response time of each request when the target resource is called by the microservice includes: if the average response time of each request is greater than the fast request time threshold but not greater than the slow request time threshold, then the execution is restarted to forward the resource call request to the target service through the general connection pool, and the response time of the target resource in this request is obtained, until the average response time of each request is not greater than the fast request time threshold, or the average response time of each request is greater than the slow request time threshold.

[0063] Step 204: Determine the call request speed type corresponding to the target resource.

[0064] Step 205: If the call request type is fast request, then the fast request connection pool is determined as the target connection pool; if the call request type is slow request, then the slow request connection pool is determined as the target connection pool.

[0065] Step 206: Forward the resource call request to the target service through the target connection pool.

[0066] This invention, through setting fast request duration thresholds, slow request duration thresholds, and a general connection pool to adapt to scenarios with uncertain request types, automatically classifies resource call requests by speed through data collection. This reduces the cost of manual configuration and maintenance without human intervention, and improves accuracy and system scalability.

[0067] The following further describes the service resource invocation method provided by the embodiments of the present invention.

[0068] Optionally, the call request speed type corresponding to the target resource is updated periodically based on the classification update cycle.

[0069] Specifically, the update cycle for the above categories can be set based on historical or empirical data, and can be set to 1 hour.

[0070] Optional, such as Figure 3 As shown, the service resource invocation method provided in this embodiment of the invention may include the following steps: Step 301: Determine the call request speed type based on the response time of each request when the target resource is called by a microservice within this category update cycle.

[0071] Optionally, the process of determining the speed type of a call request based on the response time of each request when the target resource is called by a microservice within the current category update cycle may include: determining the speed type of a call request based on the response time of each request when the target resource is called by a microservice within the current category update cycle when the number of times the target resource is called is not less than a threshold, or when the total recording time of the number of times the target resource is called is not less than a first time threshold.

[0072] Specifically, the speed of the call request corresponding to the target resource can be determined based on the average response time of each request within the update cycle of this category and the response time threshold.

[0073] Specifically, the call request speed type corresponding to the target resource can also be determined based on other characteristic values ​​such as the median of the response time of each request within this classification update cycle and corresponding thresholds.

[0074] Step 302: Determine the speed type of the call request corresponding to the target resource based on the resource call request. The resource call request is a call request used to call the target resource on the target service.

[0075] Specifically, when the number of times the target resource is called is less than the number threshold within the current category update cycle, or when the total recording time for recording the number of times the target resource is called is less than the first duration threshold, the request speed type corresponding to the target resource can be determined as the request speed type before the update.

[0076] Step 303: Determine the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request.

[0077] Step 304: Forward the resource call request to the target service through the target connection pool so that the target resource can be called through the target service.

[0078] It is understandable that downstream services are often optimized in real-world application scenarios. By periodically updating the call request speed type corresponding to the target resource, the service resource call method provided by the present invention can automatically adapt to business changes, ensuring the efficiency and stability of the system.

[0079] Figure 4 This is a structural diagram of a service resource invocation apparatus provided in an embodiment of the present invention. This apparatus is suitable for executing the service resource invocation method provided in an embodiment of the present invention. Figure 4 As shown, the device may specifically include: The speed type acquisition module 401 is used to determine the speed type of the call request corresponding to the target resource based on the resource call request. The resource call request is a call request used to invoke the target resource on the target service. This module can classify slow requests with long response times and fast requests with short response times, thereby facilitating the determination of the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request, and realizing resource isolation and classification processing of fast and slow requests.

[0080] Optionally, the call request speed type includes fast request and slow request.

[0081] Optionally, the call request speed type corresponding to the target resource is updated periodically based on the classification update cycle.

[0082] Optionally, the speed type acquisition module 401 can be specifically used to extract the resource path in the resource call request; and to determine the call request speed type corresponding to the target resource based on the mapping relationship between the resource path and the corresponding call request speed type.

[0083] The target connection pool acquisition module 402 is used to determine the target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request. This module can facilitate the forwarding of call requests to the target server through the target connection pool.

[0084] Optionally, the aforementioned candidate connection pools include: a request connection pool and a slow request connection pool, wherein the connection timeout of the fast request connection pool is shorter than the connection timeout of the slow request connection pool; the minimum number of connections in the fast request connection pool is greater than the minimum number of connections in the slow request connection pool; and the maximum number of connections in the fast request connection pool is greater than the maximum number of connections in the slow request connection pool.

[0085] Optionally, the above-mentioned candidate connection pools include: a general connection pool, wherein the maximum number of connections in the general connection pool is greater than the maximum number of connections in the slow request connection pool and less than the maximum number of connections in the fast request connection pool.

[0086] Optionally, the target connection pool acquisition module 402 can be specifically used to determine the fast request connection pool as the target connection pool if the call request speed type is fast request; and to determine the slow request connection pool as the target connection pool if the call request speed type is slow request.

[0087] The request forwarding module 403 forwards resource call requests to the target service through the target connection pool, enabling the target service to call the target resource. This module, combined with modules 401 and 402, achieves resource isolation and categorized processing of fast and slow requests. This prevents slow requests from consuming the connection resources of fast requests, effectively avoiding the performance impact of slow requests on fast requests, and significantly improving the efficiency and stability of microservices calling other services. Furthermore, the categorized processing mode makes request call performance more predictable, and problems with fast and slow requests can be investigated independently, reducing the difficulty of fault location.

[0088] Optionally, the service resource invocation device provided in this invention embodiment may further include a classification module, used to determine whether the call request speed type corresponding to the target resource is known before determining the call request speed type corresponding to the target resource; if the call request speed type corresponding to the target resource is unknown, the resource invocation request is forwarded to the target service through a general connection pool, and the response time of the current request of the target resource is obtained; when the number of times the target resource is invoked is not less than the number threshold, or when the total recording time of the number of times the target resource is invoked is not less than the first duration threshold, the call request speed type corresponding to the target resource is determined based on the response time of each request when the target resource is invoked by the microservice request.

[0089] Optionally, the above classification module can also be specifically used to: if the average response time of each request is not greater than the fast request time threshold, then determine the fast / slow type of the call request corresponding to the target resource as a fast request; if the average response time of each request is greater than the slow request time threshold, then determine the fast / slow type of the call request corresponding to the target resource as a slow request; if the average response time of each request is greater than the fast request time threshold but not greater than the slow request time threshold, then restart execution to forward the resource call request to the target service through the general connection pool and obtain the response time of the target resource for this request, until the average response time of each request is not greater than the fast request time threshold, or the average response time of each request is greater than the slow request time threshold.

[0090] Optionally, the above classification module can also be used to determine the speed type of the call request based on the response time of each request when the target resource is called by the microservice within the classification update cycle.

[0091] Optionally, the speed type acquisition module 401 can also be used to determine the speed type of the call request corresponding to the target resource if the speed type of the call request corresponding to the target resource is known.

[0092] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional modules is merely an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the functional modules described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0093] This invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the service resource invocation method provided in any of the above embodiments.

[0094] This invention also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the service resource invocation method provided in any of the above embodiments.

[0095] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the service resource invocation method as described in any of the embodiments of this invention.

[0096] The following is for reference. Figure 5 It shows a schematic diagram of the structure of a computer system 500 suitable for implementing an electronic device according to embodiments of the present invention. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.

[0097] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 502 or programs loaded from storage section 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the system 500. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0098] The following components are connected to I / O interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to I / O interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 510 as needed so that computer programs read from it can be installed into storage section 508 as needed.

[0099] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs the functions defined above in the system of this invention.

[0100] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0101] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0102] The modules and / or units described in the embodiments of this invention can be implemented in software or hardware. The described modules and / or units can also be housed in a processor; for example, a processor can be described as including a speed type acquisition module, a target connection pool acquisition module, and a request forwarding module. The names of these modules do not necessarily limit the functionality of the module itself.

[0103] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to: determine the speed type of a call request corresponding to a target resource based on a resource call request, wherein the resource call request is a call request for calling a target resource on a target service; determine a target connection pool from multiple candidate connection pools corresponding to the target service based on the speed type of the call request; and forward the resource call request to the target service through the target connection pool, so as to call the target resource through the target service.

[0104] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for invoking service resources, characterized in that, include: The speed type of the call request corresponding to the target resource is determined based on the resource call request, wherein the resource call request is a call request used to call the target resource on the target service; The target connection pool is determined from multiple candidate connection pools corresponding to the target service based on the speed type of the call request. as well as The resource call request is forwarded to the target service through the target connection pool, so that the target resource can be called through the target service.

2. The service resource invocation method according to claim 1, characterized in that, The call request speed type includes fast request and slow request, and the multiple candidate connection pools include: fast request connection pool and slow request connection pool; The step of determining the target connection pool from multiple candidate connection pools corresponding to the target service based on the call request speed type includes: If the call request speed type is fast request, then the fast request connection pool is determined as the target connection pool; If the call request type is slow request, then the slow request connection pool is determined as the target connection pool; Wherein, the connection timeout time of the fast request connection pool is less than the connection timeout time of the slow request connection pool; the minimum number of connections of the fast request connection pool is greater than the minimum number of connections of the slow request connection pool; and the maximum number of connections of the fast request connection pool is greater than the maximum number of connections of the slow request connection pool.

3. The service resource invocation method according to claim 1, characterized in that, The plurality of candidate connection pools includes a general connection pool; Before determining the call request speed type corresponding to the target resource, the method further includes: Determine whether the call request speed type corresponding to the target resource is known; If the speed type of the call request corresponding to the target resource is unknown, the resource call request is forwarded to the target service through the general connection pool, and the response time of this request for the target resource is obtained; When the number of times the target resource is invoked is not less than the number threshold, or when the total recording time of the number of times the target resource is invoked is not less than the first time threshold, the call request speed type corresponding to the target resource is determined based on the response time of each request when the target resource is invoked by the microservice request. The maximum number of connections in the general connection pool is greater than the maximum number of connections in the slow request connection pool and less than the maximum number of connections in the fast request connection pool.

4. The service resource invocation method according to claim 3, characterized in that, The method further includes: If the call request speed type corresponding to the target resource is known, then the execution of determining the call request speed type corresponding to the target resource is initiated.

5. The service resource invocation method according to claim 3, characterized in that, The method of determining the call request speed type corresponding to the target resource based on the response time of each request when the target resource is called by the microservice includes: If the average response time of each request is not greater than the fast request time threshold, then the call request speed type corresponding to the target resource is determined to be a fast request. If the average response time of each request is greater than the slow request time threshold, then the call request type corresponding to the target resource is determined to be a slow request. If the average response time of each request is greater than the fast request time threshold but not greater than the slow request time threshold, then the process of forwarding the resource call request to the target service through the general connection pool is restarted, and the response time of the target resource for this request is obtained, until the average response time of each request is not greater than the fast request time threshold, or the average response time of each request is greater than the slow request time threshold.

6. The service resource invocation method according to claim 1, characterized in that, The call request speed type corresponding to the target resource is updated periodically based on the classification update cycle; Before determining the call request speed type corresponding to the target resource based on the resource call request, the method further includes: The speed type of the call request is determined based on the response time of each request when the target resource is called by the microservice within this classification update cycle.

7. The service resource invocation method according to claim 1, characterized in that, The determination of the call request speed type corresponding to the target resource includes: Extract the resource path from the resource request; and The target resource's call request speed type is determined based on the mapping relationship between the resource path and the corresponding call request speed type.

8. A service resource invocation device, characterized in that, include: The speed type acquisition module is used to determine the speed type of the call request corresponding to the target resource based on the resource call request, wherein the resource call request is a call request used to call the target resource on the target service; The target connection pool acquisition module is used to determine the target connection pool from multiple candidate connection pools corresponding to the target service based on the call request speed type; as well as The request forwarding module is used to forward the resource call request to the target service through the target connection pool, so as to call the target resource through the target service.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the service resource invocation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the service resource invocation method as described in any one of claims 1 to 7.