DNS cache resource management method, system and product based on TTL value grouping

By adopting a cache resource management method of TTL value grouping in DNS servers, cache data is cleared in batches, and performance problems during global cache clearance are solved, achieving smooth clearance of cached data and improving system stability.

CN119046294AActive Publication Date: 2024-11-29INTERNET DOMAIN NAME SYST BEIJING ENG RES CENT
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411065498.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-11-29
Estimated Expiration
2044-08-05

AI Technical Summary

Technical Problem

When existing DNS servers are cleared global cache, they will cause performance problems, causing instantaneous surge in query pressure, affecting the performance of data processing and authoritative servers.

Method used

Adopt DNS cache resource management method based on TTL value grouping. By updating the last-flush field and instance-id field, the cache database is invalidated in batches, and the TTL value and instance version number are used to determine whether the cached data is invalid. Gradually clear the cached data to avoid one time. Sexually clear all data.

Benefits of technology

It realizes smooth clearance of cached data, reduces query pressure, improves system stability and predictability, avoids sudden surges and sudden drops in system resources, and ensures data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046294A_ABST
    Figure CN119046294A_ABST
Patent Text Reader

Abstract

The invention discloses a DNS (Domain Name Server) cache resource management method, system and product based on TTL (Transistor-Transistor Logic) value grouping, and aims to solve the problem that a current typical DNS server immediately clears all data at the same time when a global cache is cleared, the clearing process is not stable enough and the performance problem is caused. And when related cache data is found in the cache database in response to a DNS query request, carrying out logical judgment according to an instance version number and a TTL value of the cache data, a data instance version number instance-id of the cache database, a timestamp last-flush and a window time limit flush-over-time so as to determine whether the cache data is invalid or not. The grouping and batch failure of the cache data is realized, the effect of gradually clearing the data in the whole cache database in batches is achieved, and the DNS analysis fluctuation is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a DNS cache resource management method. Background Art

[0002] A typical DNS recursive server will support caching of DNS resource records obtained after recursion in order to improve its own performance and relieve the pressure on the authoritative server. The cache is usually controlled by an expiration time (i.e., TTL value) to define the available time of the cached data. After the cache is introduced to the time corresponding to the TTL value (usually in seconds), DNS recursive queries can be answered directly from the cached data. After the cache expires, it will recurse and reintroduce the cache.

[0003] The side effect of caching is that data that may have been updated by the authoritative server cannot be obtained for a period of time, so cache clearing is a very common operation for recursive servers. The current typical DNS server will immediately clear all data at the same time when clearing the global cache, so that all subsequent queries will immediately re-request the authoritative server and obtain the latest data. The advantage of this is that data consistency can be achieved at a faster speed, but on the other hand, for a recursive server with a large number of query requests, suddenly clearing the cache will cause huge query pressure in an instant. Because the performance of recursive queries will be much lower than hitting the cache database, this may cause some query requests to be unable to be processed. At this time, the sudden increase in the number of recursive queries will also transmit the impact to the recursive target, that is, the authoritative server, causing a series of effects. Summary of the invention

[0004] The present application provides a DNS cache resource management method, apparatus, computer device and computer program product based on TTL value grouping, aiming to solve the problem that the global cache clearing process of the DNS server in the prior art is not smooth enough, which may cause performance problems.

[0005] In a first aspect, a DNS cache resource management method based on TTL value grouping, the method comprising:

[0006] When receiving a global cache clearing operation instruction, the last-flush field and instance-id field pre-defined in the cache database are updated; the last-flush field indicates the timestamp of the last global cache clearing operation, which is used to record the starting time of the last global cache clearing operation. The last-flush field is updated to the current system timestamp; the instance-id field is the data instance version number of the cache database, with an initial value of 0, and each update increases by 1 on the original basis;

[0007] The cache database enters the stage of batch data expiration until the pre-set global clearing window time limit is reached, and the window time limit is recorded as flush-over-time; the data structure corresponding to each cache data in the cache database includes its own TTL field and instance version number field, wherein the instance version number of the cache data corresponds to the data instance version number of the cache database when it is added;

