Dns dynamic adjustment method, network architecture, computer device and storage medium
By dynamically adjusting the number of packet receiving and processing threads of the DNS server, and combining the use of lock-free queues and lock queues, the problem of low processing efficiency of DNS service under high load is solved, and efficient DNS request processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING YAXIN INTELLIGENT NETWORK TECH CO LTD
- Filing Date
- 2023-08-09
- Publication Date
- 2026-04-21
AI Technical Summary
Existing DNS services cannot dynamically adjust under high load, resulting in low processing efficiency and difficulty in meeting the application requirements of high concurrency processing.
By periodically obtaining the actual load of the DNS server, the number of packet receiving threads and processing threads are dynamically adjusted. Based on the load and the number of CPU cores, the processing requirements are matched, and either lock-free queues or lock queues are selected for DNS request processing. The use of lock-free queues and lock queues is combined to improve efficiency.
It improves network processing efficiency in high-concurrency scenarios, while balancing performance and data processing accuracy, and adapts to different application scenarios.
Smart Images

Figure CN117041208B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer network technology, and in particular to a DNS dynamic adjustment method, network architecture, computer equipment, and storage medium. Background Technology
[0002] In IP (Internet Protocol) networks, DNS (Domain Name System) is one of the most critical foundational services of the Internet, providing fundamental support for numerous network applications. Its main function is to translate easily remembered domain names into recognizable IP addresses. This conversion between domain names and IP addresses is called domain name resolution, and the network host that performs domain name resolution is called a DNS server. Through the query service of a DNS server, the entry point to the desired website or resource can be found, allowing access to that website or resource.
[0003] With the rapid development and expansion of the Internet, the load and concurrent access volume of DNS services are also increasing. How to achieve efficient DNS services has become an important area of research and practice.
[0004] Because DNS uses a high-speed cache, it typically processes packets very quickly, so its network framework differs from that of general network applications. Traditional DNS services usually employ multi-threading or asynchronous event processing for packet reception and processing to improve network efficiency. However, this approach has some drawbacks. Under high load, this method can lead to performance bottlenecks, such as excessive system resource consumption due to too many threads and complex inter-thread communication. Therefore, in practical applications, optimization is usually required based on specific circumstances to adapt to different physical resources and achieve optimal performance. For example:
[0005] 1) When dealing with high concurrency scenarios or situations where there are bottlenecks, increase the number of processing threads and use lock-free queues to reduce contention between threads.
[0006] 2) When there is a bottleneck in packet reception and the processing thread is idle, add more packet reception threads and use a locked queue to control the synchronization and competition between threads to ensure data consistency and reliability.
[0007] 3) When system resources are insufficient, the receiving thread can be used to process the packets directly or a single thread can be used for asynchronous calls to avoid unnecessary threads and communication between threads, thereby saving system resources and improving system performance and efficiency.
[0008] However, existing DNS systems cannot dynamically adjust, which affects the efficiency of DNS request processing and makes it difficult to meet the needs of high-concurrency applications. Summary of the Invention
[0009] In view of the shortcomings of the prior art described above, the purpose of this invention is to provide a DNS dynamic adjustment method, network architecture, computer equipment and storage medium to solve the technical problem of low processing efficiency of DNS requests in the prior art.
[0010] To achieve the above and other related objectives, the present invention provides the following technical solution:
[0011] A method for dynamic DNS tuning, comprising:
[0012] The actual load of the DNS server is obtained according to a preset processing cycle. The actual load of the DNS server includes: CPU load, network load, and packet processing load.
[0013] The number of packet receiving threads and processing threads are dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing requirements.
[0014] The system compares the dynamically adjusted number of packet receiving threads and the number of processing threads in real time, and selects between lock-free queues and lock queues according to a predetermined strategy based on the comparison results to process DNS requests.
[0015] As a preferred embodiment of the invention, when obtaining the actual load of the DNS server, the number of CPU cores, the current number of packet receiving threads and processing threads, and the data queue idle status are also obtained simultaneously; when making dynamic adjustments, the number of packet receiving threads is determined based on the CPU utilization rate of the packet receiving threads, and the number of processing threads is determined based on the CPU utilization rate of the processing threads.
[0016] As a preferred embodiment of the invention, the step of dynamically adjusting the number of packet receiving threads and the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match processing needs specifically includes:
[0017] It concurrently receives DNS requests from clients and dynamically adjusts the number of packet receiving threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs.
[0018] The system concurrently processes DNS requests in the data pairs column, dynamically adjusting the number of processing threads based on the actual load of the DNS server and the number of CPU cores to match processing needs.
[0019] As a preferred embodiment of the invention, the step of selecting between a lock-free queue or a lock-based queue method for DNS request processing according to a predetermined strategy based on the comparison results specifically includes:
[0020] When the number of receiving threads is less than the number of processing threads, a lock-free queue method is used to process DNS requests.
[0021] When the number of receiving threads exceeds the number of processing threads, a locked queue method is used to process DNS requests.
[0022] As a preferred embodiment of the invention, the step of selecting either a lock-free queue or a locked queue method for DNS request processing according to a predetermined strategy based on the comparison result further includes:
[0023] When physical resources are insufficient, DNS requests are processed directly by the packet receiving thread.
[0024] To address the aforementioned technical problems, the present invention also provides a dynamically adjustable network architecture, comprising:
[0025] A state collector is used to obtain the actual load status of the DNS server according to a preset processing cycle. The actual load status of the DNS server includes: CPU load, network load, and packet processing load.
[0026] The dynamic adjuster is used to dynamically adjust the number of packet receiving threads and the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs. It also compares the dynamically adjusted number of packet receiving threads and the number of processing threads in real time, and selects whether to use a lock-free queue or a lock queue to process DNS requests according to a predetermined strategy based on the comparison results.
[0027] As a preferred embodiment of the invention, the dynamic regulator is connected to a packet receiving thread pool and a processing thread pool;
[0028] The packet receiving thread pool is used to concurrently receive DNS requests from clients, and the number of packet receiving threads is dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing needs.
[0029] The processing thread pool is used to concurrently process DNS requests in the data pair column, and the number of processing threads is dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing needs.
[0030] As a preferred embodiment of the invention, the step of selecting between a lock-free queue or a lock-based queue method for DNS request processing according to a predetermined strategy based on the comparison results specifically includes:
[0031] When the number of receiving threads is less than the number of processing threads, a lock-free queue method is used to process DNS requests.
[0032] When the number of receiving threads exceeds the number of processing threads, a locked queue method is used to process DNS requests.
[0033] When physical resources are insufficient, DNS requests are processed directly by the packet receiving thread.
[0034] To address the aforementioned technical problems, the present invention also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor performs the steps of the DNS dynamic adjustment method described in any of the above technical solutions.
[0035] To address the aforementioned technical problems, the present invention also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the DNS dynamic adjustment method as described in any one of claims 1 to 5.
[0036] As described above, the DNS dynamic adjustment method, network architecture, computer equipment, and storage medium of the present invention have the following advantages:
[0037] Beneficial effects:
[0038] This invention provides a dynamic DNS adjustment method, comprising: acquiring the actual load of a DNS server according to a preset processing cycle, wherein the actual load of the DNS server includes CPU load, network load, and packet processing load; dynamically adjusting the number of packet receiving threads and processing threads according to the actual load of the DNS server and the number of CPU cores to match processing needs; comparing the dynamically adjusted number of packet receiving threads and processing threads in real time, and selecting either a lock-free queue or a locked queue method for DNS request processing according to a predetermined strategy based on the comparison result. By periodically acquiring the actual load of the DNS server and adaptively and dynamically adjusting the number of packet receiving threads and processing threads, network processing efficiency is improved. The combination of lock-free and locked queues balances performance and data processing correctness, meeting the application requirements of high-concurrency processing. Furthermore, it allows for customized development and deployment according to actual needs, thus adapting to different application scenarios. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 The diagram shows the basic flowchart of the DNS dynamic adjustment method in an embodiment of the present invention.
[0041] Figure 2 The diagram shows the processing flow architecture when the number of receiving threads is less than the number of processing threads in an embodiment of the present invention.
[0042] Figure 3 The diagram shows the processing flow architecture when the number of receiving threads is greater than the number of processing threads in an embodiment of the present invention.
[0043] Figure 4 This diagram illustrates the processing flow architecture when physical resources are insufficient, as shown in an embodiment of the present invention.
[0044] Figure 5 The diagram shown is a basic structural schematic of the DNS dynamic adjustment network architecture in an embodiment of the present invention.
[0045] Figure 6 The diagram shown is a basic structural block diagram of a computer device in an embodiment of the present invention. Detailed Implementation
[0046] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0047] In some of the processes described in the specification, claims, and accompanying drawings of this invention, multiple operations appearing in a specific order are included. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] Please see Figure 1 This invention provides a method for dynamic DNS adjustment, comprising:
[0050] S100. Obtain the actual load of the DNS server according to the preset processing cycle. The actual load of the DNS server includes: CPU load, network load and message processing load.
[0051] When obtaining the actual load of the DNS server, the system also obtains the number of CPU cores, the current number of packet receiving threads and processing threads, and the idle status of the data queue.
[0052] S200. Dynamically adjust the number of packet receiving threads and the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match the processing requirements.
[0053] Specifically, the S200 includes:
[0054] S201. Concurrently receive DNS requests from clients, and dynamically adjust the number of packet receiving threads according to the actual load of the DNS server and the number of CPU cores to match the processing requirements, so as to adapt to different load conditions.
[0055] S202. Concurrently process DNS requests in the data pair column, and dynamically adjust the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs, so as to adapt to different load conditions.
[0056] When making dynamic adjustments, the number of receiving threads is determined based on the CPU utilization rate of the receiving threads, and the number of processing threads is determined based on the CPU utilization rate of the processing threads.
[0057] In this embodiment, the rules for dynamic adjustment are as follows:
[0058] Assume the number of packet receiving threads is n, the number of processing threads is m, the number of processing queues corresponding to each packet receiving thread is x, the number of extra queues is r, and the thread number is i; when the process is initialized, n = 2, m = number of CPU cores / 2, and when dynamic adjustment occurs:
[0059] n = n + (CPU utilization of packet receiving thread > 50%? 1 : -1), (n > 0);
[0060] m = m + (processing thread CPU utilization > 50%? 1 : -1), (m > 0 && m <= number of CPU cores);
[0061] x = n / m;
[0062] r = n%m;
[0063] x(i) = x + (i ≤ r? 1: 0).
[0064] That is, when making dynamic adjustments, if the CPU utilization rate of the receiving thread is >50%, then n = n + 1, otherwise n = n - 1; if the CPU utilization rate of the processing thread is >50%, then m = m + 1, otherwise m = m - 1; r is the remainder after dividing n by m; when i ≤ r, x(i) = x + 1, otherwise x(i) = x.
[0065] S300 compares the dynamically adjusted number of packet receiving threads and the number of processing threads in real time, and selects either a lock-free queue or a locked queue method to process DNS requests according to a predetermined strategy based on the comparison result.
[0066] Specifically, the selection of either a lock-free queue or a locked queue approach for DNS request processing based on the comparison results and a predetermined strategy includes:
[0067] When the number of receiving threads is less than the number of processing threads, a lock-free queue approach is used for DNS request processing to meet the needs of high-concurrency processing or scenarios where processing bottlenecks exist. The processing flow architecture diagram is as follows: Figure 2 As shown;
[0068] When the number of receiving threads exceeds the number of processing threads, a locked queue approach is used for DNS request processing to meet the needs of scenarios with rapid processing and bottlenecks in packet receiving. The processing flow architecture diagram is as follows: Figure 3 As shown;
[0069] When physical resources are insufficient, DNS requests are processed directly by the packet receiving thread to save system resources. The processing architecture diagram is as follows. Figure 4 As shown.
[0070] This invention improves network processing efficiency by periodically acquiring the actual load of the DNS server and adaptively and dynamically adjusting the number of packet receiving threads and processing threads. It also employs a combination of lock-free and lock-based queues to balance performance and data processing accuracy, meeting the application requirements of high-concurrency processing. Furthermore, it can be customized and deployed according to actual needs to adapt to different application scenarios.
[0071] To solve the above technical problems, such as Figure 4 As shown, the present invention also provides a DNS dynamic adjustment network architecture, including: a state collector, used to obtain the actual load of the DNS server according to a preset processing cycle, wherein the actual load of the DNS server includes: CPU load, network load and packet processing load; and a dynamic adjuster, used to dynamically adjust the number of packet receiving threads and the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match the processing requirements, and compare the dynamically adjusted number of packet receiving threads and the number of processing threads in real time, and select the lock-free queue or the lock queue method for DNS request processing according to a predetermined strategy based on the comparison result.
[0072] Specifically, the dynamic regulator is connected to a packet receiving thread pool and a processing thread pool. The packet receiving thread pool is used to concurrently receive DNS requests from clients, and dynamically adjusts the number of packet receiving threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs. The processing thread pool is used to concurrently process DNS requests in the data pair queue, and dynamically adjusts the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs.
[0073] When the dynamic regulator performs dynamic adjustments, it selects between lock-free queuing and lock-locked queuing methods for DNS request processing according to a predetermined strategy based on the comparison results. Specifically, this includes:
[0074] When the number of receiving threads is less than the number of processing threads, a lock-free queue is used to process DNS requests to meet the needs of high-concurrency processing or scenarios where there is a bottleneck in processing.
[0075] When the number of receiving threads exceeds the number of processing threads, a locked queue method is used to process DNS requests to meet the needs of scenarios where processing is fast and there is a bottleneck in receiving packets.
[0076] When physical resources are insufficient, DNS requests are processed directly by the packet receiving thread to save system resources.
[0077] The DNS dynamic adjustment network architecture improves network processing efficiency by periodically obtaining the actual load of the DNS server during DNS request processing and adaptively adjusting the number of packet receiving threads and processing threads. It also adopts a combination of lock-free queues and lock queues to balance performance and data processing correctness, meeting the application requirements of high-concurrency processing. Furthermore, it can be customized and deployed according to actual needs to adapt to different application scenarios.
[0078] To address the aforementioned technical problems, embodiments of the present invention also provide a computer device. Please refer to the following for details. Figure 6 , Figure 6 This is a basic structural block diagram of the computer device in this embodiment.
[0079] like Figure 6The diagram shows the internal structure of a computer device. This computer device includes a processor, non-volatile storage medium, memory, and a network interface connected via a system bus. The non-volatile storage medium stores the operating system, a database, and computer-readable instructions. The database may store control information sequences. When the computer-readable instructions are executed by the processor, they enable the processor to implement a dynamic DNS adjustment method. The processor provides computing and control capabilities, supporting the operation of the entire computer device. The memory stores computer-readable instructions, which, when executed by the processor, enable the processor to implement a dynamic DNS adjustment method. The network interface of the computer device is used for communication with terminals. Those skilled in the art will understand that… Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0080] In this embodiment, the processor is used to execute... Figure 5 The system includes a state collector, a dynamic regulator, a packet receiving thread pool, and a processing thread pool, each with its own specific functions. The memory stores the program code and various data required to execute these modules. The network interface is used for data transmission between user terminals or servers.
[0081] When computer devices process DNS requests, they can periodically obtain the actual load of the DNS server and adaptively and dynamically adjust the number of packet receiving threads and processing threads to improve network processing efficiency. They also use a combination of lock-free queues and lock queues to balance performance and data processing correctness, meeting the application requirements of high-concurrency processing. Furthermore, they can be customized and deployed according to actual needs to adapt to different application scenarios.
[0082] The present invention also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the DNS dynamic adjustment method of any of the above embodiments.
[0083] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0084] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
Claims
1. A method for dynamic DNS adjustment, characterized in that, include: The actual load of the DNS server is obtained according to a preset processing cycle. The actual load of the DNS server includes: CPU load, network load, and packet processing load. The number of packet receiving threads and processing threads are dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing requirements. The system compares the dynamically adjusted number of packet receiving threads and the number of processing threads in real time, and selects between lock-free queues and lock queues according to a predetermined strategy based on the comparison results to process DNS requests.
2. The DNS dynamic adjustment method according to claim 1, characterized in that, When obtaining the actual load of the DNS server, the number of CPU cores, the current number of packet receiving threads and processing threads, and the data queue idle status are also obtained simultaneously. When making dynamic adjustments, the number of packet receiving threads is determined based on the CPU utilization rate of the packet receiving threads, and the number of processing threads is determined based on the CPU utilization rate of the processing threads.
3. The DNS dynamic adjustment method according to claim 1, characterized in that, The specific steps of dynamically adjusting the number of packet receiving threads and processing threads based on the actual load of the DNS server and the number of CPU cores to match processing needs include: It concurrently receives DNS requests from clients and dynamically adjusts the number of packet receiving threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs. The DNS requests in the data queue are processed concurrently, and the number of processing threads is dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing needs.
4. The DNS dynamic adjustment method according to claim 1, characterized in that, The step of selecting between a lock-free queue or a locked queue approach for DNS request processing according to a predetermined strategy based on the comparison results specifically includes: When the number of receiving threads is less than the number of processing threads, a lock-free queue method is used to process DNS requests. When the number of receiving threads exceeds the number of processing threads, a locked queue method is used to process DNS requests.
5. The DNS dynamic adjustment method according to claim 1, characterized in that, The step of selecting between lock-free queues and lock-based queues for DNS request processing according to a predetermined strategy based on the comparison results also includes: When physical resources are insufficient, DNS requests are processed directly by the packet receiving thread.
6. A dynamically adjustable network architecture, characterized in that, include: A state collector is used to obtain the actual load status of the DNS server according to a preset processing cycle. The actual load status of the DNS server includes: CPU load, network load, and packet processing load. The dynamic adjuster is used to dynamically adjust the number of packet receiving threads and the number of processing threads according to the actual load of the DNS server and the number of CPU cores to match the processing needs. It also compares the dynamically adjusted number of packet receiving threads and the number of processing threads in real time, and selects whether to use a lock-free queue or a lock queue to process DNS requests according to a predetermined strategy based on the comparison results.
7. The dynamically adjustable network architecture according to claim 6, characterized in that, The dynamic regulator is connected to a packet receiving thread pool and a processing thread pool. The packet receiving thread pool is used to concurrently receive DNS requests from clients, and the number of packet receiving threads is dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing needs. The processing thread pool is used to concurrently process DNS requests in the data pair column, and the number of processing threads is dynamically adjusted according to the actual load of the DNS server and the number of CPU cores to match the processing needs.
8. The dynamically adjustable network architecture according to claim 6, characterized in that, The step of selecting between a lock-free queue or a locked queue approach for DNS request processing according to a predetermined strategy based on the comparison results specifically includes: When the number of receiving threads is less than the number of processing threads, a lock-free queue method is used to process DNS requests. When the number of receiving threads exceeds the number of processing threads, a locked queue method is used to process DNS requests. When physical resources are insufficient, DNS requests are processed directly by the packet receiving thread.
9. A computer device comprising a memory and a processor, the memory storing computer-readable instructions which, when executed by the processor, cause the processor to perform the steps of the DNS dynamic adjustment method as claimed in any one of claims 1 to 5.
10. A storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the DNS dynamic adjustment method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for adjusting thread pool, storage medium and computer equipment
CN108874550A
Dynamic adjustment method and device of pressure measurement thread, electronic equipment and storage medium
CN115576791A