Thread capacity expansion method, gateway, storage medium and program product

By threading capacity expansion for each service level and generating capacity expansion rules based on the predicted number of requests, the problem that existing traffic control methods affect important services under high concurrency is solved, and more efficient resource allocation and user experience is achieved.

CN119806822APending Publication Date: 2025-04-11INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411867215.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The existing traffic control methods are based on application or interface dimension settings, which will trigger current limit when the traffic of low-level services suddenly increases, affecting the processing of high-level services and affecting user experience.

Method used

By determining the service level to which each business request belongs, and predicting the number of requests in the next time period based on the current number of requests and thread response time of the service level, generating thread expansion rules, creating new and associated threads to achieve automatic expansion of threads.

Benefits of technology

It realizes independent resource allocation at different service levels, so that important services are processed first, ensure business response speed and processing capabilities, and improve system performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806822A_ABST
    Figure CN119806822A_ABST
Patent Text Reader

Abstract

The invention discloses a thread capacity expansion method, a gateway, a storage medium and a program product. Relates to the technical field of financial science and technology, and comprises the following steps: obtaining business requests in a current time period, and respectively determining a service level to which each business request belongs, one service level corresponding to at least one thread; for each service level, determining a predicted request quantity corresponding to the service level in the next time period according to the current request quantity and the current thread response time corresponding to the service level; and if the predicted request number is not matched with the current thread number corresponding to the service level, generating a thread expansion rule corresponding to the service level, creating a new thread based on the thread expansion rule, and associating the new thread with the service level. According to the scheme provided by the invention, the automatic capacity expansion of the thread can be realized to ensure the response speed and the processing capability of the service, and meanwhile, important services can be preferentially processed, so that the overall performance of the system and the user experience feeling are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial technology, and in particular to a thread expansion method, a gateway, a storage medium and a program product. Background Art

[0002] With the rapid development of Internet technology, financial services have gradually achieved digital, networked and intelligent transformation. At present, users no longer need to go to offline outlets to handle most financial services, but can handle them online through user devices (such as smartphones, tablets, etc.).

[0003] In the online process of financial services, business requests are sent to the gateway through the client installed on the user's device. The gateway will put the business requests into the sending thread in a certain order, and then pass the sending thread to the server for business processing. In order to prevent the server from crashing due to high concurrency and high traffic, it is usually necessary to control the flow of the gateway.

[0004] However, most of the existing traffic control methods are set based on the application or interface dimension. When there are multiple services of different importance levels in an application or interface, if the traffic of low-level services suddenly increases, it will trigger flow limiting, resulting in the inability to process high-level services, affecting the user experience. Summary of the invention

[0005] The present invention provides a thread expansion method, a gateway, a storage medium and a program product, which can realize automatic thread expansion to ensure the response speed and processing capacity of the business, while enabling important businesses to be processed with priority, thereby improving the overall performance of the system and the user experience.

[0006] According to one aspect of the present invention, a thread expansion method is provided, which is applied to a gateway; the method comprises: obtaining business requests in a current time period, and respectively determining a service level to which each business request belongs, wherein one service level corresponds to at least one thread; for each service level, determining a predicted number of requests corresponding to the service level in the next time period according to a current number of requests corresponding to the service level and a current thread response time; if the predicted number of requests does not match the current number of threads corresponding to the service level, generating a thread expansion rule corresponding to the service level, creating a new thread based on the thread expansion rule, and associating the new thread with the service level.

[0007] Optionally, based on the current number of requests corresponding to the service level and the current thread response time, determine the predicted number of requests corresponding to the service level in the next time period, including: querying in a preset statistical model to determine target statistical information based on the current number of requests corresponding to the service level and the current thread response time; determining the predicted number of requests corresponding to the service level in the next time period based on the target statistical information.

[0008] Optionally, the statistical model is determined by the following method: obtaining historical transaction information, historical thread information and time correlation information of a historical time period, wherein the time correlation information is used to describe holiday information and / or operational activity information within the historical time period; and constructing a statistical model based on the historical transaction information, historical thread information and time correlation information.