[0008] In the batch expiration phase, when responding to a DNS query request and finding relevant cached data in the cache database, a logical judgment is made based on the instance version number and TTL value of the cached data, the instance version number instance-id of the cache database, the timestamp last-flush, and the window time limit flush-over-time to determine whether the cached data is invalid; if it is determined to be invalid data, the cached data is ignored, a recursive query is triggered, and the data obtained by the recursive query is returned to the requester and stored in the cache database;

[0009] After the batch expiration phase ends, when responding to a DNS query request and finding relevant cached data in the cache database, it is only determined whether the instance version number of the cached data is less than the data instance version number of the cache database. If so, the cached data is considered invalid, triggering a recursive query, and returning the data obtained from the recursive query to the requester and storing it in the cache database.

[0010] In the above solution, optionally, the logical judgment is performed based on the instance version number of the cache data, the data instance version number of the cache database, the last-flush field in the cache database, and the window time limit flush-over-time to determine whether the cache data is invalid, specifically including:

[0011] Check the instance version number of the cached data. If it is equal to the instance-id of the cache database, the cached data is considered to be the latest data. Whether it has been cleared or not is not a question. It only needs to determine whether the TTL of the cached data is within the validity period.

[0012] Check the TTL value of the cached data. If the TTL value is found to have expired, the cached data will be ignored, a recursive query will be triggered, and the data obtained by the recursive query will be returned to the requester and stored in the cache database.

[0013] If the TTL of the cached data is still valid and the instance version number of the cached data is less than the instance-id of the cache database, further determine whether the data has been invalidated during the batch invalidation process. The determination method is that if the remaining time t2 of the data batch invalidation phase is less than the effective cutoff point t1 of the cached data in the batch invalidation phase, the corresponding t1 has been invalidated, that is, the cached data is invalid, and the recursive process should continue to be triggered. Otherwise, it means that the cached data is still available.

[0014] Among them, t1 is obtained by taking the modulo of the TTL value of the cached data and the flush-over-time value, and the calculation formula of t2 is

[0015] t2=flush-over-time-(n-last-flush)

[0016] n represents the timestamp of the current time.

[0017] In the above scheme, optionally, the TTL value of the cached data is the system timestamp when the data is stored in the cache database plus a random value, and the range of the random value is [0, flush-over-time), so that the TTL value distribution of each cached data is basically uniform.

[0018] In the above solution, optionally, when the cache database space is limited and new data needs to be added, the invalid data is overwritten accordingly according to the instance version number of the cache data.

[0019] In the above solution, further optionally, the corresponding overwriting of the invalid data according to the instance version number of the cached data is to use an LRU algorithm to select the data item that has not been accessed for the longest time for replacement.

[0020] In a second aspect, a DNS cache resource management system based on TTL value grouping, the system comprising:

[0021] A field update module is used to update the pre-defined last-flush field and instance-id field in the cache database when receiving a global cache clearing operation instruction; the cache database enters a phase of data batch expiration until a pre-set global clearing window time limit is reached, and the window time limit is recorded as flush-over-time; the data structure corresponding to each cache data in the cache database includes a respective TTL field and an instance version number field, wherein the instance version number of the cache data corresponds to the data instance version number of the cache database when it is added;

[0022] The cache data clearing module is used to, in the batch expiration phase, when responding to a DNS query request and finding relevant cache data in the cache database, perform logical judgment based on the instance version number and TTL value of the cache data, the data instance version number instance-id and the timestamp last-flush of the cache database, and the window time limit flush-over-time to determine whether the cache data is invalid; if it is determined to be invalid data, ignore the cache data, trigger a recursive query, return the data obtained by the recursive query to the requester and store it in the cache database; and, after the batch expiration phase ends, when responding to a DNS query request and finding relevant cache data in the cache database, only determine whether the instance version number of the cache data is less than the data instance version number of the cache database. If it is less, the cache data is considered to be invalid, trigger a recursive query, return the data obtained by the recursive query to the requester and store it in the cache database.

