DNS Caching on Amazon AMIs

Recently encountered an issue with Elastic beanstalk where the application started giving error like "host not found or unreachable" while connecting to Redis cluster. First I thought it might be related to AWS scheduled maintenance but it was not started yet. On investigating further, the tested that the Redis cluster was live and was connecting from other instances.

On google, there was not much help available except one on amazon forum that amazon does restricts DNS requests after some limit and by default no DNS caching service is installed in Amazon AMIs.

After installing nscd, the issue was solved. I used the following .ebextensions/install-nscd.config to always install nscd and keep it running on any new instance added to the scaling group.

# these commands run before the application and web server are
# set up and the application version file is extracted.
packages:
  yum:
    nscd: []

services: 
  sysvinit:
    nscd:
      enabled: true
      ensureRunning: true

Lesson learnt, always install DNS caching service on amazon AMIs.