[0009] Optionally, the gateway is communicatively connected with the server; before generating thread expansion rules corresponding to the service level, the method also includes: obtaining the current resource utilization rate of the server; if the current resource utilization rate is greater than the resource utilization threshold corresponding to the service level, maintaining the current number of threads corresponding to the service level unchanged; if the current resource utilization rate is less than or equal to the resource utilization threshold corresponding to the service level, continuing to execute the step of generating thread expansion rules corresponding to the service level.

[0010] Optionally, generating thread expansion rules corresponding to the service level includes: obtaining the maximum expansion number of threads and the maximum expansion ratio corresponding to the service level, wherein the sum of the maximum expansion ratios corresponding to all service levels is equal to 1; generating thread expansion rules corresponding to the service level according to the maximum expansion number of threads and the maximum expansion ratio.

[0011] Optionally, the thread expansion rule includes several thread expansion quantities arranged in order, wherein the sum of all thread expansion quantities is equal to the product of the maximum thread expansion number and the maximum expansion ratio corresponding to the service level, and the thread expansion rule is used to indicate that new threads are created in batches according to the arrangement order of the thread expansion quantities.

[0012] Optionally, after creating a new thread based on the thread expansion rule and associating the new thread with the service level, the method further includes: obtaining a thread destruction instruction; and destroying the new thread according to the thread destruction instruction.

[0013] According to another aspect of the present invention, a gateway is provided, comprising: at least one processor; and a memory in communication with the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the thread expansion method of any embodiment of the present invention.

[0014] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the thread expansion method of any embodiment of the present invention when executed.

[0015] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the thread expansion method of any embodiment of the present invention is implemented.

[0016] The technical solution of the embodiment of the present invention determines the service level to which each business request in the current time period belongs, and expands the thread capacity for each service level respectively: according to the current number of requests corresponding to the service level and the current thread response time, the predicted number of requests corresponding to the service level in the next time period is determined; if the predicted number of requests does not match the current number of threads corresponding to the service level, a thread expansion rule corresponding to the service level is generated, a new thread is created based on the thread expansion rule, and the newly created thread is associated with the service level. Compared with the traditional flow control method set based on the application or interface dimension, on the one hand, expanding the thread capacity for each service level can achieve the mutual independence of different service levels, ensure the dynamic allocation of resources, and enable important businesses to be given priority. On the other hand, by accurately predicting the predicted number of requests corresponding to the service level in the next time period, automatic thread expansion is achieved to ensure that the actual number of threads after the new threads are added matches the future business flow rate, so as to ensure the response speed and processing capacity of the business, and improve the overall performance of the system and user experience.

[0017] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 It is a system architecture diagram of a business processing provided by an embodiment of the present invention;

[0020] Figure 2 It is a flowchart of a thread expansion method provided by an embodiment of the present invention;

[0021] Figure 3 It is a flowchart of another thread expansion method provided by an embodiment of the present invention;

[0022] Figure 4 It is a structural schematic diagram of a thread expansion device provided by an embodiment of the present invention;

[0023] Figure 5 It is a schematic diagram of the structure of a gateway provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "goal", "history", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] Figure 1 1 is a system architecture diagram of a business processing provided by an embodiment of the present invention. Figure 1 As shown, the business processing system includes: a client, a gateway and a server. The client is connected to the gateway for communication, and the gateway is connected to the server for communication. The client is loaded on a user device (such as a smart phone, a tablet computer, etc.). The gateway is configured with several threads. In the present invention, the number of threads configured in the gateway is variable.

[0027] After the user sends the service request to the gateway through the client, the gateway can aggregate the service requests sent by each client to form a service request queue, and then put the service requests into the thread in a certain order. The thread will pass the service request to the server for service processing and return the processing result. Usually, a thread can only process one service request at a time.

[0028] Figure 2 is a flow chart of a thread expansion method provided by an embodiment of the present invention. This embodiment is applicable to the case where a gateway performs thread expansion according to a service request. The method can be executed by a thread expansion device. The thread expansion device can be implemented in the form of hardware and / or software. The thread expansion device can be configured in Figure 1In the gateway (such as the inlet gateway) of the business processing system shown in FIG. Figure 2 As shown, the method includes:

[0029] S110 , obtaining service requests in the current time period, and determining the service level to which each service request belongs, wherein one service level corresponds to at least one thread.