[0023] In a third aspect, a computer device comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0024] In a fourth aspect, a computer program product comprises a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.

[0025] Compared with the prior art, this application has at least the following beneficial effects:

[0026] Based on further analysis and research of existing technical problems, this application recognizes that the current typical DNS server will immediately clear all data at the same time when clearing the global cache. The clearing process of all data at the same time is not smooth enough and will cause performance problems. This application achieves the effect of gradually clearing the data in the overall cache database in batches by grouping the cached data according to certain rules based on the TTL of the cached data, avoiding DNS resolution fluctuations caused by global cache clearing, and improving the global cache data clearing method of the DNS recursive server.

[0027] This application also introduces a random value for the TTL value. By introducing the random value, it ensures that the TTL value distribution of each cache record is basically uniform, avoiding a relatively concentrated situation, and reducing the system pressure. At the same time, since the expiration time of the cached data is basically evenly distributed, the system's burden of processing cache invalidation requests will also be smoother, avoiding sudden surges and drops in system resources, and improving the stability and predictability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1A flowchart of a DNS cache resource management method based on TTL value grouping provided in one embodiment of the present application;

[0029] Figure 2 A module architecture block diagram of a DNS cache resource management device based on TTL value grouping provided by an embodiment of the present application;

[0030] Figure 3 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. 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.

[0032] In the description of the present application: unless otherwise specified, expressions such as “include”, “comprising”, “having”, etc. also mean “not limited to” (certain units, components, materials, steps, etc.).

[0033] In one embodiment, Figure 1 As shown, a DNS cache resource management method based on TTL value grouping is provided. This embodiment takes the method applied to a terminal as an example. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0034] When receiving a global cache clearing operation instruction, the last-flush field and instance-id field pre-defined in the cache database are updated; the last-flush field indicates the timestamp of the last global cache clearing operation, which is used to record the starting time of the last global cache clearing operation. The last-flush field is updated to the current system timestamp; the instance-id field is the data instance version number of the cache database, with an initial value of 0, and each update increases by 1 on the original basis;

[0035] The cache database enters the stage of batch data expiration until the pre-set global clearing window time limit is reached, and the window time limit is recorded as flush-over-time; the data structure corresponding to each cache data in the cache database includes its own TTL field and instance version number field, wherein the instance version number of the cache data corresponds to the data instance version number of the cache database when it is added;

[0036] In this embodiment, when data is stored in the cache database, the data instance version number of the cache database is 5, and the instance version number of the data is also 5.

[0037] In the batch expiration phase, when responding to a DNS query request and finding relevant cached data in the cache database, a logical judgment is made based on the instance version number and TTL value of the cached data, the instance version number instance-id of the cache database, the timestamp last-flush, and the window time limit flush-over-time to determine whether the cached data is invalid; if it is determined to be invalid data, the cached data is ignored, a recursive query is triggered, and the data obtained by the recursive query is returned to the requester and stored in the cache database;

[0038] After the batch expiration phase ends, when responding to a DNS query request and finding relevant cached data in the cache database, it is only determined whether the instance version number of the cached data is less than the data instance version number of the cache database. If so, the cached data is considered invalid, triggering a recursive query, and returning the data obtained from the recursive query to the requester and storing it in the cache database.

[0039] The "batch invalidation" of this application means that within a specified time window, the cached data is not physically deleted immediately, but gradually loses its validity. In this process, the data is logically considered expired, but it is not immediately removed from the cache. When the DNS server receives a query request, it checks whether the data in the cache is still within the validity period. If the data is considered invalid (that is, it does not conform to the new instance-id or has exceeded the combined limit of its TTL and flush-over-time), it will trigger a recursive query to obtain the latest data instead of directly using the data in the cache. In this way, the "clearance" of the data is actually achieved by gradually determining that the data is invalid and triggering an update, rather than physically deleting all the data from the cache at once.

