Support > About cloud server > How to optimize DNS caching on Singapore VPS cloud servers
How to optimize DNS caching on Singapore VPS cloud servers
Time : 2025-11-06 13:38:31
Edit : Jtti

In Singapore VPS operations, DNS lookup latency often impacts service response speed. When users access a website, domain name resolution involves a complex query process, which not only slows down page loading but also directly affects search engine rankings and user experience. Through proper DNS caching optimization, query time can be reduced from hundreds of milliseconds to single digits.

The core value of DNS caching is to temporarily store the most recent domain name resolution results locally, avoiding duplicate queries. Without caching, each domain name request requires a query to an external DNS server, a process that typically takes 50-200 milliseconds. With local caching enabled, the same query can be completed in just 0.1-1 milliseconds within the cache's validity period, improving efficiency by hundreds of times. For a mid-sized website with 100,000 queries per day, this can save users several hours of waiting time daily.

Choosing the Right DNS Caching Solution

Choosing the right caching software based on business scale is crucial. For lightweight applications, systemd-resolved is an ideal choice. As a component of systemd, it consumes minimal resources and requires no additional configuration. To enable systemd-resolved, simply execute `systemctl enable systemd-resolved` and `systemctl start systemd-resolved`. Then, modify the DNS parameters in the `/etc/systemd/resolved.conf` file to point to a reliable public DNS service.

For scenarios requiring greater customization, dnsmasq offers more flexible configuration options. After installation, edit the `/etc/dnsmasq.conf` configuration file, setting `cache-size=1000` to increase the cache entry capacity, and configuring `server=8.8.8.8` and `server=1.1.1.1` to specify the upstream DNS server. After restarting the service, your Singapore VPS will have full DNS caching capabilities.

For large-scale application environments, consider professional solutions like BIND or Unbound. Unbound is known for its excellent security and caching efficiency. By adjusting the `num-threads` and `msg-cache-size` parameters, it can easily handle high-concurrency query scenarios.

The cache size directly determines the number of DNS records that can be stored. For businesses handling millions of queries daily, it's recommended to set the cache size to at least 10,000 records. A reasonable minimum TTL (Time To Live) value can balance caching effectiveness with data update needs; a value of 300 seconds or more is generally recommended.

For Singapore VPSs with ample memory resources, consider enabling prefetching. When a cached record is about to expire, the system automatically updates it in advance, ensuring users always receive a fast parsing response. In Unbound, simply set `prefetch: yes` and `prefetch-key: yes` to enable this feature.

Establishing an effective monitoring mechanism is crucial for ensuring the stable operation of the caching service. Use `rndc stats` or `unbound-control stats` to view key metrics such as cache hit rate, query count, and response time in real time. Ideally, the cache hit rate should be maintained above 80%. If it falls below this value, you may need to consider adjusting the caching strategy or checking configuration parameters.

Regularly cleaning up expired records is equally important. While most DNS caching software automatically handles expired entries, in special cases (such as when a domain migration requires immediate effect), you can manually execute `rndc flush` or `systemctl restart dnsmasq` to force a cache refresh.

Cache pollution is one of the most common problems in DNS caching. Attackers hijack domain name resolution by injecting forged DNS responses. Enabling DNSSEC verification can effectively prevent such attacks; this can be enabled by adding the `auto-trust-anchor-file:` option to the configuration file.

Another common problem is excessive memory usage. By setting a reasonable maximum cache size and regularly monitoring memory usage, you can avoid system performance degradation caused by cache bloat. When memory usage exceeds a set threshold, the system will automatically clean up the oldest cached records.

After optimization, using the `dig` command to compare query times before and after optimization provides a clear view of the effect. Without caching, the first query may take more than 100 milliseconds, while the same query with caching enabled typically takes only 1-5 milliseconds. Continuously monitoring the average query latency and cache hit rate over a week can help further fine-tune parameters to achieve optimal performance.

DNS caching optimization is one of the simplest and most effective ways to improve the performance of a Singapore VPS. By choosing the right caching scheme, optimizing key parameters, and establishing a continuous monitoring mechanism, you can provide users with a faster access experience while reducing your reliance on external DNS services.

Relevant contents

Learn how to deploy a Docker container environment on a cloud server Hong Kong VPS Website Building Tutorial: How to Quickly Deploy a WordPress Website Six Key Parameters for Beginners Choosing a Hong Kong VPS Is your US VPS too slow? Here are 7 practical tips to improve your access performance. Why can't I open the BT Panel after installing it on my Singapore VPS cloud server? What is the relationship between virtualization and cloud computing? 2025 Overseas VPS Security Risk Ranking: From Cloud Configuration Misconfigurations to New AI Attacks What are the security reinforcement architectures for Japanese cloud servers IIS? How to choose a VPS server suitable for overseas users? A tutorial on optimizing memory and CPU for US cloud servers
Go back

24/7/365 support.We work when you work

Support