June 6, 2015

Linux ARP Cache

Recently I found very interesting question asked on stackoverflow.com as mentioned here. User was using host aliases to simulate local clients to load test his server, however he was hitting limit of 1023 devices and client timing out

Upon further investigation, I found the issue to be due to ARP cache getting full
Detailed information about ARP tunables could be found in man pages arp(7)
       gc_thresh1 (since Linux 2.2)
              The  minimum  number of entries to keep in the ARP cache.  The garbage collector will not run if there are fewer than
              this number of entries in the cache.  Defaults to 128.

       gc_thresh2 (since Linux 2.2)
              The soft maximum number of entries to keep in the ARP cache.  The garbage collector will allow the number of  entries
              to exceed this for 5 seconds before collection will be performed.  Defaults to 512.

       gc_thresh3 (since Linux 2.2)
              The hard maximum number of entries to keep in the ARP cache.  The garbage collector will always run if there are more
              than this number of entries in the cache.  Defaults to 1024.

As seen above default maximum for gc_thresh3 is 1024. When ARP table reaches 1024 - no more entries could be added, until garbage collector was able to cleanup some stale ARP entries. Simple fix was to bump-up default values, to suit the need