[0040] When data is judged to be invalid, it will not be physically deleted from the cache immediately, but subsequent recursive queries will obtain the latest data, which will have a higher instance-id value. When new data is introduced into the cache, it will be regarded as the latest version of the data because its instance-id is higher, and will be used first in subsequent queries, which actually plays the role of "overwriting" the old data.

[0041] This application alleviates the problems caused by the one-time clearing method by setting a cache data clearing window so that all caches are invalidated in batches during this period.

[0042] The following steps are involved:

[0043] 1) Set a global flush-over-time to specify the total time required for the entire flush operation to complete. If this value is set to 0, it means that this method of cache flushing is not enabled.

[0044] 2) Set a timestamp field (last-flush) of the last flush operation for the cache database to record the start time of the last global cache flush operation.

[0045] 3) Set a data instance version number (instance-id) for the cache database, with an initial value of 0.

[0046] 4) An instance version number field is added to the data structure corresponding to each cached data, corresponding to the data instance version number (instance-id) of the database when it was added.

[0047] 5) The cached TTL is saved in the form of a timestamp (this is a typical implementation method). A random jitter value can be added to the timestamp as needed, that is, the final cached TTL timestamp is the time when the cache is introduced, plus a random value. The range of the random value is: [0, flush-over-time)

[0048] 6) When performing a global cache clearing operation, unlike the typical method of directly clearing all data, this solution will only update the last-flush and instance-id fields. The last-flush field is set to the system timestamp when this operation occurs, and the instance-id field will be increased by 1 based on the original value.

[0049] 7) After completing step 6, the cache database will enter the stage of batch data invalidation.

[0050] After the batch expiration phase ends (the current system timestamp is greater than or equal to the sum of the last-flush + flush-over-time values), if relevant data is found during cache query, the batch issue is no longer involved in determining whether it is invalid. Instead, the data instance-id is only checked to see if it is less than the database instance-id. If so, it is considered invalid.

[0051] The data instance version number is used to identify the "freshness" or "batch" of the cache. Whenever a global cache operation is performed, the database data instance version number will increase, indicating the start of a new data batch or cycle. During the batch expiration phase, the system does not directly delete the cached data of the old batch, but instead uses a series of combined rules to invalidate the cached data in batches.

[0052] Once the batch invalidation phase ends (i.e. the current time is greater than or equal to the sum of the last-flush + flush-over-time values), all cached data belonging to the old batch (i.e. the instance version number of the cached data is less than the instance-id of the data instance in the current database) should have been processed (whether it is naturally expired or logically determined to be invalid). At this point, the system no longer needs to rely on complex batch invalidation logic to determine whether the cached data is valid, because all data in the old batches are outdated.

[0053] In order to simplify the logic of cache query, a rule can be set at this time: as long as the data instance version number of the cached data is smaller than the data instance version number of the database, the cached data is considered invalid.

[0054] In this way, there is no need to perform complex calculations and judgments when querying, and you only need to simply compare the two version numbers. In addition, by ensuring that the cached data of the old batch is considered invalid after the batch invalidation phase ends, the system can ensure that the data in the cache is consistent with the latest data in the database, which helps to simplify the cache query logic and ensure data consistency.

[0055] During the batch expiration phase, when a DNS request queries the cache and finds relevant data, the following situations may occur:

[0056] In one embodiment, the logical judgment is performed based on the instance version number of the cache data, the data instance version number of the cache database, the last-flush field in the cache database, and the window time limit flush-over-time to determine whether the cache data is invalid, specifically including:

[0057] Check the instance version number of the cached data. If it is equal to the instance-id of the cache database, the cached data is considered to be the latest data. Whether it has been cleared or not is not a question. It only needs to determine whether the TTL of the cached data is within the validity period.

[0058] Check the TTL value of the cached data. If the TTL value is found to have expired, the cached data will be ignored, a recursive query will be triggered, and the data obtained by the recursive query will be returned to the requester and stored in the cache database.