[0030] The thread expansion method provided by the present invention can be executed periodically, that is, executed once every fixed time length to ensure efficient use of system resources. The fixed time length (that is, the length of the current time period and the length of the next time period involved in the present invention) can be set according to actual needs, for example, the fixed time length is 1ms, 10ms, 50ms, 100ms, 500ms, 1s, 3s, 5s, etc.

[0031] In the present invention, the current time period is the time period corresponding to the fixed time length calculated forward from the current moment. The business request can be any request related to financial business, such as various transaction requests and query requests between users and financial institutions. Among them, the transaction request can be a deposit and withdrawal request, a loan request, an electronic payment request, a transfer request, etc.; the query request can be an account query request, a transaction query request, etc.

[0032] Specifically, the gateway may receive several service requests sent by various clients in the current time period, and determine the service level to which each service request belongs. The service level to which each service request belongs may be determined according to the request type of the service request.

[0033] Exemplarily, a comparison table of request types and service levels may be stored in the gateway. For each service request, after the gateway identifies the request type of the service request, the service level to which the service request belongs can be determined according to the comparison table of request types and service levels.

[0034] In addition, the present invention also groups several threads configured in the gateway, each group includes at least one thread, and one service level corresponds to at least one thread belonging to the same group. That is, at least one thread belonging to the same group is used to transmit the service request of the corresponding service level to the server for service processing.

[0035] For example, suppose there are five service levels, namely service level 1, service level 2, service level 3, service level 4 and service level 5. The higher the service level, the more important the service request; the lower the service level, the less important the service request. Currently, 50 threads are configured in the gateway, of which threads 1-10 are a group, threads 11-20 are a group, threads 21-30 are a group, threads 31-40 are a group, and threads 41-50 are a group. Service level 1 corresponds to threads 1-10, and threads 1-10 are used to process service requests of service level 1; service level 2 corresponds to threads 11-20, and threads 11-20 are used to process service requests of service level 2; service level 3 corresponds to threads 21-30, and threads 21-30 are used to process service requests of service level 3; service level 4 corresponds to threads 31-40, and threads 31-40 are used to process service requests of service level 4; service level 5 corresponds to threads 41-50, and threads 41-50 are used to process service requests of service level 5.

[0036] Since business requests change in real time, the current number of threads corresponding to the service level of the current time period may not be suitable for the next time period, so thread adjustment can be performed for each service level (that is, the following steps S120-S130 can be performed for each service level). The data basis for performing thread adjustment is the number of business requests in the current time period.

[0037] S120: For each service level, determine the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time.

[0038] In one embodiment, the service levels can be arranged in order, and the gateway adjusts the threads for each service level in turn according to the order of the service levels. Preferably, the service levels are arranged in order from high to low importance. In this way, it can be ensured that the threads of the service levels with high importance are expanded first, thereby ensuring that important services can be processed first.

[0039] In an optional embodiment, a method for determining the predicted number of requests corresponding to the service level in the next time period based on the current number of requests corresponding to the service level and the current thread response time may include: judging whether the current thread response time corresponding to the service level meets the requirements of the service level; if so, the current number of requests may be used as the predicted number of requests corresponding to the service level in the next time period; if not, a change coefficient may be determined based on the current thread response time, and the product of the change coefficient and the current number of requests may be used as the predicted number of requests corresponding to the service level in the next time period.

[0040] In another optional embodiment, a method for determining the predicted number of requests corresponding to the service level in the next time period based on the current number of requests corresponding to the service level and the current thread response time may include: querying in a preset statistical model based on the current number of requests corresponding to the service level and the current thread response time to determine the predicted number of requests corresponding to the service level in the next time period.

[0041] A preset statistical model can be a tool built based on historical data to estimate, predict or explain the relationship between one or more variables.

[0042] Compared with the previous implementation, the predicted number of requests determined based on the preset statistical model is more accurate and faster, providing a good data basis for determining subsequent thread expansion rules and ensuring the timeliness of thread expansion.

[0043] S130: If the predicted request quantity does not match the current thread quantity corresponding to the service level, a thread expansion rule corresponding to the service level is generated, a new thread is created based on the thread expansion rule, and the new thread is associated with the service level.

