A microservice call method, device, and storage medium
In the microservice calling method, the micro server with the lowest evaluation value is selected based on the system nanoseconds, average access time estimation value and regional weight to process financial services, which solves the problem of large gap in waiting time between customers and improves the user experience.
Patent Information
- Application Number
- CN202310860607.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-07-13
AI Technical Summary
In the prior art, microservice calling methods lead to a large gap in service processing waiting time between customers, affecting user preference. Especially when the number of visits is huge during peak financial services, the random load strategy cannot effectively balance the microserver load.
By receiving financial services forwarded by routing equipment, alternative micro servers are randomly selected based on the system nanoseconds and micro server code, combined with the average estimated access time, the number of requests in transit, and the regional weight, the load rate and evaluation value of each micro server are calculated, and the micro server with the lowest evaluation value is selected to handle financial services.
It achieves balancing micro-server processing speed, reduces the waiting time gap between customers' services, improves user experience, and handles financial services by selecting micro-servers closest to users and with lighter loads.
Smart Images

Figure CN116866354B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of microservice calls, and in particular to a microservice call method, device, and storage medium. Background Art
[0002] Currently, for a banking business system, the financial business system is usually designed as a microservice architecture, that is, several microservices are used to process different businesses. For each financial business, the banking business system will open several microservices to process the same type of business. In the prior art, for the selection of microservices, simple load strategies such as round-robin and random are often used. In this random load strategy, when a microservice with relatively strong processing power and relatively idle is randomly selected, the processing of some users' businesses is relatively fast. When the bank conducts financial businesses in multiple provinces or the whole country, the demand for financial business handling is very large. When encountering the peak period of financial business handling, the number of accesses at the same time is huge. Therefore, when the existing random load strategy randomly selects a microservice with relatively weak processing power and relatively busy, the processing of some users' financial businesses is relatively slow, and the difference in the waiting time for financial business processing among different customers is relatively large, which extremely affects the user's favorability. Summary of the Invention
[0003] Aiming at the above problems in the prior art, the purpose of this specification is to provide a microservice call method, device, and storage medium to solve the problem that randomly selecting a microservice in the prior art makes the difference in the waiting time for business processing among customers relatively large and extremely affects the user's favorability.
[0004] To solve the above technical problems, the specific technical solutions of this specification are as follows:
[0005] On the one hand, this specification provides a microservice call method, including:
[0006] Receiving a financial business forwarded by a routing device;
[0007] Randomly selecting at least two microservices as alternative microservices from all microservices according to the system nanoseconds and the server code corresponding to the microservice;
[0008] Determining the load rate of each of the alternative microservices according to the predicted average access time and the number of requests in transit, where the predicted average access time is determined based on the previous prediction value, the current measurement value, and the weight parameter;
[0009] Determining the regional weight of each of the alternative microservices according to the IP address corresponding to the financial business and the IP corresponding to the alternative microservice;
[0010] Determine the evaluation value of each of the alternative micro-servers according to the load rate of the alternative micro-servers and their corresponding regional weights;
[0011] Select the alternative micro-server with the lowest evaluation value to process the financial service.
[0012] As an embodiment of this specification, the step of randomly selecting at least two micro-servers from all micro-servers as alternative micro-servers according to the system nanoseconds and the server code corresponding to the micro-server further includes:
[0013] Generate at least two random numbers according to the formula:
[0014] [node] = (λ * C)^T % CS
[0015] where [node] is a random number, λ is the server code corresponding to the micro-server, C is a preset constant, T is the system nanoseconds, CS is the set of server codes corresponding to all micro-servers, and % is the addressing symbol;
[0016] Match the random numbers with the server codes corresponding to the micro-servers to obtain at least two micro-servers as alternative micro-servers.
[0017] As an embodiment of this specification, the step of determining the load rate of each of the alternative micro-servers according to the estimated average access time and the number of in-flight requests further includes:
[0018] Calculate the load rate of each of the alternative micro-servers according to the formula:
[0019]
[0020] where load is the load rate, v t is the estimated average access time, and I is the number of in-flight requests for each alternative micro-server.
[0021] As an embodiment of this specification, the estimated average access time is determined according to the previous estimate, the current measurement value, and the weight parameter, and further includes:
[0022] Calculate the estimated average access time according to the formula:
[0023] v t = βv t-1 + (1 - β)θ t
[0024] where v t is the estimated average access time, β is the weight parameter, and the value range is 0 < β < 1; θ tis the measured value at the current moment; the value range of t: 1, 2, 3, …… n, v t-1 is the estimated value of the average access time at the previous moment.
[0025] As an embodiment of this specification, the weight parameter is determined using the following formula:
[0026] β = e -(Δt / k)
[0027] where β is the weight parameter, Δt represents the time interval between two requests, which is the time between the current moment request and the previous moment request, and k is a preset proportionality coefficient.
[0028] As an embodiment of this specification, determining the regional weight of each of the alternative microservices according to the IP address corresponding to the financial service and the IP corresponding to the alternative microservice further includes:
[0029] Determine whether the IP address corresponding to the financial service and the IP corresponding to the alternative microservice belong to the same geographical section, where the geographical section is determined according to the coordinates corresponding to the IP;
[0030] If they belong to the same geographical section, the regional weight of the alternative microservice is the first regional weight;
[0031] If they do not belong to the same geographical section, determine the regional weight of the alternative microservice according to the distance between the IP address corresponding to the financial service and the IP corresponding to the alternative microservice.
[0032] As an embodiment of this specification, the determining the regional weight of the alternative microservice according to the distance between the IP address corresponding to the financial service and the IP corresponding to the alternative microservice further includes:
[0033] Calculate the regional weight of the alternative microservice according to the following formula:
[0034]
[0035] where γ is the regional weight of the alternative microservice, x1 is the abscissa of the financial service sending location obtained according to the IP address corresponding to the financial service, y1 is the ordinate of the financial service sending location obtained according to the IP address corresponding to the financial service, x2 is the abscissa of the alternative microservice obtained according to the IP corresponding to the alternative microservice, and y2 is the ordinate of the alternative microservice obtained according to the IP corresponding to the alternative microservice.
[0036] As an embodiment of this specification, determining the evaluation value of each of the alternative microservices according to the load rate of the alternative microservice and its corresponding regional weight further includes:
[0037] τ = load × γ
[0038] Where τ is the evaluation value of the alternative microservice, load is the load rate of the alternative microservice, and γ is the regional weight corresponding to the load rate of the alternative microservice.
[0039] On the other hand, this specification also provides a microservice call device, including:
[0040] An instruction receiving unit, configured to receive financial services forwarded by a routing device;
[0041] A server selection unit, configured to randomly select at least two microservices as alternative microservices from all microservices according to the system nanoseconds and the server code corresponding to the microservice;
[0042] A load rate calculation unit, configured to determine the load rate of each of the alternative microservices according to the estimated average access time and the number of requests in transit, where the estimated average access time is determined according to the previous moment's estimate, the current moment's measurement value, and the weight parameter;
[0043] A regional weight calculation unit, configured to determine the regional weight of each of the alternative microservices according to the IP address corresponding to the financial service and the IP corresponding to the alternative microservice;
[0044] An evaluation value calculation unit, configured to determine the evaluation value of each of the alternative microservices according to the load rate of the alternative microservice and its corresponding regional weight;
[0045] An instruction sending unit, configured to select the alternative microservice with the lowest evaluation value to process the financial service.
[0046] On the other hand, this specification also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements the microservice call method according to any one of the above.
[0047] On the other hand, this specification also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the microservice call method according to any one of the above.
[0048] By adopting the above technical solution, the financial services forwarded by the routing device can be received to send the external financial services to the internal system of the bank; by randomly selecting at least two microservices as alternative microservices from all microservices according to the system nanoseconds and the server code corresponding to the microservice, the computing amount required for subsequently determining the evaluation values of each microservice can be reduced, and the processing speed of selecting a microservice to process the online transaction request and the time required to select a microservice are balanced; by determining the load rate of each of the alternative microservices according to the predicted average access time and the number of in-flight requests, where the predicted average access time is determined based on the previous prediction value, the current measurement value, and the weight parameter, the average access time of each alternative microservice and the number of in-flight requests of each microservice can be determined. The average access time characterizes the processing speed of each microservice for the online transaction request instruction, and the number of in-flight requests characterizes the number of online transaction request instructions to be processed by each microservice; by determining the regional weight of each of the alternative microservices according to the IP address corresponding to the financial service and the IP corresponding to the alternative microservice, the microservice closest to the user who initiates the financial service can be selected to process the financial service. When the financial service processing fails, it is convenient for the user to go to the business point near the microservice for manual processing; by determining the evaluation value of each of the alternative microservices according to the load rate of the alternative microservice and its corresponding regional weight, scoring of each microservice can be achieved, and the score can objectively characterize the processing speed of each microservice for the financial service; by selecting the alternative microservice with the lowest evaluation value to process the financial service, a microservice with a relatively fast processing speed for the financial service can be selected to process the online transaction instruction, so as to reduce the large difference in the business processing waiting time among customers, thereby enhancing the user's favorability.
[0049] To make the above and other purposes, features, and advantages of this specification more obvious and understandable, the following specifically gives preferred embodiments and, in conjunction with the accompanying drawings, makes the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] To more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of this specification. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0051] Figure 1 Shows the schematic diagram of the microservice system architecture in the embodiment of this specification;
[0052] Figure 2Shows the schematic diagram of the steps of a microservice call method according to an embodiment of this specification;
[0053] Figure 3 Shows the schematic diagram of the regional weight determination method according to an embodiment of this specification;
[0054] Figure 4 Shows the schematic diagram of a microservice call device according to an embodiment of this specification;
[0055] Figure 5 Shows the schematic diagram of a computer device according to an embodiment of this specification.
[0056] Description of the reference numerals in the drawings:
[0057] 11. Terminal;
[0058] 12. Routing device;
[0059] 13. Selector;
[0060] 14. Interface device;
[0061] 15. Microserver;
[0062] 401. Instruction receiving unit;
[0063] 402. Server selection unit;
[0064] 403. Load rate calculation unit;
[0065] 404. Regional weight calculation unit;
[0066] 405. Evaluation value calculation unit;
[0067] 406. Instruction sending unit;
[0068] 502. Computer device;
[0069] 504. Processor;
[0070] 506. Memory;
[0071] 508. Driving mechanism;
[0072] 510. Input / output module;
[0073] 512. Input device;
[0074] 514. Output device;
[0075] 516. Presentation device;
[0076] 518. Graphical user interface;
[0077] 520. Network interface;
[0078] 522. Communication link;
[0079] 524. Communication bus. Detailed implementation manner
[0080] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this specification.
[0081] It should be noted that the terms "first", "second", etc. in the description and claims of this specification and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of this specification described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or equipment that includes a series of steps or units does not necessarily have to be limited to those clearly listed steps or units, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products or equipment.
[0082] It should be noted that the financial services in this specification include various services that require micro-servers for processing, such as online transaction instructions, online signing instructions, or online loans. Of course, it also includes various tasks that require human participation, including credit tasks, access tasks, etc. Those skilled in the art can design the micro-server to process the services according to needs, and this specification does not make any limitations in this regard.
[0083] As Figure 1 shown in the schematic diagram of the microservice system architecture, it includes: terminal 11, routing device 12, selector 13, interface device 14, and micro-server 15.
[0084] The terminal 11 is used to receive the operation instructions of the user and generate financial services. It should be noted that the types of terminals include mobile phones, tablets, computers, smart watches, or automatic terminals, etc.
[0085] As the initiator of the online transaction, the terminal directly faces the user, is responsible for assembling the content of the online transaction, which is formulated according to the requirements of the routing device. At the same time, the terminal exposes the entry of each function outward and finally receives the response content of the online transaction initiated by this device.
[0086] The routing device 12 is connected to the terminal and is used to forward the financial services to the bank's internal system.
[0087] Since there are many types of financial services, new transaction types need to be supported, and there are many devices for processing financial services, the message format is complex. In this specification, all requests and responses of financial services need to be processed by this routing device and then routed and forwarded, playing a role in unified processing and directional allocation.
[0088] Selector 13, which is respectively connected to the routing device, the interface device, and the micro server, is used to select a micro server that can process financial services relatively quickly through all the micro server information displayed by the interface device.
[0089] Interface device 14, which is respectively connected to the selector and the micro server, is used to receive the current running status returned by all micro servers and display it externally. In addition, the interface device can also prevent external direct access to the micro server, playing the role of a firewall.
[0090] Micro server 15 is used to process financial services. In this specification, there is a micro server cluster in the bank, and there are several micro servers in this cluster. Since the data processing capabilities of each micro server are different, and due to optimization issues, the processing speeds for different types of financial services are also different. Specifically, the hardware configurations of the first micro server and the second micro server are the same, including memory and processor, etc. When the first micro server is better optimized for two types of financial services A and B, the processing speeds of the first micro server for the two types of financial services A and B will be higher than those of the second micro server.
[0091] In addition, if the optimizations of the first micro server and the third micro server for various financial services are the same, then the only factor affecting the processing speeds of the first micro server and the third micro server for financial services is the hardware configuration. When the quality of the processor, memory, etc. of the third micro server is higher than that of the first micro server, the processing speed of the third micro server for financial services will be higher than that of the first micro server.
[0092] In this specification, a micro server is selected by the selector to process financial data. The following details the specific content of the selector selecting the micro server.
[0093] When the bank conducts financial services in multiple provinces or the whole country, the demand for handling financial services is very large. When encountering the peak period of handling financial services, the number of accesses at the same time is huge. Therefore, when the existing random load balancing strategy randomly selects a micro server with relatively weak processing capabilities and is relatively busy, the processing of financial services for some users is relatively slow, and the waiting times for financial services between different customers vary greatly, extremely affecting user satisfaction.
[0094] To solve the above problems, the embodiments of this specification provide a micro service invocation method, which can select a micro server that currently processes financial services relatively quickly to process financial services.Figure 2 This is a schematic diagram of the steps of a microservice call method provided by an embodiment of this specification. This specification provides the method operation steps as described in the embodiments or flowcharts, but based on routine or non-creative labor, there may be more or fewer operation steps. The step order listed in the embodiments is only one of the ways of the execution order of numerous steps and does not represent the only execution order. When the actual system or device product executes, it can be executed in the method order shown in the embodiments or the drawings or executed in parallel. Specifically, as Figure 2 shown, the method may include:
[0095] Step 201, receive the financial service forwarded by the routing device;
[0096] Step 202, randomly select at least two microservices as alternative microservices from all microservices according to the system nanosecond number and the server code corresponding to the microservice;
[0097] Step 203, determine the load rate of each of the alternative microservices according to the average access time consumption prediction value and the number of in-transit requests, where the average access time consumption prediction value is determined according to the prediction value at the previous moment, the measurement value at the current moment, and the weight parameter;
[0098] Step 204, determine the regional weight of each of the alternative microservices according to the IP address corresponding to the financial service and the IP corresponding to the alternative microservice;
[0099] Step 205, determine the evaluation value of each of the alternative microservices according to the load rate of the alternative microservice and its corresponding regional weight;
[0100] Step 206, select the alternative microservice with the lowest evaluation value to process the financial service.
[0101] By adopting the above technical solution, the financial services forwarded by the routing device can be received to send the external financial services to the internal system of the bank; by randomly selecting at least two micro-servers as alternative micro-servers from all the micro-servers according to the system nanoseconds and the server code corresponding to the micro-server, the computational effort required for subsequently determining the evaluation values of each micro-server can be reduced, and the processing speed of selecting a micro-server to process the online transaction request and the time required for selecting a micro-server are balanced; by determining the load ratio of each of the alternative micro-servers according to the estimated average access time and the number of requests in transit, where the estimated average access time is determined based on the previous estimate, the current measurement value, and the weight parameter, the average access time of each alternative micro-server and the number of requests in transit of each micro-server can be determined. The average access time characterizes the processing speed of each micro-server for the online transaction request instruction, and the number of requests in transit characterizes the number of online transaction request instructions to be processed by each micro-server; by determining the regional weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server, the micro-server closest to the user who initiates the financial service can be selected to process the financial service. When the financial service processing fails, it is convenient for the user to go to the business outlet near the micro-server for manual processing; by determining the evaluation value of each of the alternative micro-servers according to the load ratio of the alternative micro-server and its corresponding regional weight, the score of each micro-server can be achieved, and this score can objectively characterize the processing speed of each micro-server for the financial service; by selecting the alternative micro-server with the lowest evaluation value to process the financial service, a micro-server with a relatively fast processing speed for the financial service can be selected to process the online transaction instruction, so as to reduce the large gap in the business processing waiting time of customers, thereby enhancing the user's favorability.
[0102] As an embodiment of this specification, step 201: Receive the financial service forwarded by the routing device;
[0103] In this step, the financial service includes various services that require micro-servers for processing, such as online transaction instructions, online signing instructions, or online loans. Of course, it also includes various tasks that require human participation, including credit tasks, access tasks, etc.
[0104] When the user sends a financial service, the financial service carries the IP of the sending terminal, and the user's location can be accurately located through the IP.
[0105] Specifically, when the terminal used by the user is a bank automated teller machine, the IP of the sending location can be the IP of the bank self-service teller machine. When the terminal used by the user is a mobile phone, the access network of the mobile phone is the IP of the sending location.
[0106] Since the load rate and regional weight corresponding to each micro-server need to be calculated when selecting micro-servers in this specification, during the calculation process, when all micro-servers are included in the alternative micro-servers, if the computing power of the selector is weak, it takes a lot of time to calculate the load rate and regional weight of each micro-server, resulting in an extended processing time for financial services and a slow processing speed for financial services.
[0107] Therefore, those skilled in the art can select several micro-servers as alternative micro-servers to process financial services according to the actual computing performance of the selector, and this specification does not make any limitations in this regard.
[0108] As an embodiment of this specification, step 202, randomly selecting at least two micro-servers as alternative micro-servers from all micro-servers according to the system nanoseconds and the server code corresponding to the micro-server, further includes:
[0109] Generating at least two random numbers according to the formula:
[0110] [node]=(λ*C)^T%CS
[0111] Where [node] is a random number, λ is the server code corresponding to the micro-server, C is a pre-set constant, T is the system nanoseconds, CS is the set of server codes corresponding to all micro-servers, and % is the addressing symbol;
[0112] In this specification, the currentTimeMillis instruction is used to obtain the system nanoseconds (system.nanoTime), and the result returned is the number of milliseconds between the current system time and the time before January 1, 1970. The system nanoseconds itself has no physical meaning. Since the time point it is based on is random, it may be the current, past, or future time point, so the corresponding value is random.
[0113] CS(collection.size) is the set of server codes corresponding to all micro-servers. Specifically, the selector in this specification obtains the server codes corresponding to all micro-servers through the interface, and the obtaining method of this server code is
[0114] Schedule all microservices to access the interface every 5, 10, 15, 20, or 25 seconds. The interface sets the microservices that send normal access requests to the available state. When a microservice has not accessed the interface for more than 50 seconds, the interface actively accesses the microservice to check whether the service of the microservice is available. If an unavailable result is obtained through the query, the microservice is set to unavailable. At the same time, the interface updates the set stored locally with microservice codes and deletes the microservice code corresponding to the unavailable microservice. In this way, the microservice codes can be dynamically updated to ensure that all microservices that can be obtained by all selectors are available, avoiding the situation where the microservice becomes unavailable after acquisition, resulting in an overly long waiting time for users to process financial services.
[0115] The specific form of the microservice code can be the microservice code form table shown in Table 1:
[0116] Table 1
[0117] Micro-server name Micro-server code First micro-server A100 Second micro-server A200 Third micro-server A300
[0118] Using the above formula, several random numbers can be obtained from A100, A200, and A300. The random number can be any one of the three microservice codes. Through the selected microservice code, the corresponding microservice can be used as an alternative microservice.
[0119] As an embodiment of this specification, in step 203, determine the load rate of each of the alternative microservices according to the average estimated access time and the number of in-flight requests, where the average estimated access time is determined based on the previous estimated value, the current measured value, and the weight parameter;
[0120] According to the formula, calculate the load rate of each of the alternative microservices:
[0121]
[0122] where load is the load rate, v t is the average estimated access time, and I is the number of in-flight requests for each alternative microservice.
[0123] In this step, the number of in-flight requests represents the number of financial services currently queued for processing by the microservice. According to the above formula, it can be known that when the average estimated access times of two microservices are the same, the lower the number of in-flight requests, the lower the load rate. When the number of in-flight requests of two microservices is the same, the lower the average estimated access time, the lower the load rate. It can be seen that this formula conforms to the natural law. The lower the calculated load rate, the faster the microservice processes microservices. When the load rate is higher, it means that the microservice processes microservices more slowly.
[0124] Therefore, the load rate can characterize the ability of the micro-server to process microservices. The lower the load rate, the stronger the ability of the current micro-server to process microservices; the higher the load rate, the weaker the ability of the current micro-server to process microservices.
[0125] Specifically, the predicted value of the average access time is determined according to the predicted value at the previous moment, the measured value at the current moment, and the weight parameter, and further includes:
[0126] Calculate the predicted value of the average access time according to the formula:
[0127] v t =βv t-1 +(1 - β)θ t
[0128] where v t is the predicted value of the average access time, β is the weight parameter, and the value range is 0 < β < 1; θ t is the measured value at the current moment; the value range of t is: 1, 2, 3,..., n, and v t-1 is the predicted value of the average access time at the previous moment.
[0129] In this step, in practice, the measured value at the current moment obtained through computer instructions often does not match the actual processing time of the micro-server for financial services. The reasons for the difference between the two can include that the micro-server is still reading and writing the tail data of the previous financial service at the current moment. Therefore, it is necessary to combine the measured value at the current moment and the predicted value of the average access time at the previous moment to obtain the predicted value of the average access time at the current moment, that is, to perform weighted averaging using the predicted value of the average access at the previous moment and the measured value at the current moment, which can make the actual time used by the micro-server to process financial services approach the predicted value of the average access time, and make the calculated load value more accurately describe the ability of each micro-server.
[0130] Specifically, since the shorter the time interval between the micro-server's processing of two consecutive financial services, the more easily the micro-server's processing of the financial service at the current moment is affected by the tail data of the financial service at the previous moment, the variable of the weight parameter includes the time interval between two requests, which is the time between the current moment and the previous moment's request, and the value of the weight parameter is determined by this time interval.
[0131] The weight parameter is determined using the following formula:
[0132] β = e -(Δt / k)
[0133] where β is the weight parameter, Δt represents the time interval between two requests, which is the time between the current moment and the previous moment's request, and k is a preset proportionality coefficient.
[0134] Specifically, when the time interval between two requests is long, the weight parameter is small. The measured value at the current moment has a greater impact on the predicted value of the average access time at the current moment, that is, the measured value at the current moment can basically represent the predicted value of the average access time at the current moment. When the time interval between two requests is short, the weight parameter is small. The measured value at the current moment has a greater impact on the predicted value of the average access time at the current moment, that is, the measured value at the current moment can basically represent the predicted value of the average access time at the current moment.
[0135] In this specification, micro-servers may be distributed in various regions. When a user in region A selects a micro-server to process financial services, the existing random method may call a micro-service in region E, which is far from region A, to process the financial services. Since the policies for the same financial services vary in different regions, if the financial service processing in region E fails, the user in region A may not be able to go to region E, which will affect the speed of the user to handle financial services.
[0136] In order to enable the user to quickly find the corresponding physical business outlet to process the financial service after the failure of the financial service processing, when selecting a micro-server in this specification, it is preferable to select a micro-server in the same region to process the financial service.
[0137] Such as Figure 3 As shown in the schematic diagram of the regional weight determination method, as an embodiment of this specification, step 203, determining the regional weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server, further includes:
[0138] Step 301, determining whether the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server belong to the same geographical section, where the geographical section is determined according to the coordinates corresponding to the IP;
[0139] In this specification, there is a corresponding relationship between the section in the IP address and the region. A geographical section and IP address correspondence table is provided in the selector, such as the geographical section and IP address correspondence table shown in Table 2.
[0140] Table 2
[0141] IP address Geographical section ***.***.001.** First area (coordinate 031.246) ***.***.002.** Second area (coordinate 011.146) ***.***.003.** Third area (coordinate 021.274) ***.***.003.** Third area (coordinate 021.274)
[0142] In this way, when obtaining the financial service, the geographical section and the corresponding coordinates of the sending location of the financial service can be obtained.
[0143] Step 302, if they belong to the same geographical section, the regional weight of the alternative micro-server is the first regional weight;
[0144] In this specification, if the geographical section where the financial data is sent is the same as the geographical section where the micro-server is located, then its regional weight can be the first regional weight. In this specification, the first regional weight is the smallest value among all regional weights, and can be 0, 0.1, 0.11, 0.02, etc. This specification does not make any limitations in this regard.
[0145] Step 303: If they do not belong to the same geographical section, then determine the regional weight of the alternative micro-server according to the distance between the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server.
[0146] Specifically, calculate the regional weight of the alternative micro-server according to the following formula:
[0147]
[0148] Among them, γ is the regional weight of the alternative micro-server, x1 is the abscissa of the financial service sending location obtained according to the IP address corresponding to the financial service, y1 is the ordinate of the financial service sending location obtained according to the IP address corresponding to the financial service, x2 is the abscissa of the alternative micro-server obtained according to the IP corresponding to the alternative micro-server, and y2 is the ordinate of the alternative micro-server obtained according to the IP corresponding to the alternative micro-server.
[0149] Through the above formula, if the geographical section where the financial service is sent is relatively close to the geographical section of the micro-server, then the finally calculated γ is smaller. If the geographical section where the financial service is sent is far from the geographical section of the micro-server, then the finally calculated γ is larger.
[0150] As an embodiment of this specification, step 205: The determining the evaluation value of each alternative micro-server according to the load rate of the alternative micro-server and its corresponding regional weight further includes:
[0151] τ = load × γ
[0152] Among them, τ is the evaluation value of the alternative micro-server, load is the load rate of the alternative micro-server, and γ is the regional weight corresponding to the load rate of the alternative micro-server.
[0153] Through the above formula, the evaluation value of each alternative micro-server can be obtained. Specifically, the load rate characterizes the processing ability of a micro-server for financial services. A high load rate indicates poor processing ability of the micro-server for financial services, while a low load rate indicates strong processing ability of the micro-server for financial services. In addition, the geographical weight characterizes the distance between the geographical section where the financial service is initiated and the geographical section of the alternative micro-server. When the geographical section where the financial service is initiated is close to the geographical section of the alternative micro-server, the geographical weight is low; when the geographical section where the financial service is initiated is far from the geographical section of the alternative micro-server, the geographical weight is high. Therefore, when a micro-server has strong processing ability for financial services and is close to the location where the financial service is initiated, the evaluation value of this micro-server should be the lowest. Therefore, the alternative micro-server with the lowest evaluation value is selected to process the financial service.
[0154] Such as Figure 4 shown in the schematic diagram of a microservice call device, including:
[0155] An instruction receiving unit 401, configured to receive the financial service forwarded by the routing device;
[0156] A server selection unit 402, configured to randomly select at least two micro-servers as alternative micro-servers from all micro-servers according to the system nanosecond number and the server code corresponding to the micro-server;
[0157] A load rate calculation unit 403, configured to determine the load rate of each of the alternative micro-servers according to the estimated average access time and the number of in-transit requests, where the estimated average access time is determined based on the previous moment's estimate, the current moment's measurement value, and the weight parameter;
[0158] A geographical weight calculation unit 404, configured to determine the geographical weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server;
[0159] An evaluation value calculation unit 405, configured to determine the evaluation value of each of the alternative micro-servers according to the load rate of the alternative micro-server and its corresponding geographical weight;
[0160] An instruction sending unit 406, configured to select the alternative micro-server with the lowest evaluation value to process the financial service.
[0161] Adopting the above technical solution, by receiving financial services forwarded by the routing device, it is possible to send external financial services to the internal system of the bank; by randomly selecting at least two micro-servers as alternative micro-servers from all micro-servers according to the system nanoseconds and the server code corresponding to the micro-server, it is possible to reduce the computational effort required to subsequently determine the evaluation values of each micro-server, balance the processing speed of selecting a micro-server to process the online transaction request and the time required to select a micro-server; by determining the load rate of each of the alternative micro-servers according to the estimated average access time and the number of requests in transit, where the estimated average access time is determined based on the previous estimate, the current measurement value, and the weight parameter, it is possible to determine the average access time of each alternative micro-server and the number of requests in transit for each micro-server. The average access time characterizes the processing speed of each micro-server for the online transaction request instruction, and the number of requests in transit characterizes the number of online transaction request instructions to be processed by each micro-server; by determining the regional weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server, it is possible to select the micro-server closest to the user who initiates the financial service to process the financial service. When the financial service processing fails, it is convenient for the user to go to the business point near the micro-server for manual processing; by determining the evaluation value of each of the alternative micro-servers according to the load rate of the alternative micro-server and its corresponding regional weight, it is possible to score each micro-server, and this score can objectively characterize the processing speed of each micro-server for the financial service; by selecting the alternative micro-server with the lowest evaluation value to process the financial service, it is possible to select a micro-server with a relatively fast processing speed for the current financial service to process the online transaction instruction, so as to reduce the large difference in the business processing waiting time of customers, thereby enhancing user satisfaction.
[0162] Such as Figure 5As shown in the figure, a computer device provided by an embodiment of this specification. The computer device runs the microservice call method described in this article. The computer device 502 may include one or more processors 504, such as one or more central processing units (CPUs), and each processing unit may implement one or more hardware threads. The computer device 502 may also include any memory 506, which is used to store any kind of information such as code, settings, data, etc. Non-limitingly, for example, the memory 506 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory devices, hard disks, optical discs, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 502. In one case, when the processor 504 executes the associated instructions stored in any memory or combination of memories, the computer device 502 may perform any operation of the associated instructions. The computer device 502 also includes one or more drive mechanisms 508 for interacting with any memory, such as a hard disk drive mechanism, an optical disc drive mechanism, etc.
[0163] The computer device 502 may also include an input / output module 510 (I / O), which is used to receive various inputs (via the input device 512) and to provide various outputs (via the output device 514). A specific output mechanism may include a presentation device 516 and an associated graphical user interface (GUI) 518. In other embodiments, the input / output module 510 (I / O), the input device 512, and the output device 514 may not be included, and it may only be a computer device in the network. The computer device 502 may also include one or more network interfaces 520, which are used to exchange data with other devices via one or more communication links 522. One or more communication buses 524 couple the components described above together.
[0164] The communication link 522 may be implemented in any way, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 522 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0165] Corresponding to Figure 2 and Figure 3 For the method in, an embodiment of this specification also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a processor, it executes the steps of the above method.
[0166] The embodiments of this specification also provide a computer-readable instruction. When a processor executes the instruction, the program therein causes the processor to execute the method as Figure 2 and Figure 3 shown.
[0167] It should be understood that in the various embodiments of this specification, the magnitudes of the sequence numbers of the above processes do not imply the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this specification.
[0168] It should also be understood that in the embodiments of this specification, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this specification generally represents an "or" relationship between the associated objects before and after.
[0169] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this specification can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this specification.
[0170] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0171] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed coupling or direct coupling or communication connection to each other can be an indirect coupling or communication connection through some interfaces, devices, or units, and can also be an electrical, mechanical, or other form of connection.
[0172] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of this specification.
[0173] In addition, each functional unit in the embodiments of this specification can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0174] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this specification, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of this specification. The aforementioned storage medium includes: various media that can store program codes such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.
[0175] Specific embodiments are used in this specification to elaborate on the principles and implementation manners of this specification. The descriptions of the above embodiments are only used to help understand the method and its core idea of this specification; at the same time, for those of ordinary skill in the art, according to the idea of this specification, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this specification.
Claims
1. A method for micro-server calls, characterized in that, Including: Receiving financial services forwarded by a routing device; Generating at least two random numbers based on the system nanoseconds and the server code corresponding to the micro-server, and matching the random numbers with the server code corresponding to the micro-server to obtain at least two micro-servers as alternative micro-servers; Determining the load rate of each of the alternative micro-servers according to the estimated average access time and the number of in-transit requests, where the estimated average access time is determined based on the previous moment's estimate, the current moment's measurement value, and a weight parameter, and the weight parameter is calculated based on the time interval between the current moment's request and the previous moment's request; Determining the regional weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server; Determining the evaluation value of each of the alternative micro-servers according to the load rate of the alternative micro-server and its corresponding regional weight; Selecting the alternative micro-server with the lowest evaluation value to process the financial service.
2. The micro-server calling method according to claim 1, wherein The step of generating at least two random numbers based on the system nanoseconds and the server code corresponding to the micro-server further includes: Generating at least two random numbers according to the formula: [node] = (λ * C)^T % CS Where [node] is the random number, λ is the server code corresponding to the micro-server, C is a preset constant, T is the system nanoseconds, CS is the set of server codes corresponding to all micro-servers, and % is the addressing symbol.
3. The micro-server call method according to claim 1, wherein The step of determining the load rate of each of the alternative micro-servers according to the estimated average access time and the number of in-transit requests further includes: Calculating the load rate of each of the alternative micro-servers according to the formula: Among them, load is the load rate, v t is the estimated value of the average access time, and I is the number of in-transit requests for each alternative micro-server.
4. The micro-server call method according to claim 3, wherein The estimated average access time is determined based on the previous moment's estimate, the current moment's measurement value, and a weight parameter, and further includes: Calculating the estimated average access time according to the formula: v t = βv t-1 + (1 - β)θ t Among them, v t is the estimated value of the average access time, β is the weight parameter, and the value range is 0 < β < 1; θ t is the measured value at the current moment; the value range of t is: 1, 2, 3,..., n, v t-1 is the estimated value of the average access time at the previous moment.
5. The micro-server call method according to claim 4, wherein The weight parameter is determined using the following formula: β=e -(Δt / k) Where β is the weight parameter, Δt represents the time interval between two requests, which is the time between the current moment's request and the previous moment's request, and k is a preset proportionality coefficient.
6. The micro-server call method according to claim 1, characterized in that The step of determining the regional weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server further includes: Determining whether the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server belong to the same geographical section, where the geographical section is determined according to the coordinates corresponding to the IP; If they belong to the same geographical section, the regional weight of the alternative micro-server is the first regional weight; If they do not belong to the same geographical section, the regional weight of the alternative micro-server is determined according to the distance between the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server.
7. The micro-server call method according to claim 6, characterized in that The step of determining the regional weight of the alternative micro-server according to the distance between the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server further includes: Calculating the regional weight of the alternative micro-server according to the following formula: Among them, γ is the regional weight of the alternative micro-server, x1 is the abscissa of the financial service sending location obtained according to the IP address corresponding to the financial service, y1 is the ordinate of the financial service sending location obtained according to the IP address corresponding to the financial service, x2 is the abscissa of the alternative micro-server obtained according to the IP corresponding to the alternative micro-server, and y2 is the ordinate of the alternative micro-server obtained according to the IP corresponding to the alternative micro-server.
8. The micro-server call method according to claim 1, characterized in that Determining the evaluation value of each of the alternative micro-servers according to the load rate of the alternative micro-server and its corresponding regional weight further includes: τ = load × γ Among them, τ is the evaluation value of the alternative micro-server, load is the load rate of the alternative micro-server, and γ is the regional weight corresponding to the load rate of the alternative micro-server.
9. A micro-server calling device, characterized in that It includes: An instruction receiving unit, configured to receive the financial service forwarded by the routing device; A server selection unit, configured to generate at least two random numbers according to the system nanoseconds and the server code corresponding to the micro-server, match the random numbers with the server code corresponding to the micro-server, and obtain at least two micro-servers as alternative micro-servers; A load rate calculation unit, configured to determine the load rate of each of the alternative micro-servers according to the estimated average access time and the number of requests in transit, where the estimated average access time is determined according to the previous estimated value, the measured value at the current moment, and the weight parameter, and the weight parameter is calculated according to the time interval between the current moment request and the previous moment request; A regional weight calculation unit, configured to determine the regional weight of each of the alternative micro-servers according to the IP address corresponding to the financial service and the IP corresponding to the alternative micro-server; An evaluation value calculation unit, configured to determine the evaluation value of each of the alternative micro-servers according to the load rate of the alternative micro-server and its corresponding regional weight; An instruction sending unit, configured to select the alternative micro-server with the lowest evaluation value to process the financial service.
10. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the micro-server calling method according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements the micro-server calling method according to any one of claims 1-8.
Citation Information
Patent Citations
Load balancing method and controller thereof
CN107087014A
Service scheduling method and device, electronic equipment and storage medium
CN113407316A