[0059] If the TTL of the cached data is still valid and the instance version number of the cached data is less than the instance-id of the cache database, further determine whether the data has been invalidated during the batch invalidation process. The determination method is that if the remaining time t2 of the data batch invalidation phase is less than the effective cutoff point t1 of the cached data in the batch invalidation phase, the corresponding t1 has been invalidated, that is, the cached data is invalid, and the recursive process should continue to be triggered. Otherwise, it means that the cached data is still available.

[0060] Among them, t1 is obtained by taking the modulo of the TTL value of the cached data and the flush-over-time value, and the calculation formula of t2 is

[0061] t2=flush-over-time-(n-last-flush)

[0062] n represents the timestamp of the current time.

[0063] In the batch expiration stage, when the DNS request queries the cache and finds relevant data, it will involve the above-mentioned multiple situations. As mentioned earlier, the TTL values ​​of each cache data are randomly and evenly distributed, all caches are naturally grouped according to the above steps to achieve batch expiration.

[0064] In one of the steps of this embodiment, the data instance version number and the TTL value jointly determine the validity of the cached data. The data instance version number ensures the consistency of the cached data version, while the TTL value ensures the time validity of the cached data. The cached data is considered valid only when the cached data is equal to the data instance version number of the database and the TTL value is within the validity period. In this way, the consistency of the data is guaranteed and the problem of cached data occupying resources for a long time without being updated is avoided.

[0065] When the TTL value of the cached data is still within the validity period, it means that the cached data has not expired. However, in this application, the mechanism that determines the validity of the cached data is not just the TTL value (there are also the instance version number and TTL value of the cached data, the data instance version number instance-id of the cache database and the timestamp last-flush and the window time limit flush-over-time). Therefore, the cached data cannot be judged to be valid only from the fact that the TTL value has not expired.

[0066] Although the TTL value is still valid, the difference between the data instance version number of the cached data and the database does not directly determine whether the cached data will be invalidated immediately during the batch invalidation process. It only indicates that the synchronization status between the cached data and the database needs to be checked and updated. At this time, further check whether the remaining time t2 of the batch invalidation phase is less than the effective time cutoff point t1 of the cached data during the batch invalidation process. If so, the cached data has been invalidated. Otherwise, the data is still valid.

[0067] In one embodiment, the TTL value of the cached data is the system timestamp when the data is stored in the cache database plus a random value, and the range of the random value is [0, flush-over-time), so that the TTL value distribution of each cached data is basically uniform.

[0068] The cached TTL is saved in the form of a timestamp (this is a typical implementation method). A random jitter value can be added to the timestamp as needed, that is, the final cached TTL timestamp is the time when the cache is introduced, plus a random value. The range of the random value is: [0, flush-over-time)

[0069] In the absence of random jitter, if a large amount of cache data is introduced at the same time and their TTL values ​​are the same or similar, then they are likely to expire at the same time or a similar time. This will cause the system to face a large number of cache invalidation operations at the same time, which may impact system performance. By adding random values ​​to the TTL value, the expiration time of these cache data can be dispersed, reducing system pressure.

[0070] Since cache expiration times are dispersed, the system's burden of handling cache invalidation requests will also be smoother. This helps avoid sudden surges and drops in system resources and improves system stability and predictability.

[0071] It is worth noting that the jitter value is not a must-set value, because its purpose is to ensure that the TTL values ​​of each cache record are evenly distributed to avoid a concentrated situation. In fact, during the operation of the recursive server, the time when the request is actually generated and the corresponding time when it is introduced into the cache can also be regarded as a random feature, so you can also choose not to set it.

[0072] In one embodiment, when the cache database space is limited and new data needs to be added, the invalid data is overwritten accordingly according to the instance version number of the cache data.

[0073] When the cache database has limited space and needs to add new data, it can determine which data items should be replaced by checking the version numbers of existing data items. In this way, even if the cache database has limited space, it can ensure that the latest data items are added, and the instance version number can be used to determine which data items can be safely replaced or overwritten to keep the data in the cache as close to the real state as possible.

