App makes frequent requests to the same domain name of some service.
There are front end requests served by PHP-FPM and there are cron jobs launching multiple PHP command line processes. Almost every time requests to an URL under that domain are performed. Code utilizes Amazon php-sdk which uses cURL for web requests afaik.
How are repeated DNS queries cached (if they are)?
I understand that a single php-fpm worker process is used to process N requests and then is respawned. Is DNS cache shared between multiple php-fpm workers?
Servers runs on CentOS and on Debian. I learned that there is no OS DNS cache by default. Does it make sense to install some OS-wise DNS cache package to cache a single request?
IP address of the service might infrequently change, so hardcoding the ip in /etc/hosts is probably not a good idea.
I don't know how your CentOS and on Debian is configured to handle DNS caching, generally all operating systems are reading the time to refresh the DNS cache from your domain SOA records.
Here is how you can check any domain SOA value: https://mxtoolbox.com/SOALookup.aspx
Here is the situation with PHP cURL:
DNS cache is implemented on cURL on Jan 2002. Read more about it here:
https://curl.haxx.se/mail/lib-2002-01/0076.html
You can turn DNS cache for cURL ON or OFF with
CURLOPT_DNS_USE_GLOBAL_CACHE
TRUE to use a global DNS cache. This option is not thread-safe and is enabled by default.
Read more on curl options here:
http://php.net/manual/en/function.curl-setopt.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With