[0044] In one embodiment, a method for determining whether the predicted number of requests matches the current number of threads corresponding to the service level may be: determining the predicted thread response time corresponding to the service level based on the predicted number of requests and the current number of threads corresponding to the service level; and then determining whether the predicted thread response time meets the requirements of the service level.

[0045] For example, assuming that the predicted number of requests is 200, the current number of threads corresponding to the service level is 50, and the predicted thread response time corresponding to the service level determined based on the predicted number of requests and the current number of threads corresponding to the service level is 200ms. When the service level requires the thread response time to be no greater than 100ms, since the predicted thread response time of 200ms is greater than 100ms, it is determined that the predicted number of requests does not match the current number of threads corresponding to the service level, and thread expansion is required. When the service level requires the thread response time to be no greater than 300ms, since the predicted thread response time of 200ms is less than 300ms, it is determined that the predicted number of requests matches the current number of threads corresponding to the service level, and the process ends.

[0046] In an optional implementation, a method for generating thread expansion rules corresponding to a service level, creating a new thread based on the thread expansion rules, and associating the new thread with the service level may include: obtaining a maximum expansion number of threads and a maximum expansion ratio corresponding to the service level, wherein the sum of the maximum expansion ratios corresponding to all service levels is equal to 1; then calculating the maximum expansion number corresponding to the service level based on the maximum expansion number of threads and the maximum expansion ratio; determining the actual expansion number based on the maximum expansion number and creating a new thread, and associating the new thread with the service level.

[0047] In this implementation, the actual expansion number is smaller than the maximum expansion number.

[0048] In another optional implementation, a method for generating thread expansion rules corresponding to a service level, creating new threads based on the thread expansion rules, and associating the newly created threads with the service level may include: obtaining a maximum thread expansion number and a maximum expansion ratio corresponding to the service level, wherein the sum of the maximum expansion ratios corresponding to all service levels is equal to 1; then determining a number of sequentially arranged thread expansion numbers based on the maximum thread expansion number and the maximum expansion ratio, creating new threads in batches according to the order of arrangement of the thread expansion numbers, and associating the newly created threads with the service level.

[0049] In this implementation, the sum of the capacity expansion numbers of all threads is equal to the product of the maximum capacity expansion number of threads and the maximum capacity expansion ratio corresponding to the service level.

[0050] Compared with the previous implementation, creating new threads in batches according to the order of thread expansion quantity can achieve step-by-step adjustment of threads, which is smoother, does not increase the system burden, and improves system stability.

[0051] Optionally, after step S130 is executed, the newly created thread may be destroyed to restore the original thread configuration. Specifically, the newly created thread may be destroyed based on a thread destruction instruction, or the newly created thread may be automatically destroyed after a period of time. The embodiment of the present invention does not impose any specific restrictions on this.

[0052] The embodiment of the present invention provides a thread expansion method, including: obtaining business requests in the current time period, and determining the service level to which each business request belongs, wherein one service level corresponds to at least one thread; for each service level, determining the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time; if the predicted number of requests does not match the current number of threads corresponding to the service level, then generating a thread expansion rule corresponding to the service level, creating a new thread based on the thread expansion rule, and associating the newly created thread with the service level. The technical solution of the embodiment of the present invention determines the service level to which each business request in the current time period belongs, and performs thread expansion for each service level respectively: determining the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time; if the predicted number of requests does not match the current number of threads corresponding to the service level, then generating a thread expansion rule corresponding to the service level, creating a new thread based on the thread expansion rule, and associating the newly created thread with the service level. Compared with the traditional flow control method based on application or interface dimensions, on the one hand, thread expansion for each service level can achieve the independence of different service levels, ensure the dynamic allocation of resources, and give priority to important services. On the other hand, by accurately predicting the number of predicted requests corresponding to the service level in the next time period, automatic thread expansion is achieved to ensure that the actual number of threads after the new threads are added matches the future business flow rate, so as to ensure the response speed and processing capacity of the business, and improve the overall performance of the system and user experience.

[0053] Figure 3 FIG. 1 is a flow chart of another thread expansion method provided by an embodiment of the present invention. Based on the above embodiment, this embodiment provides a specific method for constructing a statistical model and a specific method for generating thread expansion rules. Figure 3 As shown, the method includes:

[0054] S201. Obtain service requests in the current time period, and determine the service level to which each service request belongs, wherein one service level corresponds to at least one thread.

