Cache scheduling method and system for image slicing service
By determining the request for map slices under high concurrency and establishing a new cache service, the problem of slow map slices producing graphs under high concurrency is solved, and map loading efficiency and user experience are improved.
Patent Information
- Application Number
- CN202510085757.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-16
AI Technical Summary
In high concurrency, the static map slicing is slower to produce, resulting in slower map loading speed and affecting user experience.
By determining the slice range before searching for slices, it is determined whether the latitude and longitude ranges of the four corners of the slice match the requested layer range, and a new cache service is established when the number of requests exceeds the preset threshold, thereby dynamically allocating the request to the original and newly established cache services.
Reduces invalid access and operations, improves the efficiency of obtaining map slicing, avoids degradation in slicing service performance, reduces the time to wait for map output, and thus improves the efficiency and user experience of map loading.
Smart Images

Figure CN120013743A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geographic information technology, and more specifically, to a cache scheduling method and system for image slice services. Background Art
[0002] With the development of information technology and geographic information systems, when loading a map on an electronic device, it is generally done by calling multiple map slices of the map to load the complete map data on the display interface of the electronic device. Among them, the map cache is a directory containing map slices of the entire map range at different scales. Based on the cache service, static images can be used to quickly provide maps, thereby improving the user experience.
[0003] Most of the existing tile loading is based on dynamic tiling and caching. However, in some scenarios, static map tiling has more obvious advantages. However, when using static map tiling, in high concurrency situations (a large number of requests suddenly emerge), the tiling may still be slow, which will slow down the map loading speed and affect the user experience. Summary of the invention
[0004] In order to solve the above-mentioned technical problem of slow static slicing output under high concurrency conditions, the present invention provides solutions in the following aspects.
[0005] In a first aspect, the present invention provides a cache scheduling method for an image slice service, comprising:
[0006] In response to receiving a request to obtain a map slice, determining the longitude and latitude ranges of four corners of the slice according to the slice level, slice row number, and slice column number carried in the request;
[0007] Determine whether the latitude and longitude ranges of the four corners of the slice match the requested layer range. If so, return the corresponding slice from the original cache service and / or the newly created cache service; if not, return an error prompt.
[0008] Furthermore, returning corresponding slices from the original cache service and / or the newly created cache service includes: determining whether there is currently an idle cache service, and if so, returning corresponding slices from the currently idle cache service according to slice levels, slice row numbers, and slice column numbers; if not, establishing a new cache service, and returning corresponding slices from the new cache service and the original cache service according to slice levels, slice row numbers, and slice column numbers.
[0009] Further, determining whether there is currently an idle cache service includes: determining whether the load of the slice cache reaches a preset threshold, if so, there is no idle cache service; if not, there is an idle cache service.
[0010] Furthermore, corresponding slices are returned from the new cache service and the original cache service according to the slice level, slice row number and slice column number, including: preferentially allocating requests to the original cache service, and allocating the remaining parts to the new cache service.
[0011] Furthermore, corresponding slices are returned from the new cache service and the original cache service according to the slice level, slice row number and slice column number, including: dynamically allocating requests to the original cache service and the new cache service to minimize the difference in load between the original cache service and the new cache service.
[0012] Further, the latitude and longitude ranges of the four corners of the slice are determined according to the slice level, slice row number, and slice column number carried in the request, including:
[0013]
[0014] Where lon_min represents the minimum longitude of the slice, lon_max represents the maximum longitude of the slice, lat_min represents the minimum latitude of the slice, lat_max represents the maximum latitude of the slice, Z represents the slice level, X represents the slice row number, and Y represents the slice column number.
[0015] Furthermore, it is determined whether the longitude and latitude ranges of the four corners of the slice match the requested layer range, including: in response to the longitude and latitude ranges of the four corners of the slice and the layer range both corresponding to rectangular ranges, it is determined whether there is an intersection or inclusion relationship between the rectangle corresponding to the slice range and the rectangle corresponding to the layer range; if so, the longitude and latitude ranges of the four corners of the slice match the requested layer range; if not, the longitude and latitude ranges of the four corners of the slice do not match the requested layer range.
[0016] Furthermore, judging whether the rectangle corresponding to the slice range and the rectangle corresponding to the layer range intersect or contain each other includes:
[0017] In response to satisfying a preset condition, the rectangle corresponding to the slice range and the rectangle corresponding to the layer range have an intersection or inclusion relationship; the preset condition is:
[0018]
[0019] In the formula, x1 and y1 are the horizontal and vertical coordinates of one diagonal vertex of the rectangle corresponding to the slice range, x2 and y2 are the horizontal and vertical coordinates of the other diagonal vertex of the rectangle corresponding to the slice range, x3 and y3 are the horizontal and vertical coordinates of one diagonal vertex of the rectangle corresponding to the layer range, and x4 and y4 are the horizontal and vertical coordinates of the other diagonal vertex of the rectangle corresponding to the layer range.
[0020] Furthermore, the method of the present invention also includes: determining the layer range according to the layer ID in the request.
[0021] In a second aspect, the present invention provides a cache scheduling system for an image slice service, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a cache scheduling method for an image slice service described in the first aspect is implemented.
[0022] The beneficial effect of the present invention is that the method of the present invention can reduce invalid access and operations by determining the slice range before searching for slices, thereby improving the efficiency of obtaining map slices, and further improving the efficiency of map loading. Furthermore, by establishing a new cache service when the number of requests exceeds a preset threshold, and returning slices from the new cache service, the degradation of the slice service performance is avoided, thereby reducing the waiting time for map output, and further improving the efficiency of obtaining map slices. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0024] Figure 1 is a flowchart schematically illustrating a cache scheduling method for an image slice service according to an embodiment of the present invention;
[0025] Figure 2 is a flowchart schematically illustrating a cache scheduling method for an image slice service according to another embodiment of the present invention;
[0026] Figure 3 is a schematic diagram schematically illustrating a layer range and a slice range according to an embodiment of the present invention;
[0027] Figure 4 is a flowchart schematically illustrating slice service scheduling according to an embodiment of the present invention;
[0028] Figure 5 is a flowchart schematically illustrating slice service scheduling according to another embodiment of the present invention;
[0029] Figure 6 It is a structural block diagram schematically showing a cache scheduling system for an image slice service according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0031] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0032] Figure 1 It is a flowchart schematically illustrating a cache scheduling method for an image slice service according to an embodiment of the present invention.
[0033] In a first aspect, the present invention provides a cache scheduling method for an image slice service, such as Figure 1 As shown, the method of the present invention comprises:
[0034] S101. In response to receiving a request for obtaining a map slice, determine the longitude and latitude ranges of the four corners of the slice.
[0035] Before displaying the map, the map client initiates a request to obtain a map slice from the slice server. In one embodiment, the request to obtain a map slice carries a layer id, a slice level, a slice row number, and a slice column number.
[0036] After receiving the request, the slice server can calculate the longitude and latitude range of the four corners of the slice (i.e., the slice range) according to the slice level, slice row number, and slice column number in the request. Specifically, first, the minimum latitude and maximum latitude (i.e., south latitude and north latitude) of the slice can be determined according to the slice level and slice row number; secondly, the minimum longitude and maximum longitude (i.e., west longitude and east longitude) of the slice can be determined according to the slice level and slice column number, thereby obtaining the slice range. It can be understood that the slice range is the boundary range of the covered geographical area.
[0037] In one embodiment, the calculation expression of the minimum longitude (i.e., west longitude) of a slice is:
[0038]
[0039] Where lon_min represents the minimum longitude of the slice, Z represents the slice level, and X represents the slice row number.
[0040] Furthermore, the calculation expression of the maximum longitude (i.e. east longitude) of the slice is:
[0041]
[0042] Where lon_max represents the maximum longitude of the slice, Z represents the slice level, and X represents the slice row number.
[0043] Furthermore, the calculation expression of the minimum latitude of the slice (i.e., south latitude) is:
[0044]
[0045] Where lat_min represents the minimum latitude of the slice, Z represents the slice level, and Y represents the slice column number.
[0046] Furthermore, the calculation expression of the maximum latitude of the slice (i.e., the north latitude) is:
[0047]
[0048] Where lat_max represents the maximum latitude of the slice, Z represents the slice level, and Y represents the slice column number.
[0049] According to the east longitude, west longitude, south latitude and north latitude obtained above, the longitude and latitude ranges of the four corners of the slice are formed.
[0050] S102. Determine whether the latitude and longitude ranges of the four corners of the slice match the requested layer range. If so, return the corresponding slice from the original cache service and / or the newly created cache service; if not, return an error prompt.
[0051] Specifically, the slice server determines whether the latitude and longitude ranges of the four corners of the slice match the requested layer range. If they do not match, it indicates that the map slice is not stored in the slice server, and an error is returned to prompt the user that the current request exceeds the access range; if they match, it indicates that the resources of the slice are stored in the slice server, and the corresponding slice is returned.
[0052] In other optional embodiments, the cache scheduling method of the present invention can also be as follows: Figure 2 As shown, the latitude and longitude range of the slice is separated from the layer range, that is, the slice range does not match the layer range.
[0053] In one embodiment, when the slice range and the layer range are both rectangular ranges (generally speaking, the slice range and the layer range are both rectangular ranges, such as Figure 3 As shown, rectangle 1 is the rectangle corresponding to the layer range, rectangle 2 is the rectangle corresponding to the slice 1 range, rectangle 3 is the rectangle corresponding to the slice 2 range, and rectangle 4 is the rectangle corresponding to the slice 3 range). It can be determined whether the slice range matches the requested layer range by judging whether the rectangle corresponding to the slice range and the rectangle corresponding to the layer range intersect or contain each other. Schematically, as Figure 3As shown, the range of slice 1 and the range of slice 2 both match the range of the layer (that is, rectangle 2 and rectangle 3 intersect or contain rectangle 1, respectively), and the range of slice 3 does not match the range of the layer (that is, rectangle 4 neither intersects nor contains rectangle 1).
[0054] It should be noted that the slice server can determine the layer range corresponding to the requested slice according to the layer id in the request. Specifically, the layer metadata can be found in the service according to the layer id, and the layer metadata contains the layer range, which corresponds to the map slice stored in the slice server. It can be understood that the layer range also corresponds to the latitude and longitude range of the four corners.
[0055] In one embodiment, when the rectangle corresponding to the slice range and the rectangle corresponding to the layer range meet a preset condition, it indicates that the two have an intersection or inclusion relationship. Specifically, the preset condition is as follows:
[0056]
[0057] In the formula, x1 and y1 are the horizontal and vertical coordinates of one diagonal vertex of the rectangle corresponding to the slice range, x2 and y2 are the horizontal and vertical coordinates of the other diagonal vertex of the rectangle corresponding to the slice range, x3 and y3 are the horizontal and vertical coordinates of one diagonal vertex of the rectangle corresponding to the layer range, and x4 and y4 are the horizontal and vertical coordinates of the other diagonal vertex of the rectangle corresponding to the layer range.
[0058] It is understandable that if one diagonal vertex of the rectangle corresponding to the slice range is the upper right vertex, then the other diagonal vertex is the lower left vertex. In addition, the two diagonal vertices of the layer range correspond to the slice range (i.e., the lower left vertex corresponds to the lower left vertex, and the upper right vertex corresponds to the upper right vertex) to determine the intersection or inclusion relationship. In addition, it is understandable that the coordinates of the four vertices of the rectangle corresponding to the slice range can be determined based on the latitude and longitude ranges of the four corners of the slice obtained above.
[0059] In the above preset conditions, max(x1,x3) represents the maximum value of x1 and x3, that is, the point where the two rectangles are closer to the positive semi-axis on the x-axis, and min(x2,x4) represents the minimum value of x2 and x4, that is, the point where the two rectangles are closer to the negative semi-axis on the x-axis. When max(x1,x3)≤min(x2,x4), it indicates that the two rectangles overlap in the x-axis direction. Similarly, when max(y1,y3)≤min(y2,y4), it indicates that the two rectangles overlap in the y-axis direction.
[0060] It is understandable that when the rectangle corresponding to the slice range intersects with the rectangle corresponding to the layer range (such as Figure 3Rectangle 1 and rectangle 2 shown) or including (such as Figure 3 The relationship between rectangle 1 and rectangle 3) shown in the figure both meets the above preset conditions.
[0061] It should be noted that when the rectangle corresponding to the slice range intersects with the rectangle corresponding to the layer range (i.e. Figure 3 If some slices are not included in the layer range (indicates that there is no slice at this location in the layer range), a 404 (not found) request will occur. Although this method will trigger an error request, it is more efficient and the number of 404 requests triggered is controllable, while other methods may increase the time complexity and the number of 404 requests, thus affecting the efficiency of slice return.
[0062] In an optional embodiment, the preset condition may also be:
[0063]
[0064] It is understandable that the preset condition is met only when the rectangle corresponding to the slice range and the rectangle corresponding to the layer range are contained. Therefore, the slice range that meets the preset condition will be within the layer range, thereby avoiding the request 404, but it may increase the time complexity. Those skilled in the art can make a choice according to actual needs.
[0065] By performing range judgment before searching for slices, invalid operations and accesses can be avoided. For example, the number of slice searches can be reduced, thereby effectively improving the efficiency of obtaining map slices and further improving the efficiency of map loading.
[0066] Furthermore, after determining that the slice range matches the requested layer range, determine whether there is currently an idle cache service. If there is an idle cache service, return the corresponding slice directly from the currently idle cache service according to the slice level, slice row number and slice column number; if there is no idle cache service, copy the slice from the cache service with a smaller current load, establish a new cache service, and then return the corresponding slice from the new cache service and the original cache service according to the slice level, slice row number and slice column number.
[0067] In one embodiment, it is possible to determine whether there is currently an idle cache service by judging whether the load of the slice cache reaches the threshold of the slice service being fully loaded. Specifically, if the threshold of the slice service being fully loaded is not reached, there is an idle cache service; if the threshold of the slice service being fully loaded is reached, there is no idle cache service.
[0068] In one embodiment, the map slice service scheduler is as follows: Figure 4 As shown. Figure 4It can be seen that at time 1, the slice server receives 80qps requests (that is, the system receives 80 requests per second). At this time, the number of requests does not exceed the load limit of the slice service (100qps, that is, the preset threshold), indicating that there is an idle cache service, so it directly uses the current cache service (that is, Figure 4 , and the corresponding tile (i.e., slice) is returned to the slice service 8080 in the map. At time 2, the slice server receives 160qps requests. At this time, the number of requests has exceeded the load limit of the original slice service 8080. In the prior art, all these requests will be directly allocated to the slice service 8080. However, since the number of requests has exceeded the load limit of the slice service 8080, the performance of the slice service 8080 will drop sharply, resulting in a decrease in the speed at which the slice service 8080 processes requests, which in turn results in an increase in the time it takes to output slices. In this regard, in order to avoid the effect of increased time on map loading caused by outputting slices, 100qps requests are first allocated to the slice service 8080 to ensure the performance of the slice service 8080. At this time, there are still 60qps requests to be allocated. Since there are no idle cache services, slices can be copied from smaller cache services, and then a new cache service (i.e. Figure 4 8081 in the slice service), and then distribute the 60qps request to the newly established slice service 8081 so that the slice service 8081 can handle the remaining requests. Since the 60qps request does not exceed the load limit of the slice service 8081, the performance of the slice service 8081 is not limited, which will not affect the efficiency of map slicing. At time 3, the slice server receives a 60qps request. Since the number of requests does not exceed the load limit of the slice service, it indicates that there is an idle cache service, and the corresponding slice can be returned directly from the slice service 8080. At this time, the slice service 8081 is in an idle state. In other optional embodiments, at time 3, the 60qps request can be evenly distributed to the slice service 8080 and the slice service 8081 to speed up the efficiency of outputting slices. By establishing a new slice service after reaching the load limit of the slice service, the performance degradation of the slice service can be avoided, thereby avoiding the problem of prolonged time for outputting tiles, thereby improving the efficiency of map loading.
[0069] In an optional embodiment, the map slice service scheduling can also be as follows Figure 5After determining that the number of received requests exceeds the load limit of the slice service, a new cache service can be established based on the original cache service, and then these requests can be dynamically allocated to the original cache service (i.e., slice service 8080) and the new cache service (i.e., slice service 8081) to minimize the difference between the load of slice service 8080 and the load of slice service 8081, even if the load of slice service 8080 and slice service 8081 is balanced (in Figure 5 In the example, 160 qps is evenly distributed to slice service 8080 and slice service 8081. By dynamically allocating requests (i.e., making the slice services load balanced), the resource utilization of the system can be improved.
[0070] It is understandable that those skilled in the art may choose to allocate the request first or to establish a new cache service first according to actual needs.
[0071] In summary, by establishing a new cache service when the number of requests exceeds the slice service, the slow output of slices in a single-layer cache under high concurrency conditions is avoided, thereby improving the efficiency of obtaining map slices, and then improving the efficiency of map loading and improving the user experience.
[0072] Figure 6 It is a structural block diagram schematically showing a cache scheduling system of an image slice service according to this embodiment.
[0073] In a second aspect, the present invention also provides a cache scheduling system for image slice services. Figure 6 As shown, the cache scheduling system of the image slice service includes a processor and a memory, and the memory stores computer program instructions. When the computer program instructions are executed by the processor, a cache scheduling method for the image slice service according to the first aspect of the present invention is implemented.
[0074] The cache scheduling system of the image slice service also includes other components familiar to those skilled in the art, such as a communication interface, and their settings and functions are known in the art, so they will not be described in detail here.
[0075] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that may be used to store the required information and may be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device. Any application or module described in the present invention may be implemented using computer-readable / executable instructions that may be stored or otherwise maintained by such a computer-readable medium.
[0076] In the description of this specification, "plurality" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0077] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A cache scheduling method for image slice service, characterized in that: include: In response to receiving a request to obtain a map slice, determining the longitude and latitude ranges of four corners of the slice according to the slice level, slice row number, and slice column number carried in the request; Determine whether the latitude and longitude ranges of the four corners of the slice match the requested layer range. If so, return the corresponding slice from the original cache service and / or the newly created cache service; if not, return an error prompt.
2. The cache scheduling method for image slice service according to claim 1, characterized in that: Return the corresponding slice from the original cache service and / or the newly created cache service, including: determining whether there is currently an idle cache service, and if so, returning the corresponding slice from the currently idle cache service according to the slice level, slice row number and slice column number; if not, establishing a new cache service, and returning the corresponding slice from the new cache service and the original cache service according to the slice level, slice row number and slice column number.
3. The cache scheduling method for image slice service according to claim 2, characterized in that: Determining whether there is currently an idle cache service includes: determining whether the load of the slice cache reaches a preset threshold, if so, there is no idle cache service; if not, there is an idle cache service.
4. The cache scheduling method for image slice service according to claim 2 or 3, characterized in that: Return corresponding slices from the new cache service and the original cache service according to the slice level, slice row number and slice column number, including: preferentially allocating requests to the original cache service, and allocating the remaining parts to the new cache service.
5. The cache scheduling method for image slice service according to claim 2 or 3, characterized in that: Return corresponding slices from the new cache service and the original cache service according to the slice level, slice row number and slice column number, including: dynamically allocating requests to the original cache service and the new cache service to minimize the difference in load between the original cache service and the new cache service.
6. The cache scheduling method for image slice service according to claim 1, characterized in that: The latitude and longitude ranges of the four corners of the slice are determined according to the slice level, slice row number, and slice column number carried in the request, including: Where lon_min represents the minimum longitude of the slice, lon_max represents the maximum longitude of the slice, lat_min represents the minimum latitude of the slice, lat_max represents the maximum latitude of the slice, Z represents the slice level, X represents the slice row number, and Y represents the slice column number.
7. The cache scheduling method for image slice service according to claim 1, characterized in that: Determine whether the longitude and latitude ranges of the four corners of the slice match the requested layer range, including: in response to the longitude and latitude ranges of the four corners of the slice and the layer range both corresponding to rectangular ranges, determine whether there is an intersection or inclusion relationship between the rectangle corresponding to the slice range and the rectangle corresponding to the layer range; if so, the longitude and latitude ranges of the four corners of the slice match the requested layer range; if not, the longitude and latitude ranges of the four corners of the slice do not match the requested layer range.
8. The cache scheduling method for image slice service according to claim 7, characterized in that: Determine whether the rectangle corresponding to the slice range intersects or contains the rectangle corresponding to the layer range, including: In response to satisfying a preset condition, the rectangle corresponding to the slice range and the rectangle corresponding to the layer range have an intersection or inclusion relationship; the preset condition is: In the formula, x1 and y1 are the horizontal and vertical coordinates of one diagonal vertex of the rectangle corresponding to the slice range, x2 and y2 are the horizontal and vertical coordinates of the other diagonal vertex of the rectangle corresponding to the slice range, x3 and y3 are the horizontal and vertical coordinates of one diagonal vertex of the rectangle corresponding to the layer range, and x4 and y4 are the horizontal and vertical coordinates of the other diagonal vertex of the rectangle corresponding to the layer range.
9. The cache scheduling method for image slice service according to claim 1, characterized in that: Also includes: Determine the layer range according to the layer ID in the request.
10. A cache scheduling system for image slice service, characterized in that: It includes a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a cache scheduling method for image slice service according to claims 1-9 is implemented.