An optimization method and system for dynamic routing
By recording the route address on the server side and having the client generate the route request header, the problem of the client's inability to configure route forwarding independently is solved, achieving flexible route forwarding and an optimized user experience.
Patent Information
- Application Number
- CN202410383588.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-01
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-04-01
AI Technical Summary
In existing technologies, clients cannot configure routing forwarding independently; it requires server-side configuration, resulting in inflexible routing configuration and an inability to meet personalized needs.
The server obtains and records routing address information, the client caches and generates routing request headers, the server receives and forwards according to the routing request headers, enabling the client to configure routing forwarding independently.
It implements client-configurable autonomous routing and forwarding capabilities, improving the flexibility and response speed of routing configuration, reducing system coupling, and optimizing the user experience.
Smart Images

Figure CN118264614B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data processing, in particular to a dynamic routing optimization method and system. BACKGROUND
[0002] In the current Internet system, in order to support the request forwarding of various service ends, there will be a routing table function, which is configured by the service end, and the routing is matched to the corresponding service node according to the request type.
[0003] When new routing information needs to be added or changed, the corresponding information is configured by the administrator, and it can take effect. However, each routing configuration needs to be configured through the service end, and at the same time, only data meeting specific conditions can be routed and forwarded, and the client as a demand source cannot perform self-configured routing forwarding. SUMMARY
[0004] The technical problem to be solved by the present application is to provide a dynamic routing optimization method and system to realize the function of client-controllable autonomous routing forwarding.
[0005] In order to solve the above technical problems, the technical scheme adopted by the present application is:
[0006] A dynamic routing optimization method, comprising the steps of:
[0007] S1, the service end acquires routing address information and records;
[0008] S2, the client caches routing address information and generates a routing request header in combination with individualized needs;
[0009] S3, the service end receives the routing request header and forwards according to the routing request header.
[0010] In order to solve the above technical problems, another technical scheme adopted by the present application is:
[0011] A dynamic routing optimization system, comprising a service end and a client;
[0012] The service end comprises a first processor, a first memory, and a first computer program stored in the first memory and executable on the first processor;
[0013] The client comprises a second processor, a second memory, and a second computer program stored in the second memory and executable on the second processor;
[0014] The first processor executes the first computer program to realize the following steps:
[0015] S1, acquire routing address information and record;
[0016] S3, receiving the routing request header and forwarding according to the routing request header;
[0017] The second processor implements the following steps when executing the second computer program:
[0018] S2, caching routing address information and generating a routing request header in combination with personalized needs.
[0019] The system has the beneficial effects of the present application, which provides an optimization method and system for dynamic routing. The routing address information of the server is uniformly arranged and processed, and is cached by the client. When the client needs to configure the routing forwarding function independently, the client adds a specific routing forwarding request header according to the arrangement information. The routing forwarding request header can arrange routing rules by itself. When the server receives the request, it prioritizes routing forwarding according to the information in the routing forwarding request header, and continues to transmit the request header, realizing the configurable and independent routing forwarding function of the client. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 A flowchart of an optimization method for dynamic routing in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of an optimization system for dynamic routing in an embodiment of the present application;
[0022] REFERENCE NUMERALS:
[0023] 1. An optimization system for dynamic routing; 2. A server; 3. A client;
[0024] 4. A first processor; 5. A first storage; 6. A second processor;
[0025] 7. A second storage. DETAILED DESCRIPTION
[0026] To explain the technical content, purposes and effects of the present application in detail, the following embodiments are described with reference to the accompanying drawings.
[0027] Please refer to Figure 1 An optimization method for dynamic routing, comprising the steps of:
[0028] S1, the server obtains routing address information and records;
[0029] S2, the client caches routing address information and generates a routing request header in combination with personalized needs;
[0030] S3, the server receives the routing request header and forwards according to the routing request header.
[0031] From the above description, the beneficial effects of the present application are that the routing address information of the server is uniformly arranged and processed, and is cached by the client. When the client needs to configure the routing forwarding function independently, the client adds a specific routing forwarding request header according to the arrangement information. The routing forwarding request header can arrange routing rules by itself. When the server receives the request, the server performs routing forwarding according to the information of the routing forwarding request header in priority, and continues to transmit the request header, thereby realizing the configurable and independent routing forwarding function of the client.
[0032] In some embodiments of the present application, the step S1 specifically comprises the steps of:
[0033] The server numbers and sorts each routing address, and records the primary key id and the numerical type of each routing address.
[0034] From the above description, each routing address of the server is numbered and sorted, that is, each routing address has a unique number, such as URL1, URL2, URL3, and the like. Preferably, in order to reduce the amount of recorded data, only the primary key id and the numerical type of each routing address are recorded.
[0035] In some embodiments of the present application, in the step S2:
[0036] The key of the routing request header is routePathKey.
[0037] From the above description, the forwarding path of the request is dynamically specified by modifying the routePathKey in the request header, the individual processing of the request is realized, and it is particularly useful for constructing a complex micro-service architecture. The routing of the request can be flexibly adjusted according to the content of the request, the preference of the user or other business logic.
[0038] In some embodiments of the present application, the step S3 specifically comprises the steps of:
[0039] When the routing node of the server accepts the request, it is inquired whether the routing request header exists. If the routing request header exists, the server forwards according to the information of the routing request header. Otherwise, the server forwards the request according to the configured default routing rule.
[0040] From the above description, in order to prevent errors of the individual routing request header, the server still retains the configured default routing rule as the second priority, and only executes the default path when it is inquired that the routing request header does not exist.
[0041] In some embodiments of the present application, in the step S2:
[0042] The value of the routing request header is an array, and the subscript of the array represents the node of the routing, and the numerical value of the subscript is the number of the routing address.
[0043] The step S3 specifically comprises the steps that when the routing node of the server accepts the request, the server queries whether the routing request header exists, if the routing request header exists, the server parses the value of the routing request header, queries the numerical value of the corresponding subscript in the value array, matches the number of the routing address and forwards; otherwise, the server forwards the request according to the configured default routing rule.
[0044] As can be seen from the above description, the format of the value of the routing request header adopts an array type, and the node of the routing is represented by the subscript of the array, and the numerical value of the subscript is the number of the routing address, and when the routing node of the server accepts the routing request header transmitted by the client, the numerical value corresponding to the subscript in the array of the routing request header is first parsed, and the routing address represented by the numerical value is matched and forwarded, and specific examples are as follows:
[0045] Suppose there are three routing nodes, which are represented by numbers 1, 2 and 3 respectively. The client needs to send requests to these three nodes respectively, and the server knows according to these numbers which node the request will be forwarded to, wherein: the array in the routing request header is [1, 2, 3]; the meaning of this array is that the client hopes that the server will forward the request to the routing nodes numbered 1, 2 and 3 in turn. The subscript of the array starts from 0, so the subscript 0 represents the first routing node (number 1), the subscript 1 represents the second routing node (number 2), and the subscript 2 represents the third routing node (number 3).
[0046] Specifically, if the client hopes that the first request is sent to the routing node 1 and the second request is sent to the routing node 3, the value of the request header routePathKey can be set as an array [1, 3]. In this scenario, the first element (subscript 0) of the array is 1, indicating that the first request needs to be forwarded to the node numbered 1; the second element (subscript 1) of the array is 3, indicating that the second request needs to be forwarded to the node numbered 3.
[0047] Please refer to Figure 2 , an optimization system of dynamic routing, comprising a server 2 and a client 3;
[0048] The server 2 comprises a first processor 4, a first memory 5, and a first computer program stored in the first memory 5 and executable on the first processor 4;
[0049] The client 3 comprises a second processor 6, a second memory 7, and a second computer program stored in the second memory 7 and executable on the second processor 6;
[0050] The first processor 4 implements the following steps when executing the first computer program:
[0051] S1, obtain routing address information and record;
[0052] S3, receive the routing request header and forward according to the routing request header;
[0053] The second processor 7 implements the following steps when executing the second computer program:
[0054] S2, cache routing address information, and generate a routing request header in combination with personalized needs.
[0055] That is, the embodiment of the optimization method of dynamic routing, when implementing the method, the routing address information of the server is uniformly arranged and processed, and is cached by the client, when the client needs to configure the routing forwarding function independently, the client adds a specific routing forwarding request header according to the arrangement information, the routing forwarding request header can arrange routing rules by itself, when the server receives the request, the server preferentially forwards the routing according to the information of the routing forwarding request header, and continues to transmit the request header, so as to realize the configurable and independent routing forwarding function of the client.
[0056] The application provides a kind of dynamic routing optimization method and system, mainly configurable and independent routing forwarding function is realized in client, specific description is made below in conjunction with embodiment:
[0057] Please refer to Figure 1 The embodiment one of the application is:
[0058] A kind of dynamic routing optimization method, comprising the following steps:
[0059] S1, server obtains routing address information and records; that is, each routing address of the server is numbered and sorted, and the primary key id and numerical value of each routing address are recorded.
[0060] S2, client caches routing address information, and generates a routing request header in combination with personalized needs; the key of routing request header is routePathKey.
[0061] S3, when the routing node of the server accepts request, it is inquired whether there is routing request header, if there is, the server forwards according to the information of routing request header; otherwise, the server forwards the request according to the default routing rule configured by the server.
[0062] That is, in the embodiment, the routing address information of the server is uniformly arranged and processed, and is cached by the client. When the client needs to configure a routing forwarding function autonomously, the client adds a specific routing forwarding request header according to the arrangement information, the routing forwarding request header can autonomously arrange routing rules inside, when the server receives the request, the server preferentially performs routing forwarding according to the information of the routing forwarding request header, and continues to transmit the request header, thereby realizing the configurable autonomous routing forwarding function of the client.
[0063] Embodiment two of the application is:
[0064] On the basis of the embodiment one, the value of the routing request header is an array, the subscript of the array indicates a node of routing, and the numerical value of the subscript is the number of the routing address; and the application of the dynamic routing optimization method is as follows:
[0065] S1, the server numbers and sorts each routing address, that is, each routing address has a unique number, for example, URL1, URL2, URL3, and the like.
[0066] S2, the client caches the routing address information after arrangement and processing, and generates a routing request header with a key of routePathKey in combination with individualized requirements, wherein the value of the routing request header is an array, the subscript of the array indicates a node of routing, and the numerical value of the subscript is the number of the routing address; specifically, the routing request header individually prepared by the client is [3, 1, 2]; the meaning of the array is that the client hopes that the server forwards the request to the routing nodes with numbers of 3, 1 and 2 in turn. The subscript of the array starts from 0, so the subscript 0 indicates the first routing node (number URL3), the subscript 1 indicates the second routing node (number URL1), and the subscript 2 indicates the third routing node (number URL2).
[0067] S3, when the routing node of the server accepts the request, the routing node queries whether the routing request header exists, if the routing request header exists, the routing node parses the value of the routing request header, queries the numerical value of the corresponding subscript in the value array, matches the number of the routing address and performs forwarding; otherwise, the server performs request forwarding according to the default routing rule configured by the server.
[0068] Please refer to Figure 2 Embodiment three of the application is:
[0069] An optimization system 1 of dynamic routing, comprising a server 2 and a client 3; the server 2 comprises a first processor 4, a first memory 5, and a first computer program stored in the first memory 5 and executable on the first processor 4; the client 3 comprises a second processor 6, a second memory 7, and a second computer program stored in the second memory 7 and executable on the second processor 6; when the first processor 4 executes the first computer program and the second processor 6 executes the second computer program, the steps of any one of the dynamic routing optimization methods in the above embodiments one to two are implemented.
[0070] In summary, the dynamic routing optimization method and system provided by the application have the following advantages:
[0071] Dynamic routing control: allows the client to dynamically specify the routing path of the request as needed, without modifying the configuration of the server or redeploying the service, greatly improving the flexibility of service deployment and operation and maintenance.
[0072] Reduce system coupling: by setting the routePathKey request header in the client to control the routing of the request, avoid hard coding of different routing logic in the server, reduce the coupling degree between systems, make the expansion and modification of the service more simple and safe.
[0073] Optimize user experience: for system users, dynamically select the best service node according to the user's geographic location, device type and other factors, which can significantly reduce the response time and improve the response speed of the service and the user's experience.
[0074] The above is only an embodiment of the application, and does not limit the patent scope of the application, any equivalent transformation or direct or indirect application in related technical fields using the content of the application specification and drawings is also included in the patent protection scope of the application.
Claims
1. A method for optimizing dynamic routing, characterized in that: Including the following steps: S1. The server obtains and records the routing address information; S2. The client caches the routing address information and generates a routing request header based on personalized requirements. S3. The server receives the routing request header and forwards it according to the routing request header; in step S2: The key in the routing request header is routePathKey; Step S3 specifically includes the following steps: When a server-side routing node receives a request, it checks whether the routing request header exists. If it does, the server forwards the request according to the information in the routing request header; otherwise, the server forwards the request according to the configured default routing rules.
2. The dynamic routing optimization method according to claim 1, characterized in that: Step S1 specifically includes the following steps: The server assigns a number to each route address and sorts them, recording the primary key id and numeric type of each route address.
3. The dynamic routing optimization method according to claim 1, characterized in that: In step S2: The value of the routing request header is an array, where the index of the array represents the node of the route, and the value of the index is the number of the route address; Step S3 specifically includes the following steps: When the server's routing node receives a request, it checks whether the routing request header exists. If it does, the server parses the value of the routing request header, queries the value of the corresponding index in the value array, matches the number of the routing address, and forwards the request; otherwise, the server forwards the request according to the configured default routing rules.
4. A dynamic routing optimization system, characterized in that: Including server-side and client-side; The server includes a first processor, a first memory, and a first computer program stored in the first memory and capable of running on the first processor; The client includes a second processor, a second memory, and a second computer program stored in the second memory and capable of running on the second processor; When the first processor executes the first computer program, it implements step S1: S1. Obtain and record the routing address information; When the second processor executes the second computer program, it implements step S2: S2. Cache the routing address information, generate a routing request header based on personalized requirements, and send the routing request header to the server; the first processor executes the first computer program to implement step S3: S3. Receive the routing request header and forward it according to the routing request header; In step S2: The key in the routing request header is routePathKey; Step S3 specifically includes the following steps: When a server-side routing node receives a request, it checks whether the routing request header exists. If it does, the server forwards the request according to the information in the routing request header; otherwise, the server forwards the request according to the configured default routing rules.
5. The dynamic routing optimization system according to claim 4, characterized in that: Step S1 specifically includes the following steps: The server assigns a number to each route address and sorts them, recording the primary key id and numeric type of each route address.
6. The dynamic routing optimization system according to claim 4, characterized in that: In step S2: The value of the routing request header is an array, where the index of the array represents the node of the route, and the value of the index is the number of the route address; Step S3 specifically includes the following steps: When the server's routing node receives a request, it checks whether the routing request header exists. If it does, the server parses the value of the routing request header, queries the value of the corresponding index in the value array, matches the number of the routing address, and forwards the request; otherwise, the server forwards the request according to the configured default routing rules.
Citation Information
Patent Citations
Method for realizing dynamic routing of micro-service gateway
CN112804722A
Dynamic routing arrangement method and system realized based on Spring Cloud Gateway
CN113794636A