[0074] In one embodiment, the method of correspondingly overwriting the invalid data according to the instance version number of the cached data is to use the LRU algorithm to select the data item that has not been accessed for the longest time for replacement.

[0075] Under the premise of ensuring that the global cache clearing effect is achieved, the performance side effects brought by this operation can be reduced. In addition, although the invalid cache does not cause real resource recycling when it fails, it can still use resource replacement methods (such as LRU) to achieve subsequent on-demand recycling to ensure that there are no problems in resource management.

[0076] In the DNS cache, the "overwrite" of data items is usually achieved through cache management strategies, such as the LRU (Least Recently Used) strategy. In this case, when the cache space is limited and new data needs to be added, the LRU algorithm will select the data item that has not been accessed for the longest time for replacement. If this data item happens to be old data that has been marked as "invalid", it will be naturally replaced by the new data, although it is not immediately deleted from the cache when it is marked as invalid.

[0077] In one embodiment, Figure 2 As shown, a DNS cache resource management system based on TTL value grouping is provided, including the following program modules: a field adding module and a cache data clearing module, wherein:

[0078] A field update module is used to update the pre-defined last-flush field and instance-id field in the cache database when receiving a global cache clearing operation instruction; the cache database enters a phase of data batch expiration until a pre-set global clearing window time limit is reached, and the window time limit is recorded as flush-over-time; the data structure corresponding to each cache data in the cache database includes a respective TTL field and an instance version number field, wherein the instance version number of the cache data corresponds to the data instance version number of the cache database when it is added;

[0079] The cache data clearing module is used to, in the batch expiration phase, when responding to a DNS query request and finding relevant cache data in the cache database, perform logical judgment based on the instance version number and TTL value of the cache data, the data instance version number instance-id and the timestamp last-flush of the cache database, and the window time limit flush-over-time to determine whether the cache data is invalid; if it is determined to be invalid data, ignore the cache data, trigger a recursive query, return the data obtained by the recursive query to the requester and store it in the cache database; and, after the batch expiration phase ends, when responding to a DNS query request and finding relevant cache data in the cache database, only determine whether the instance version number of the cache data is less than the data instance version number of the cache database. If it is less, the cache data is considered to be invalid, trigger a recursive query, return the data obtained by the recursive query to the requester and store it in the cache database.

[0080] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. The processor of the computer device is used to provide computing and control capabilities, and the network interface is used to communicate with an external terminal through a network connection. The computer device loads and runs a computer program to implement the above-mentioned DNS cache resource management method based on TTL value grouping.

[0081] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0082] In one embodiment, a computer program product is also provided, including a computer program / instruction, which implements the steps of the above-mentioned embodiment method when executed by a processor.

[0083] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

Claims

1. A DNS cache resource management method based on TTL value grouping, characterized in that: include: When receiving a global cache clearing operation instruction, the last-flush field and instance-id field pre-defined in the cache database are updated; the last-flush field indicates the timestamp of the last global cache clearing operation, which is used to record the starting time of the last global cache clearing operation. The last-flush field is updated to the current system timestamp; the instance-id field is the data instance version number of the cache database, with an initial value of 0, and each update increases by 1 on the original basis; The cache database enters the stage of batch data expiration until the pre-set global clearing window time limit is reached, and the window time limit is recorded as flush-over-time; the data structure corresponding to each cache data in the cache database includes its own TTL field and instance version number field, wherein the instance version number of the cache data corresponds to the data instance version number of the cache database when it is added; In the batch expiration phase, when responding to a DNS query request and finding relevant cached data in the cache database, a logical judgment is made based on the instance version number and TTL value of the cached data, the instance version number instance-id of the cache database, the timestamp last-flush, and the window time limit flush-over-time to determine whether the cached data is invalid; if it is determined to be invalid data, the cached data is ignored, a recursive query is triggered, and the data obtained by the recursive query is returned to the requester and stored in the cache database; After the batch expiration phase ends, when responding to a DNS query request and finding relevant cached data in the cache database, it is only determined whether the instance version number of the cached data is less than the data instance version number of the cache database. If so, the cached data is considered invalid, triggering a recursive query, and returning the data obtained from the recursive query to the requester and storing it in the cache database.

