timeout errors from Tomcat talking to MongoDB in Azure
This is due to high tcp_keepalive_time in your CentOS server.
In your MongoS server:sudo nano /proc/sys/net/ipv4/tcp_keepalive_timeChange 7200 to 60
Restart your Azure instance.
Update:In order to make sure your VM always has the value of tcp_keepalive_time:
Add this line:
bash -c 'echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time'
to:
/etc/rc.d/rc.local
Update to the update:For most flavors for Linux, there is a /etc/sysctl.d/
directory. Create a file, e.g. mongo.conf
containing:
net.ipv4.tcp_keepalive_time = 60
Put the file in that directory and run:
sysctl -p /etc/sysctl.d/mongo.conf
Verify the change with:
sysctl net.ipv4.tcp_keepalive_time
This will survive reboots in RedHat-based and Debian-based systems I've come across. You'll want to be sure and check /etc/sysctl.conf
and any other files in /etc/sysctl.d
to see if the variable is already being set to something else and make appropriate changes.