[0055] The thread expansion method provided by the present invention can be executed periodically, that is, executed once every fixed time length to ensure efficient use of system resources. The current time period is the time period corresponding to the fixed time length calculated forward from the current moment to the end moment. The business request can be any request related to financial business, such as various transaction requests and query requests between users and financial institutions. Among them, the transaction request can be a deposit and withdrawal request, a loan request, an electronic payment request, a transfer request, etc.; the query request can be an account query request, a transaction query request, etc.

[0056] Specifically, the gateway may receive several service requests sent by various clients in the current time period, and determine the service level to which each service request belongs. The service level to which each service request belongs may be determined according to the request type of the service request.

[0057] Exemplarily, a comparison table of request types and service levels may be stored in the gateway. For each service request, after the gateway identifies the request type of the service request, the service level to which the service request belongs can be determined according to the comparison table of request types and service levels.

[0058] In addition, the present invention also groups several threads configured in the gateway, each group includes at least one thread, and one service level corresponds to at least one thread belonging to the same group. That is, at least one thread belonging to the same group is used to transmit the service request of the corresponding service level to the server for service processing.

[0059] Since business requests change in real time, the current number of threads corresponding to the service level of the current time period may not be suitable for the next time period, so thread adjustment can be performed for each service level (that is, the following steps S202-S211 can be performed for each service level). The data basis for performing thread adjustment is the number of business requests in the current time period.

[0060] S202: For each service level, query in a preset statistical model according to the current number of requests and the current thread response time corresponding to the service level to determine target statistical information.

[0061] In one embodiment, the statistical model may be determined through the following two steps.

[0062] Step 1: Obtain historical transaction information, historical thread information, and time correlation information of a historical time period, wherein the time correlation information is used to describe holiday information and / or operation activity information within the historical time period.

[0063] The value of the historical time period can be set according to actual needs. It is understandable that the larger the value of the historical time period, the more resources / computing power is required to build the statistical model, and the more accurate the statistical model is; the smaller the value of the historical time period, the fewer resources / computing power is required to build the statistical model, and the faster the statistical model is built. Usually, the value of the historical time period can be 1 month, 3 months, half a year, 1 year, 2 years, 3 years, 5 years, 10 years, etc.

[0064] Historical transaction information may include, but is not limited to: transaction data, which is used to analyze the activity of transaction activities; transaction time, which is used to record the exact time when the transaction occurred; and transaction type, which is used to distinguish different transactions.

[0065] The historical thread information may include, but is not limited to, thread usage (such as actual thread usage and actual thread response time), which is used to analyze system load and performance.

[0066] Time-related information is used to describe holiday information and / or operational activity information within a historical period. Holiday information is used to analyze the impact of holidays on business; operational activity information is used to record the time and type of operational activities and to analyze the impact of operational activities on business.

[0067] Historical transaction information, historical thread information and time correlation information of historical time periods can provide data support for the subsequent construction of statistical models.

[0068] Optionally, after obtaining the historical transaction information, historical thread information and time correlation information of the historical time period, operations such as deduplication, deletion of invalid and erroneous data, etc. may be performed on the information to ensure the accuracy of the data.

[0069] Optionally, historical transaction information, historical thread information and time correlation information may be integrated to form a complete data set, and a time series may be formed in chronological order to facilitate information search and application.

[0070] Step 2: Build a statistical model based on historical transaction information, historical thread information and time correlation information.

[0071] The process of building a statistical model usually includes steps such as model setting, parameter estimation, model testing, and model optimization.

[0072] In one embodiment, based on the current number of requests and the current thread response time corresponding to the service level, a query is performed in a preset statistical model, and the method for determining the target statistical information may include: based on the current number of requests and the current thread response time corresponding to the service level, a query is performed in a preset statistical model, and a piece of information that is most similar to the current number of requests and the current thread response time is determined, and this piece of information is used as the target statistical information.

[0073] S203: Determine the predicted number of requests corresponding to the service level in the next time period according to the target statistical information.

[0074] The number of requests in the next time period of the time period corresponding to the target statistical information in the statistical model is used as the predicted number of requests corresponding to the service level in the next time period.

