Method, device, storage medium and electronic device for accessing resources
By identifying the target terminal device and server in the smart home system, scheduling resource data and forwarding requests evenly, the problem of slow resource loading of terminal device is solved and the system response efficiency is improved.
Patent Information
- Application Number
- CN202111119050.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-24
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-09-24
AI Technical Summary
In smart home systems, as the number of terminal devices and access volume increases, the server load is too heavy, resulting in slow resource loading speed.
By receiving resource access requests from multiple terminal devices, the target terminal device and target server are determined, the resource data is scheduled to the server with the best link quality, and the resource access request is uniformly forwarded to multiple servers if necessary to mitigate load.
It improves the speed of terminal equipment loading resource data, reduces server load, and improves system response efficiency.
Smart Images

Figure CN113867946B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communications, and in particular to a method, device, storage medium and electronic device for accessing resources. Background Art
[0002] In a smart home system, users access resources in a server through terminal devices. The types of resources include web pages, pictures, files, etc. The server responds to the resource access request of the terminal device and sends the resource to the terminal device. As the scale of the smart home system increases, the number of terminal devices increases and the access volume of terminal devices increases. There may be multiple terminal devices accessing the same resource in the server at the same time, or the terminal device may send a large number of requests in a short period of time, exceeding the processing capacity of the server. Therefore, how to reduce the load on the server and improve the response speed of the terminal device loading resources is a problem that needs to be solved urgently. Summary of the invention
[0003] In order to solve the above-mentioned technical problems, the present application provides a method, device, storage medium and electronic device for accessing resources, which solve the problem of slow loading of resource data by terminal devices in the prior art.
[0004] In a first aspect, the present application provides a method for accessing resources, comprising:
[0005] Receive m resource access requests from n terminal devices; where m and n are integers greater than 1, and each resource access request carries a source IP address and a resource ID;
[0006] If there is a target terminal device among the n terminal devices, determine a target server in the server cluster; wherein the target terminal device is a terminal device whose access volume is greater than a first quantity threshold within a preset time period; and the target server is a server with the best link quality with the target terminal device;
[0007] Determine resource data to be accessed according to resource IDs carried in multiple resource access requests from the target terminal device, and dispatch the resource data to the target server;
[0008] forwarding the multiple resource access requests to the target server;
[0009] The resource data returned by the target server is forwarded to the target terminal device.
[0010] In one possible design, the method further includes:
[0011] If the target terminal device does not exist among the n terminal devices, determining the multiple resource data to be accessed by the n terminal devices according to the resource IDs carried by the m resource access requests;
[0012] Determine whether there is target resource data among the multiple resource data; wherein the target resource data is resource data with a preset time duration and a visit volume greater than a second quantity threshold;
[0013] If yes, query the server cluster for a set of servers storing the target resource data;
[0014] Determining k resource access requests for accessing target resource data from the m resource access requests; wherein k < m and is an integer;
[0015] Evenly forwarding the k resource access requests to each server in the server set;
[0016] The target resource data returned by each server in the server set is forwarded to the corresponding terminal device.
[0017] In a possible design, the uniformly forwarding each resource access request in the resource access set to each server in the server set includes:
[0018] Determine a terminal device set that issues the k resource access requests and the number of resource access requests issued by each terminal device in the terminal device set;
[0019] For each terminal device in the terminal device set, query the server set that is closest to the terminal device;
[0020] According to the number of resource access requests issued by each terminal device and the query result, the k resource access requests are evenly forwarded to each server in the server set.
[0021] In a possible design, determining the target server in the server cluster includes:
[0022] Sending a test data packet to each server, and receiving a response data packet returned by each server in response to the test data packet;
[0023] The round trip time of each server is calculated based on the sending time of the test data packet and the receiving time of the response data packet;
[0024] Use the server with the shortest round trip time as the target server; or
[0025] Monitor the parameter values of the load status parameters of each server;
[0026] Use the server with the lightest load as the target server; or
[0027] Obtaining geographic location information of the target terminal device and the geographic location information of each server;
[0028] The server closest to the target terminal device is used as the target server.
[0029] In a possible design, obtaining address location information includes:
[0030] Obtained by parsing the geographical location information of the terminal device carried in the resource access request; or
[0031] Parse the resource access request to obtain the source IP address, and determine the corresponding geographic location information based on the source IP address.
[0032] In one possible design, the method further includes:
[0033] Compress resource data from the server.
[0034] In one possible design, it also includes:
[0035] When it is detected that the server cluster is in an idle state, the updated resource data is synchronized to each server in the server cluster.
[0036] In a second aspect, the present application provides a device for accessing resources, including:
[0037] A transceiver unit, configured to receive m resource access requests from n terminal devices; wherein m and n are integers greater than 1, and each resource access request carries a source IP address and a resource ID;
[0038] A determination unit, configured to determine a target server in the server cluster if a target terminal device exists among the n terminal devices; wherein the target terminal device is a terminal device whose access volume is greater than a first quantity threshold within a preset time period; and the target server is a server having the best link quality with the target terminal device;
[0039] A scheduling unit, configured to determine resource data to be accessed according to resource IDs carried in a plurality of resource access requests from the target terminal device, and schedule the resource data to the target server;
[0040] The transceiver unit is further configured to forward the multiple resource access requests to the target server;
[0041] The transceiver unit is further used to forward the resource data returned by the target server to the target terminal device.
[0042] In one possible design, the method further includes:
[0043] A distribution unit, configured to determine, if the target terminal device does not exist among the n terminal devices, a plurality of resource data to be accessed by the n terminal devices according to the resource IDs carried by the m resource access requests;
[0044] Determine whether there is target resource data among the multiple resource data; wherein the target resource data is resource data with a preset time duration and a visit volume greater than a second quantity threshold;
[0045] If yes, query the server cluster for a set of servers storing the target resource data;
[0046] Determining k resource access requests for accessing target resource data from the m resource access requests; wherein k < m and is an integer;
[0047] Evenly forwarding the k resource access requests to each server in the server set;
[0048] The target resource data returned by each server in the server set is forwarded to the corresponding terminal device.
[0049] In a possible design, the uniformly forwarding each resource access request in the resource access set to each server in the server set includes:
[0050] Determine a terminal device set that issues the k resource access requests and the number of resource access requests issued by each terminal device in the terminal device set;
[0051] For each terminal device in the terminal device set, query the server set that is closest to the terminal device;
[0052] According to the number of resource access requests issued by each terminal device and the query result, the k resource access requests are evenly forwarded to each server in the server set.
[0053] In a possible design, determining the target server in the server cluster includes:
[0054] Sending a test data packet to each server, and receiving a response data packet returned by each server in response to the test data packet;
[0055] The round trip time of each server is calculated based on the sending time of the test data packet and the receiving time of the response data packet;
[0056] Use the server with the shortest round trip time as the target server; or
[0057] Monitor the parameter values of the load status parameters of each server;
[0058] Use the server with the lightest load as the target server; or
[0059] Obtaining geographic location information of the target terminal device and the geographic location information of each server;
[0060] The server closest to the target terminal device is used as the target server.
[0061] In a possible design, obtaining address location information includes:
[0062] The geographical location information of the terminal device is carried in the resource access request, and the geographical location information is obtained by parsing the resource access request; or
[0063] Parse the resource access request to obtain the source IP address, and determine the corresponding geographic location information based on the source IP address.
[0064] In one possible design, the method further includes:
[0065] The compression unit is used to compress the resource data from the server.
[0066] In one possible design, it also includes:
[0067] The synchronization unit is used to synchronize updated resource data to each server in the server cluster when it is detected that the server cluster is in an idle state.
[0068] In another aspect, the present application provides a device that can implement the distributed task scheduling method of the first aspect or the second aspect. For example, the device can be a chip or a server. The above method can be implemented by software, hardware, or by hardware executing corresponding software.
[0069] In a possible implementation, the structure of the device includes a processor and a memory; the processor is configured to support the device to perform the corresponding functions in the above-mentioned application testing method. The memory is used to couple with the processor, and stores the necessary programs (instructions) and / or data of the device. Optionally, the device may also include a communication interface to support communication between the device and other network elements.
[0070] In another possible implementation, the device may include a unit module for executing corresponding actions in the above method.
[0071] In another possible implementation, it includes a processor and a transceiver, the processor is coupled to the transceiver, and the processor is used to execute a computer program or instruction to control the transceiver to receive and send information; when the processor executes the computer program or instruction, the processor is also used to implement the above method.
[0072] On the other hand, the present application provides a device, which includes: a memory and a processor; wherein a group of program codes are stored in the memory, and the processor is used to call the program codes stored in the memory to execute the methods described in various aspects.
[0073] Another aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the computer-readable storage medium is run on a computer, the computer executes the methods described in the above aspects.
[0074] Another aspect of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the methods described in the above aspects.
[0075] According to the above embodiments, when resource data needs to be loaded, the access volume of each terminal device is monitored based on resource access requests from multiple terminal devices. When there is a terminal device with a large number of accesses in a short period of time, the server with the best link quality with the terminal device is queried in the server cluster, and then the resource data to be accessed by the terminal device is scheduled to the queried server to reduce the access pressure of the terminal device, redirect the resource access request of the terminal device to the server with the fastest response speed, and improve the speed of loading resource data by the terminal device. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0077] Figure 1 This is a network architecture diagram provided by an embodiment of the present application;
[0078] Figure 2 It is a flowchart of a method for accessing resources provided in an embodiment of the present application;
[0079] Figure 3 is another flowchart of the method for accessing resources provided by an embodiment of the present application;
[0080] Figure 4 is a schematic diagram of the structure of a device provided in an embodiment of the present application;
[0081] Figure 5 It is another structural schematic diagram of a device provided by the present application. DETAILED DESCRIPTION
[0082] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. At the same time, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. It should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits and methods are omitted to prevent unnecessary details from hindering the description of the present application.
[0083] Figure 1 An exemplary system architecture that can be applied to the method for accessing resources or the apparatus for accessing resources of the present application is shown.
[0084] like Figure 1 As shown, the system architecture may include terminal device 11, terminal device 12, terminal device 13, load balancing device 2, server 31, server 32 and server 33. Server 31, server 32 and server 33 form a server cluster, each server in the server cluster stores resource data, and the load balancing device stores the mapping relationship between server ID and resource ID, so the load balancing device can know the deployment status of resource data on each server. The terminal devices 11 to 13 and the load balancing device 2 are connected via the network ( Figure 1 The load balancing device 2 and the servers 31 to 32 communicate through a network, which is a medium for providing a communication link. The network may include various types of wired communication links or wireless communication links, for example, wired communication links include optical fibers, twisted pairs or coaxial cables, and wireless communication links include Bluetooth communication links, wireless fidelity (Wi-Fi) communication links or microwave communication links.
[0085] Users can use terminal devices 11-13 to interact with servers 31-33 through the load balancing device 2 to receive control data or business data from the servers or send messages to the servers 31-33. Various communication client applications can be installed on the terminal devices 11-13, such as: video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0086] The terminal devices 11-13 can be hardware or software. When the terminal devices 11-13 are hardware, they can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers. When the terminal devices 11-13 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example: used to provide distributed services), or they can be implemented as a single software or software module, which is not specifically limited here.
[0087] When the terminal devices 11 to 13 are hardware, a display device may be installed thereon, and the display may be various devices capable of realizing display functions, such as cathode ray tube display (CR), light-emitting diode display (LED), electronic ink screen, liquid crystal display (LCD), plasma display panel (PDP), etc. The user may use the display device on the terminal devices 11 to 13 to view displayed text, pictures, videos and other information.
[0088] It should be noted that the method for accessing resources provided in the embodiment of the present application is generally executed by the load balancing device 2, and correspondingly, the device for accessing resources is generally set in the server.
[0089] It should be noted that the servers 31 to 33 can be hardware or software. When the servers 31 to 33 are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the servers 31 to 33 are software, they can be implemented as multiple software or software modules (for example, to provide distributed services), or as a single software or software module, which is not specifically limited here.
[0090] It should be understood that Figure 1 The number of terminal devices, load balancing devices and servers in the embodiment is only for illustration. According to the implementation requirements, any number of terminal devices, load balancing devices and servers can be used.
[0091] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0092] See also Figure 2 , Figure 2 : is a flow chart of a method for accessing resources provided in an embodiment of the present application. In the embodiment of the present application, the method includes:
[0093] S201. Receive m resource access requests from n terminal devices.
[0094] Wherein, n is an integer greater than 1, m is an integer greater than 1, and m>n, an application or plug-in is installed on the terminal device, and the resource access request is initiated by the application or plug-in. Each of the n terminal devices issues at least one resource access request, and the resource access request is used to request resource data. Different terminal devices may access the same resource data or different resource data. The types of resource data include image data, web page data, or file data. The resource access request carries the source IP address and resource ID; the source IP address is the IP address of the terminal device that initiates the resource access request, and the resource ID indicates the identity of the resource data requested by the terminal device; further, the resource access request also carries the source port number, which indicates the serial number of the port used by the terminal device.
[0095] For example, n=3, m=200, and the three terminal devices are UE1, UE2, and UE3. UE1 issues 100 resource access requests, UE2 issues 80 resource access requests, and UE3 issues 20 resource access requests. Then the load balancing device receives 200 resource access requests from the three terminal devices. The multiple resource access requests issued by the same terminal device are sent at different times, and the resource access requests issued by different terminal devices may be different. The resource access requests issued by each terminal device may access different resource data, or may access the same resource data, depending on actual needs.
[0096] S202: If the target terminal device exists among the n terminal devices, determine the target server in the server cluster.
[0097] Among them, the load balancing device determines whether there is a target terminal device among the n terminal devices. If the judgment result is yes, the number of target terminal devices may be one or more. The load balancing device monitors the resource access of each terminal device according to the parameter values carried in the m resource access requests. If there is a terminal device among the n terminal devices whose access volume is greater than the first quantity threshold within the preset time length, then the terminal device is the target terminal device. The size of the preset time length and the quantity threshold can be determined according to actual needs, and this application does not limit it. The access volume represents the number of resource access requests issued by the terminal device. If the target terminal device issues a large number of resource access requests in a short period of time, the server in the server cluster may not have time to respond, resulting in the problem of slow response to the resource data requested by it. From the user side, the target terminal device will not be able to display resource data for a long time. For example: the preset time length is 50 milliseconds, and the first quantity threshold is 100 times, that is, when the number of resource access requests issued by a terminal device within 50 milliseconds exceeds 100 times, the terminal device is the target terminal device, and the multiple resource access requests issued by the target terminal device may request different resource data or the same resource data.
[0098] The server cluster includes multiple distributed servers, each of which stores resource data. The target server is the server in the server cluster with the best link quality to the target terminal device, that is, the target terminal device has the fastest response speed when accessing the resource data of the target server.
[0099] In this embodiment, methods for determining a server may include the following three methods.
[0100] Method 1:
[0101] The method for determining a target server in a server cluster includes:
[0102] Sending a test data packet to each server, and receiving a response data packet returned by each server in response to the test data packet;
[0103] The round trip time of each server is calculated based on the sending time of the test data packet and the receiving time of the response data packet;
[0104] The server with the shortest round trip time is selected as the target server.
[0105] For example, the server cluster includes 4 servers, namely server 1, server 2, server 3 and server 4. The load balancing device sends test data packets to the 4 servers at the same time, records the sending time of the test data packets as 0.00 seconds, and then receives response data packet 1 from server 1, records the receiving time of the response data packet as 0.08 seconds; receives response data packet 2 from server 2, records the receiving time of response data packet 2 as 0.05 seconds; receives response data packet 3 from server 3, records the receiving time of response data packet 3 as 0.12 seconds; receives response data packet 4 from server 4, records the receiving time of response data packet 4 as 0.15 seconds. According to the above measurement results, it can be determined that the round trip time of server 2 is the smallest, so server 2 is the target server.
[0106] Method 2:
[0107] Identify the target server in the server cluster, including:
[0108] Monitor the parameter values of the load status parameters of each server;
[0109] The server with the lightest load status is selected as the target server.
[0110] The load state parameter indicates the severity of the load state of the server, and the load state parameter includes one or more of: CPU occupancy rate, memory occupancy rate, and the number of disk IO operations. When there are multiple load state parameters, weights are set for the multiple load state parameters, and the size of the weights can be determined based on actual needs. The parameter values of the multiple load state parameters are calculated based on the weights to obtain a weighted average, and the load state of each server is evaluated based on the average.
[0111] Method 3:
[0112] Identify the target server in the server cluster, including:
[0113] Obtaining geographic location information of the target terminal device and the geographic location information of each server;
[0114] The server closest to the target terminal device is used as the target server.
[0115] The geographic location information of the target terminal device indicates the geographic location of the target terminal device, and the geographic location information of the server indicates the geographic location of the server. The geographic location can be expressed in latitude and longitude coordinates or in an area code. The granularity of the area represented by the area code can be determined according to actual needs, for example, the area is a region, province or city. The location of each server in the server cluster is generally fixed, and the load balancing device pre-stores or pre-configured with the geographic location information of each server. The load balancing device traverses the target server in the server cluster, and the traversal method can be a depth-first algorithm or a breadth-first algorithm.
[0116] In this embodiment, the method for obtaining the geographic location information of the target terminal device includes the following two methods.
[0117] Method 1:
[0118] The target terminal device has a built-in positioning module, which can be a GPS module, Beidou module or base station positioning module, etc. The terminal device obtains geographic location information based on the positioning module, and then carries the geographic location information in the resource access request sent to the load balancing device. After receiving the resource server request, the load balancing device parses the resource access request to obtain the geographic location information of the target terminal device.
[0119] Method 2:
[0120] The resource access request sent by the target terminal device carries its source IP address. The load balancing device pre-stores or pre-configures a mapping relationship between the IP address and the geographic location information, and queries the geographic location information corresponding to the source IP address based on the mapping relationship.
[0121] S203: Determine resource data to be accessed according to resource IDs carried in multiple resource access requests from the target terminal device, and dispatch the resource data to be accessed to the target server.
[0122] Among them, the multiple resource access requests sent by the target terminal device carry resource IDs, and the resource data to be accessed by the target terminal device in the server cluster is determined according to the resource ID, and then the load balancing device dispatches the resource data to be accessed to the target server.
[0123] For example, the resource IDs carried by the 100 resource access requests issued by the target terminal device determine that the resource data to be accessed by the target terminal device are: resource data 1, resource data 2, resource data 3, and resource data 4. There are 4 servers deployed in the server cluster, namely: server 1, server 2, server 3, and server 4. Server 2 is the target server. Resource data 1 is stored on server 1, resource data 3 and resource data 4 are stored on server 4, and resource data 2 is stored on server 2, i.e., the target server. Then the load balancing device sends a scheduling instruction to server 1 to instruct server 1 to send a copy of resource data 1 to server 2, and sends a scheduling instruction to server 4 to instruct server 4 to send a copy of resource data 3 and resource data 4 to server 2.
[0124] S204: forward multiple resource access requests to the target server.
[0125] The load balancing device sends multiple resource access requests initiated by the target terminal device to the target server in sequence.
[0126] S205: Forward the resource data returned by the target server to the target terminal device.
[0127] The target server obtains the resource data requested by each resource access request, and forwards the resource data to the target terminal device through the load balancing device.
[0128] In one or more possible embodiments, for terminal devices other than the target terminal device among the n terminal devices (referred to as non-target terminal devices for short), after the load balancing device receives a resource access request from the non-target terminal device, it determines the resource data to be accessed by the resource access request, and determines the server in the server set that is closest to the non-target terminal device, and determines whether the resource data to be accessed is on the closest server. If not, the resource data to be accessed is scheduled to the closest server, and then the resource access request is forwarded to the closest server to improve the access speed of the resource data.
[0129] In implementing the embodiments of the present application, when resource data needs to be loaded, the access volume of each terminal device is monitored based on resource access requests from multiple terminal devices. When there is a terminal device with a large number of accesses in a short period of time, the server with the best link quality with the terminal device is queried in the server cluster, and then the resource data to be accessed by the terminal device is scheduled to the queried server to reduce the access pressure of the terminal device, redirect the resource access request of the terminal device to the server with the fastest response speed, and improve the speed of loading resource data by the terminal device.
[0130] See also Figure 3, is another flow chart of a method for accessing resources provided in an embodiment of the present application. In an embodiment of the present application, the method includes:
[0131] S301. Receive m resource access requests from n terminal devices.
[0132] The specific process of S301 can be found in Figure 2 The description of S201 will not be repeated here.
[0133] S302: Determine whether there is a target terminal device among the n terminal devices.
[0134] S303: Determine a target server in the server cluster.
[0135] The specific process of S302 and S303 can be referred to Figure 2 The description of S202 is not repeated here.
[0136] S304: Determine resource data to be accessed according to resource IDs carried in multiple resource access requests from the target terminal device, and dispatch the resource data to the target server.
[0137] The specific process of S304 can be referred to Figure 2 The description of S203 is not repeated here.
[0138] S305: forward multiple resource access requests to the target server.
[0139] The specific process of S305 can be found in Figure 2 The description of S204 is not repeated here.
[0140] S306: Forward the resource data returned by the target server to the target terminal device.
[0141] The specific process of S306 can be found in Figure 2 The description of S205 will not be repeated here.
[0142] S307 . Determine a plurality of resource data to be accessed by n terminal devices according to the resource IDs of the m resource access requests.
[0143] Among them, m resource access requests are issued by n terminal devices, and multiple resource data to be accessed by each terminal device are determined according to the resource IDs carried in the m resource access requests. The resource data to be accessed by each terminal device may be the same or different.
[0144] For example: n=3, m=200, the four terminal devices are: UE1, UE2 and UE3, the number of resource access requests issued by UE1 is 100, and the resource data to be accessed corresponding to the 100 resource access requests are: 50 resource data 1, 30 resource data 2 and 20 resource data 3; the number of resource access requests issued by UE2 is 80, and the resource data to be accessed corresponding to the 80 resource access requests are: 40 resource data 1, 20 resource data 2, and 20 resource data 3; the number of resource access requests issued by UE3 is 20, and the resource data corresponding to the 20 resource access requests are: 10 resource data 1, 5 resource data 2 and 5 resource data 3. According to the above statistical results, it can be determined that the multiple resource data are resource data 1, resource data 2 and resource data 3, totaling 3 resource data, among which the number of visits to be carried on resource data 1 is 50+40+10=100, the number of visits to be carried on resource data 2 is 30+20+5=55, and the number of visits to be carried on resource data 3 is 20+20+5=45.
[0145] S308: Determine whether target resource data exists in the multiple resource data.
[0146] The target resource data is resource data with a visit volume greater than a second quantity threshold within a preset time period. When the target resource data exists in multiple resource data, the number of the target resource data is one or more. The preset time period and the second quantity threshold can be determined according to actual needs, and this application does not limit them. When the judgment result is yes, execute S308; when the judgment result is no, execute S309.
[0147] For example: the preset duration is 20 milliseconds, the second quantity threshold is 80, and it is assumed that the 200 resource access requests in S307 are all received within 20 milliseconds. According to the above statistical results, the number of accesses to be carried on resource data 1 is 100, which is greater than the second quantity threshold of 80, that is, resource data 1 is determined to be the target resource data.
[0148] S309: Query the server set storing the target resource data in the server cluster.
[0149] Among them, the load balancing device pre-stores or pre-configured resource deployment information of each server in the server cluster. The resource deployment information is expressed as a mapping relationship between a server ID and a resource ID. One server ID is mapped to multiple resource IDs. According to the resource deployment information, it can be known what resource data is stored in the server. The load balancing device queries the server storing the target resource data according to the resource deployment information, and the queried servers constitute a server set. The number of servers included in the server set is one or more. For example: There are 4 servers deployed in the server cluster, namely server 1, server 2, server 3 and server 4. According to the example of S307, the target resource data is resource data 1. The load balancing device determines that the target resource data is stored on server 1 and server 2 according to the pre-stored or pre-configured resource deployment information, that is, the server set includes server 1 and server 2.
[0150] S310: Process according to the default process.
[0151] Among them, the default process includes: the load balancing device receives a resource access request from a terminal device, parses the resource ID and source IP address in the resource access request, queries the server where the resource ID is located, filters out the server closest to the terminal device based on the source IP address of the terminal device and the geographic location information of the queried server, and then forwards the resource access request to the nearest server. The server responds to the resource access request and returns the resource data indicated by the resource ID to the terminal device.
[0152] S311. Determine k resource access requests for accessing target resource data from among m resource access requests.
[0153] Among them, there may be multiple resource data to be accessed by the m resource access requests, and k resource access requests to access the target resource data are determined according to the resource IDs carried in the m resource access requests, where k is less than m and is an integer. For example: according to the example of S307, the target resource data is resource data 1, and the number of resource access requests to access the target resource data 1 is 100, that is, k=100.
[0154] S312: evenly forward the k resource access requests to each server in the server set.
[0155] Among them, k resource access requests are evenly forwarded to each server in the server set, that is, the number of resource access requests carried on each server is equal or approximately equal, avoiding sending a large number of resource access requests to the same server to reduce the load of the server.
[0156] For example: according to the example of S306, k=100, UE1 issues 50 resource access requests, UE2 issues 40 resource access requests, UE3 issues 10 resource access requests, the server set includes server 1 and server 2, and server 1 and server 2 evenly carry 50 resource access requests.
[0157] Furthermore, the uniformly forwarding each resource access request in the resource access set to each server in the server set includes:
[0158] Determine a terminal device set that issues the k resource access requests and the number of resource access requests issued by each terminal device in the terminal device set;
[0159] For each terminal device in the terminal device set, query the server set that is closest to the terminal device;
[0160] According to the number of resource access requests issued by each terminal device and the query result, the k resource access requests are evenly forwarded to each server in the server set to reduce the response time of the server.
[0161] For example, according to the example of S307, the terminal device set includes UE1, UE2 and UE3, and the server set includes server 1 and server 2. The query result is: the distance between UE1 and server 1 is the shortest, and the distance between UE2 and UE3 and server 2 is the shortest. 50 resource access requests of UE1 are forwarded to server 1 for processing, and 50 resource access requests of UE2 and UE3 are forwarded to server 2 for processing.
[0162] For another example: according to the example of S307, the terminal device set includes UE1, UE2 and UE3, and the server set includes server 1 and server 2. The query result is: UE1 and UE2 are closest to server 1, and UE3 is closest to server 2. It is calculated that the average value of resource access requests carried by each server is 50. When all resource access requests of UE3 are sent to server 2, server 2 carries 10 resource access requests, and there is a difference of 40. Therefore, 40 resource access requests from 50 resource access requests issued by UE1 and 40 resource access requests issued by UE2 need to be scheduled to server 2. The scheduling method is determined according to the ratio of the number of resource access requests issued by UE1 and UE2, and (5 / 9)*40≈22 resource access requests are scheduled from UE1, and (4 / 9)*40≈18 resource access requests are scheduled from UE2, so that each terminal device sends most of the resource access requests to the nearest server, and the access volume carried by each server is equal, so as to improve the response speed of the terminal device accessing resources.
[0163] S313: Forward the target resource data returned by each server in the server set to the corresponding terminal device.
[0164] Further optionally, the load balancing device can compress the resource data from the server to reduce the amount of resource data, thereby reducing the time for resource data to be transmitted in the network, and further improving the speed at which the terminal device obtains resource data. Compression algorithms include but are not limited to Huffman coding, LZ77 algorithm or geometric coding algorithm.
[0165] Further optionally, when resource data needs to be updated, the update method can be static update or dynamic update. When the server cluster is in an idle state, the updated resource data is synchronized to each server in the server cluster so that when the terminal device accesses the resource data, it can obtain it from the nearest server, thereby improving the speed at which the terminal device obtains resource data.
[0166] Further optionally, in order to improve the security of data transmission between the terminal device and the server and reduce the possibility of data leakage, (Transport Layer Security) or (Secure Sockets Layer) is used to transmit data between the server and the terminal device.
[0167] Further optionally, the TCP (Transmission Control Protocol) protocol is used to transmit data between the terminal device and the server, and the routing information is automatically adjusted in real time based on the Cubic algorithm, Bic algorithm or Westwood algorithm during the data transmission process to avoid network congestion, packet loss and offline problems. In addition, in order to improve the network delay problem caused by NAT (Network Address Translation) nesting, the application can directly use the IPV6 connection protocol to reduce the NAT delay problem.
[0168] In addition, to further improve the speed at which the terminal device loads resource data, the terminal device may use one or more of the following methods to load resource data and display corresponding interface elements on the user interface according to the resource data.
[0169] Method 1:
[0170] The terminal device uses segmented loading to load resource data. The segmented loading process includes: when the size of the page to be displayed is larger than the display area of the terminal device, a scroll bar is set on the page. When a drag operation on the scroll bar is detected, the terminal device first loads the resource data in the display area, and then loads the resource data outside the display area, that is, the resource data of the page is loaded in segments. This can speed up the display of interface elements in the display area and improve the loading speed of the terminal device in loading the content in the display area.
[0171] Method 2:
[0172] The terminal device uses hidden loading to load resource data. The hidden loading process includes: when the terminal device displays resource data in the current display area, it creates a thread in the background, uses the thread to load resource data that is not displayed temporarily and caches the resource data, and when the resource data needs to be displayed, directly calls the resource data to display in the display area, thereby improving the loading speed of resource data.
[0173] Method 3:
[0174] The terminal device uses preloading technology to load resource data. The preloading process includes: monitoring the parameter values of the load parameters of the terminal device. The load parameters include: CPU occupancy, disk IO operation number or memory occupancy, etc. When it is detected that the terminal device load is light according to the parameter value of the load parameter, the specified resource data is obtained from the server and cached. When the resource data needs to be displayed, it is directly extracted from the cache, which can increase the loading speed of the resource data.
[0175] Method 4:
[0176] The terminal device uses advance loading to load resource data. The extraction and loading process includes: the terminal device collects the user's operating habit information and historical access records, and then uses a machine learning algorithm to train the model using the operating habit information and historical access records to obtain a machine learning model. The machine learning model is used to predict resource data that the user may access in a future time period, and the resource data is obtained from the server in advance and cached. When the resource data needs to be displayed, it is directly extracted from the cache, which can increase the loading speed of the resource data.
[0177] Above Figures 2 to 3 A method for accessing resources is described in detail. A structural diagram of a device according to an embodiment of the present application is shown.
[0178] See also Figure 4 , Figure 4 It is a structural diagram of a device 4 provided in an embodiment of the present application. The device 4 may include a transceiver unit 401, a determination unit 402 and a scheduling unit 403.
[0179] The transceiver unit 401 is used to receive m resource access requests from n terminal devices; wherein m and n are integers greater than 1, and each resource access request carries a source IP address and a resource ID;
[0180] The determination unit 402 is configured to determine a target server in the server cluster if a target terminal device exists among the n terminal devices; wherein the target terminal device is a terminal device whose access volume is greater than a first quantity threshold within a preset time period; and the target server is a server having the best link quality with the target terminal device;
[0181] The scheduling unit 403 is used to determine the resource data to be accessed according to the resource IDs carried in the multiple resource access requests from the target terminal device, and schedule the resource data to the target server;
[0182] The transceiver unit 401 is further configured to forward the multiple resource access requests to the target server;
[0183] The transceiver unit 401 is further configured to forward the resource data returned by the target server to the target terminal device.
[0184] In one possible design, the method further includes:
[0185] A distribution unit, configured to determine, if the target terminal device does not exist among the n terminal devices, a plurality of resource data to be accessed by the n terminal devices according to the resource IDs carried by the m resource access requests;
[0186] Determine whether there is target resource data among the multiple resource data; wherein the target resource data is resource data with a preset time duration and a visit volume greater than a second quantity threshold;
[0187] If yes, query the server cluster for a set of servers storing the target resource data;
[0188] Determining k resource access requests for accessing target resource data from the m resource access requests; wherein k < m and is an integer;
[0189] Evenly forwarding the k resource access requests to each server in the server set;
[0190] The target resource data returned by each server in the server set is forwarded to the corresponding terminal device.
[0191] In a possible design, the uniformly forwarding each resource access request in the resource access set to each server in the server set includes:
[0192] Determine a terminal device set that issues the k resource access requests and the number of resource access requests issued by each terminal device in the terminal device set;
[0193] For each terminal device in the terminal device set, query the server set that is closest to the terminal device;
[0194] According to the number of resource access requests issued by each terminal device and the query result, the k resource access requests are evenly forwarded to each server in the server set.
[0195] In a possible design, determining the target server in the server cluster includes:
[0196] Sending a test data packet to each server, and receiving a response data packet returned by each server in response to the test data packet;
[0197] The round trip time of each server is calculated based on the sending time of the test data packet and the receiving time of the response data packet;
[0198] Use the server with the shortest round trip time as the target server; or
[0199] Monitor the parameter values of the load status parameters of each server;
[0200] Use the server with the lightest load as the target server; or
[0201] Obtaining geographic location information of the target terminal device and the geographic location information of each server;
[0202] The server closest to the target terminal device is used as the target server.
[0203] In a possible design, obtaining address location information includes:
[0204] Obtained by parsing the geographical location information of the terminal device carried in the resource access request; or
[0205] Parse the resource access request to obtain the source IP address, and determine the corresponding geographic location information based on the source IP address.
[0206] In one possible design, the method further includes:
[0207] The compression unit is used to compress the resource data from the server.
[0208] In one possible design, it also includes:
[0209] The synchronization unit is used to synchronize updated resource data to each server in the server cluster when it is detected that the server cluster is in an idle state.
[0210] The embodiments of this application and Figure 2 and Figure 3 The method embodiments are based on the same concept, and the technical effects they bring are also the same. The specific process can be referred to Figure 2 and Figure 3 The description of the method embodiment will not be repeated here.
[0211] Device 4 can be a load balancing device, and the device 4 can also be a field-programmable gate array (FPGA), a dedicated integrated chip, a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processing circuit, a microcontroller unit (MCU), and a programmable logic device (PLD) or other integrated chips.
[0212] Figure 5 A schematic diagram of a device structure provided in an embodiment of the present application, hereinafter referred to as device 5, can be integrated into a load balancing device, such as Figure 5 As shown, the device 5 includes: a memory 502 , a processor 501 and a transceiver 503 .
[0213] The memory 502 may be an independent physical unit, and may be connected to the processor 501 and the transceiver 503 via a bus. The memory 502, the processor 501, and the transceiver 503 may also be integrated together and implemented via hardware.
[0214] The memory 502 is used to store programs for implementing the above method embodiments or various modules of the device embodiments, and the processor 501 calls the program to execute the operations of the above method embodiments.
[0215] Optionally, the device 5 further includes an input device and an output device, the input device includes but is not limited to a keyboard, a mouse, a touch panel, a camera and a microphone; the output device includes but is limited to a display screen.
[0216] The communication interface is used to send and receive various types of messages, and the communication interface includes but is not limited to a wireless interface or a wired interface.
[0217] Optionally, when part or all of the methods for accessing resources in the above embodiments are implemented by software, the device may also include only a processor. The memory for storing programs is located outside the device, and the processor is connected to the memory through circuits / wires to read and execute the programs stored in the memory.
[0218] The processor may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.
[0219] The processor may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0220] The memory may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory may also include a combination of the above types of memory.
[0221] An embodiment of the present application further provides a computer storage medium storing a computer program, wherein the computer program is used to execute the method for accessing resources provided in the above embodiment.
[0222] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the method for accessing resources provided in the above embodiment.
[0223] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0224] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0225] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0226] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
Claims
1. A method for accessing resources, characterized in that: include: Receive m resource access requests from n terminal devices; where m and n are integers greater than 1, and each resource access request carries a source IP address and a resource ID; If there is a target terminal device among the n terminal devices, determine a target server in the server cluster; wherein the target terminal device is a terminal device whose access volume is greater than a first quantity threshold within a preset time period; and the target server is a server with the best link quality with the target terminal device; Determine resource data to be accessed according to resource IDs carried in multiple resource access requests from the target terminal device, and dispatch the resource data to the target server; forwarding the multiple resource access requests to the target server; The resource data returned by the target server is forwarded to the target terminal device.
2. The method according to claim 1, characterized in that Also includes: If the target terminal device does not exist among the n terminal devices, determining the multiple resource data to be accessed by the n terminal devices according to the resource IDs carried by the m resource access requests; Determine whether there is target resource data among the multiple resource data; wherein the target resource data is resource data with a preset time duration and a visit volume greater than a second quantity threshold; If yes, query the server cluster for a set of servers storing the target resource data; Determining k resource access requests for accessing target resource data from the m resource access requests; wherein k < m and is an integer; Evenly forwarding the k resource access requests to each server in the server set; The target resource data returned by each server in the server set is forwarded to the corresponding terminal device.
3. The method according to claim 2, characterized in that The method of uniformly forwarding each resource access request in the resource access set to each server in the server set includes: Determine a terminal device set that issues the k resource access requests and the number of resource access requests issued by each terminal device in the terminal device set; For each terminal device in the terminal device set, query the server set that is closest to the terminal device; According to the number of resource access requests issued by each terminal device and the query result, the k resource access requests are evenly forwarded to each server in the server set.
4. The method according to claim 1, 2 or 3, characterized in that: Determining the target server in the server cluster includes: Sending a test data packet to each server, and receiving a response data packet returned by each server in response to the test data packet; The round trip time of each server is calculated based on the sending time of the test data packet and the receiving time of the response data packet; Use the server with the shortest round trip time as the target server; or Monitor the parameter values of the load status parameters of each server; Use the server with the lightest load as the target server; or Obtaining geographic location information of the target terminal device and the geographic location information of each server; The server closest to the target terminal device is used as the target server.
5. The method according to claim 4, characterized in that The obtaining of address location information includes: Obtained by parsing the geographical location information of the terminal device carried in the resource access request; or Parse the resource access request to obtain the source IP address, and determine the corresponding geographic location information based on the source IP address.
6. The method according to claim 1, 2 or 5, characterized in that: Also includes: Compress resource data from the server.
7. The method according to claim 6, characterized in that Also includes: When it is detected that the server cluster is in an idle state, the updated resource data is synchronized to each server in the server cluster.
8. A device for accessing resources, characterized in that: include: A transceiver unit, configured to receive m resource access requests from n terminal devices; wherein m and n are integers greater than 1, and each resource access request carries a source IP address and a resource ID; A determination unit, configured to determine a target server in the server cluster if a target terminal device exists among the n terminal devices; wherein the target terminal device is a terminal device whose access volume is greater than a first quantity threshold within a preset time period; and the target server is a server having the best link quality with the target terminal device; A scheduling unit, configured to determine resource data to be accessed according to resource IDs carried in a plurality of resource access requests from the target terminal device, and schedule the resource data to the target server; The transceiver unit is further configured to forward the multiple resource access requests to the target server; The transceiver unit is further used to forward the resource data returned by the target server to the target terminal device.
9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Resource acquisition method and proxy server
CN108337327A
Resource data acquisition method and device, computer equipment and storage medium
CN110727499A
Server scheduling method, device and system, storage medium and computer equipment
CN111491013A
Portable, resource sharing file server using co-routines
EP0426323A2