2. The DNS cache resource management method based on TTL value grouping according to claim 1 is characterized in that: The logical judgment is performed based on the instance version number of the cache data, the data instance version number of the cache database, the last-flush field in the cache database, and the window time limit flush-over-time to determine whether the cache data is invalid, specifically including: Check the instance version number of the cached data. If it is equal to the instance-id of the cache database, the cached data is considered to be the latest data. Whether it has been cleared is not considered. Only whether the TTL of the cached data is within the validity period is determined. Check the TTL value of the cached data. If the TTL value is found to have expired, the cached data will be ignored, a recursive query will be triggered, and the data obtained by the recursive query will be returned to the requester and stored in the cache database. If the TTL of the cached data is still valid and the instance version number of the cached data is less than the instance-id of the cache database, further determine whether the data has been invalidated during the batch invalidation process. The determination method is that if the remaining time t2 of the data batch invalidation phase is less than the effective cutoff point t1 of the cached data in the batch invalidation phase, the corresponding t1 has been invalidated, that is, the cached data is invalid, and the recursive process should continue to be triggered. Otherwise, it means that the cached data is still available. Among them, t1 is obtained by taking the modulo of the TTL value of the cached data and the flush-over-time value, and the calculation formula of t2 is t2=flush-over-time-(n-last-flush) n represents the timestamp of the current time.

3. The DNS cache resource management method based on TTL value grouping according to claim 1 is characterized in that: The TTL value of the cached data is the system timestamp when the data is stored in the cache database plus a random value, and the range of the random value is [0, flush-over-time), so that the TTL value distribution of each cached data is basically uniform.

4. The DNS cache resource management method based on TTL value grouping according to claim 1, characterized in that: When the cache database space is limited and new data needs to be added, the invalid data is overwritten accordingly based on the instance version number of the cached data.

5. The DNS cache resource management method based on TTL value grouping according to claim 4 is characterized in that: The method of correspondingly overwriting the invalid data according to the instance version number of the cached data is to use the LRU algorithm to select the data item that has not been accessed for the longest time for replacement.

6. A DNS cache resource management system based on TTL value grouping, characterized in that: include: A field update module is used to update the pre-defined last-flush field and instance-id field in the cache database when receiving a global cache clearing operation instruction; the cache database enters a phase of data batch expiration until a pre-set global clearing window time limit is reached, and the window time limit is recorded as flush-over-time; the data structure corresponding to each cache data in the cache database includes a respective TTL field and an instance version number field, wherein the instance version number of the cache data corresponds to the data instance version number of the cache database when it is added; The cache data clearing module is used to determine whether the cache data is invalid according to the instance version number and TTL value of the cache data, the data instance version number instance-id and the timestamp last-flush of the cache database, and the window time limit flush-over-time when responding to the DNS query request and finding the relevant cache data in the cache database during the batch invalidation stage; if it is determined to be invalid data, the cache data is ignored, a recursive query is triggered, and the data obtained by the recursive query is returned to the requester and stored in the cache database; Also, after the batch expiration phase ends, when responding to a DNS query request and finding relevant cached data in the cache database, it is only determined whether the instance version number of the cached data is less than the data instance version number of the cache database. If so, the cached data is considered to be invalid, triggering a recursive query, and returning the data obtained from the recursive query to the requester and storing it in the cache database.

7. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to claim 1.

8. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.

Citation Information

Patent Citations

  • Cache clearing method, device and system

    CN111611510A

  • Cache file management method and device and server

    CN114301985A

  • Cache management method and device, equipment and storage medium

    CN115964391A

  • Cache data updating method and device, storage medium and electronic device

    CN117743348A

  • System and method for broadcast cache invalidation

    US20190102297A1