[0075] S204: Determine whether the predicted request quantity matches the current thread quantity corresponding to the service level. If so, the process ends; if not, proceed to step S205.

[0076] In one embodiment, a method for determining whether the predicted number of requests matches the current number of threads corresponding to the service level may be: determining the predicted thread response time corresponding to the service level based on the predicted number of requests and the current number of threads corresponding to the service level; and then determining whether the predicted thread response time meets the requirements of the service level.

[0077] For example, assuming that the predicted number of requests is 200, the current number of threads corresponding to the service level is 50, and the predicted thread response time corresponding to the service level determined based on the predicted number of requests and the current number of threads corresponding to the service level is 200ms. When the service level requires the thread response time to be no greater than 100ms, since the predicted thread response time of 200ms is greater than 100ms, it is determined that the predicted number of requests does not match the current number of threads corresponding to the service level, and thread expansion is required. When the service level requires the thread response time to be no greater than 300ms, since the predicted thread response time of 200ms is less than 300ms, it is determined that the predicted number of requests matches the current number of threads corresponding to the service level, and the process ends.

[0078] S205, obtaining the current resource usage rate of the server, and determining whether the current resource usage rate is greater than the resource usage threshold corresponding to the service level. If yes, execute step S206; if no, execute step S207.

[0079] In the present invention, although the gateway determines that the number of predicted requests does not match the current number of threads corresponding to the service level, and thread expansion is required, thread expansion may not be achieved in practice. This is because if the current resource utilization rate of the server is too high, even if the gateway expands the thread capacity, the server does not have more resources to handle the business, resulting in meaningless thread expansion and even increasing the resource overhead of the system. Therefore, after step S204 is executed, the gateway also needs to obtain the current resource utilization rate of the server and determine whether the current resource utilization rate is greater than the resource utilization threshold corresponding to the service level. When the current resource utilization rate is greater than the resource utilization threshold corresponding to the service level, it means that the current resource utilization rate of the server is too high and thread expansion is not suitable. At this time, the current number of threads corresponding to the service level can be maintained unchanged. When the current resource utilization rate is less than or equal to the resource utilization threshold corresponding to the service level, it means that the current resource utilization rate of the server is within the normal range and thread expansion can be performed. At this time, the step of generating thread expansion rules corresponding to the service level can be continued.

[0080] It should be noted that the resource usage threshold values ​​corresponding to different service levels can be the same or different. Generally, the higher the importance of the service level, the larger the value of the corresponding resource usage threshold; the lower the importance of the service level, the smaller the value of the corresponding resource usage threshold. In this way, the dynamic allocation of resources can be further guaranteed, so that important services can be given priority.

[0081] S206: Maintain the current number of threads corresponding to the service level unchanged.

[0082] S207: Obtain the maximum expansion number of threads and the maximum expansion ratio corresponding to the service level, wherein the sum of the maximum expansion ratios corresponding to all service levels is equal to 1.

[0083] For example, assuming that the maximum expansion number of threads is 500, and there are five service levels, namely service level 1, service level 2, service level 3, service level 4, and service level 5. The maximum expansion ratio corresponding to service level 5 is 40%, the maximum expansion ratio corresponding to service level 4 is 25%, the maximum expansion ratio corresponding to service level 3 is 15%, the maximum expansion ratio corresponding to service level 2 is 10%, and the maximum expansion ratio corresponding to service level 1 is 10%. Then, the maximum expansion number corresponding to service level 5 is 200, the maximum expansion number corresponding to service level 4 is 125, the maximum expansion number corresponding to service level 3 is 75, the maximum expansion number corresponding to service level 2 is 50, and the maximum expansion number corresponding to service level 1 is 50.

[0084] S208: Generate thread expansion rules corresponding to the service level according to the maximum expansion number and the maximum expansion ratio of threads.

[0085] The thread expansion rule includes several thread expansion quantities arranged in order, wherein the sum of all thread expansion quantities is equal to the product of the maximum thread expansion number and the maximum expansion ratio corresponding to the service level. The thread expansion rule is used to indicate that new threads are created in batches according to the arrangement order of the thread expansion quantities.

[0086] For example, taking the above service level 5 as an example, the maximum expansion number corresponding to service level 5 is 200, and the thread expansion rules corresponding to service level 5 are 100, 60 and 40. Then, when creating new threads, 100 threads can be created for the first time, 60 threads can be created for the second time, and 40 threads can be created for the third time. In this way, the step-by-step adjustment of threads can be achieved, the adjustment is smoother, the system burden will not be increased, and the stability of the system is improved.

[0087] S209: Create a new thread based on the thread expansion rule, and associate the newly created thread with the service level.

[0088] S210: Get a thread destroy instruction.

[0089] S211. Destroy the newly created thread according to the thread destruction instruction.

[0090] Combining steps S210 and S211, it can be seen that after creating a new thread based on the thread expansion rule and associating the new thread with the service level, the gateway can also destroy the new thread to restore the original thread configuration. In this way, the thread can be readjusted after the load becomes stable to avoid resource waste.

[0091] The embodiment of the present invention provides a thread expansion method, including: obtaining business requests in the current time period, and determining the service level to which each business request belongs, wherein one service level corresponds to at least one thread; for each service level, determining the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time; if the predicted number of requests does not match the current number of threads corresponding to the service level, then generating a thread expansion rule corresponding to the service level, creating a new thread based on the thread expansion rule, and associating the newly created thread with the service level. The technical solution of the embodiment of the present invention determines the service level to which each business request in the current time period belongs, and performs thread expansion for each service level respectively: determining the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time; if the predicted number of requests does not match the current number of threads corresponding to the service level, then generating a thread expansion rule corresponding to the service level, creating a new thread based on the thread expansion rule, and associating the newly created thread with the service level. Compared with the traditional flow control method based on application or interface dimensions, on the one hand, thread expansion for each service level can achieve the independence of different service levels, ensure the dynamic allocation of resources, and give priority to important services. On the other hand, by accurately predicting the number of predicted requests corresponding to the service level in the next time period, automatic thread expansion is achieved to ensure that the actual number of threads after the new threads are added matches the future business flow rate, so as to ensure the response speed and processing capacity of the business, and improve the overall performance of the system and user experience.

[0092] Figure 4 Schematic diagram of the structure of a thread expansion device provided by an embodiment of the present invention. Figure 4 As shown, the device includes: a request receiving module 401, a level determining module 402, a prediction module 403, a rule generating module 404 and a thread adjusting module 405.

[0093] Request receiving module 401, used to obtain the service request of the current time period;

[0094] A level determination module 402, used to determine the service level to which each business request belongs, wherein one service level corresponds to at least one thread;

[0095] Prediction module 403, for determining, for each service level, the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time;

[0096] A rule generation module 404, configured to generate a thread expansion rule corresponding to the service level if the predicted request quantity does not match the current thread quantity corresponding to the service level;

[0097] The thread adjustment module 405 is used to create a new thread based on the thread expansion rule and associate the new thread with a service level.

[0098] Optionally, the prediction module 403 is specifically used to query in a preset statistical model according to the current number of requests corresponding to the service level and the current thread response time to determine the target statistical information; based on the target statistical information, determine the predicted number of requests corresponding to the service level in the next time period.

[0099] Optionally, the prediction module 403 is also used to determine a statistical model, wherein the statistical model is determined by the following method: obtaining historical transaction information, historical thread information and time correlation information of a historical time period, wherein the time correlation information is used to describe holiday information and / or operational activity information within the historical time period; and constructing a statistical model based on the historical transaction information, historical thread information and time correlation information.

[0100] Optionally, the gateway is connected to the server for communication; the rule generation module 404 is also used to obtain the current resource utilization rate of the server; if the current resource utilization rate is greater than the resource utilization threshold corresponding to the service level, the current number of threads corresponding to the service level is maintained unchanged; if the current resource utilization rate is less than or equal to the resource utilization threshold corresponding to the service level, the step of generating thread expansion rules corresponding to the service level is continued.

[0101] Optionally, the rule generation module 404 is specifically used to obtain the maximum expansion number of threads and the maximum expansion ratio corresponding to the service level, wherein the sum of the maximum expansion ratios corresponding to all service levels is equal to 1; and generate thread expansion rules corresponding to the service level according to the maximum expansion number of threads and the maximum expansion ratio.

[0102] Optionally, the thread expansion rule includes several thread expansion quantities arranged in order, wherein the sum of all thread expansion quantities is equal to the product of the maximum thread expansion number and the maximum expansion ratio corresponding to the service level, and the thread expansion rule is used to indicate that new threads are created in batches according to the arrangement order of the thread expansion quantities.

[0103] Optionally, the thread adjustment module 405 is further configured to obtain a thread destroy instruction; and destroy the newly created thread according to the thread destroy instruction.

[0104] The thread expansion device provided in the embodiment of the present invention can execute the thread expansion method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0105] Figure 5 Schematic diagram of a gateway structure provided by an embodiment of the present invention. Figure 5 As shown, the gateway 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In RAM 13, various programs and data required for the operation of the gateway 10 can also be stored. The processor 11, ROM 12 and RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0106] A number of components in the gateway 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the gateway 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0107] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a thread expansion method.

[0108] In some embodiments, the thread expansion method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the gateway 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the thread expansion method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the thread expansion method in any other appropriate manner (e.g., by means of firmware).

[0109] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0110] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0111] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0112] To provide interaction with a user, the systems and techniques described herein may be implemented on a gateway having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the gateway. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0113] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0114] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0115] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the thread expansion method provided by any embodiment of the present invention.

[0116] In the process of implementation, the computer program product can be written in one or more programming languages ​​or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).

[0117] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0118] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0119] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A thread expansion method, characterized in that: Applied to a gateway; the method comprises: Obtaining service requests in the current time period, and determining the service level to which each service request belongs, wherein one service level corresponds to at least one thread; For each of the service levels, determining the predicted number of requests corresponding to the service level in the next time period according to the current number of requests corresponding to the service level and the current thread response time; If the predicted request quantity does not match the current thread quantity corresponding to the service level, a thread expansion rule corresponding to the service level is generated, a new thread is created based on the thread expansion rule, and the new thread is associated with the service level.

2. The thread expansion method according to claim 1, characterized in that: The determining, according to the current number of requests corresponding to the service level and the current thread response time, the predicted number of requests corresponding to the service level in the next time period includes: According to the current number of requests and the current thread response time corresponding to the service level, query in a preset statistical model to determine target statistical information; The predicted number of requests corresponding to the service level in the next time period is determined according to the target statistical information.

3. The thread expansion method according to claim 2, characterized in that: The statistical model is determined by the following method: Acquire historical transaction information, historical thread information, and time correlation information of a historical time period, wherein the time correlation information is used to describe holiday information and / or operation activity information within the historical time period; The statistical model is constructed according to the historical transaction information, the historical thread information and the time correlation information.

4. The thread expansion method according to claim 1, characterized in that: The gateway is in communication connection with the server; before generating the thread expansion rule corresponding to the service level, the method further includes: Obtaining the current resource usage of the server; If the current resource usage rate is greater than the resource usage threshold corresponding to the service level, the current number of threads corresponding to the service level is maintained unchanged; If the current resource usage rate is less than or equal to the resource usage threshold corresponding to the service level, then continue to execute the step of generating a thread expansion rule corresponding to the service level.

5. The thread expansion method according to claim 1, characterized in that: The generating of the thread expansion rule corresponding to the service level includes: Obtaining a maximum expansion number of threads and a maximum expansion ratio corresponding to the service level, wherein the sum of the maximum expansion ratios corresponding to all the service levels is equal to 1; A thread expansion rule corresponding to the service level is generated according to the maximum expansion number of threads and the maximum expansion ratio.

6. The thread expansion method according to claim 5, characterized in that: The thread expansion rule includes a number of thread expansion quantities arranged in order, wherein the sum of all thread expansion quantities is equal to the product of the maximum thread expansion number and the maximum expansion ratio corresponding to the service level, and the thread expansion rule is used to indicate that new threads are created in batches according to the arrangement order of the thread expansion quantities.

7. The thread expansion method according to claim 1, characterized in that: After creating a new thread based on the thread expansion rule and associating the new thread with the service level, the method further includes: Get thread destruction instructions; According to the thread destroy instruction, the newly created thread is destroyed.

8. A gateway, characterized in that: The gateway comprises: at least one processor; and a memory in communication with the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the thread expansion method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the thread expansion method according to any one of claims 1 to 7 when executed.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the thread expansion method according to any one of claims 1 to 7.