Microsoft Azure

MongoDB on Azure brings the power of the leading next-generation database to Microsoft’s flexible, open, and scalable cloud.

Microsoft Azure is an open and flexible cloud platform that enables you to quickly build, deploy, and manage applications across a global network of Microsoft-managed datacenters. You can build applications using any language, tool, or framework. You can also integrate your public cloud applications with your existing IT environment.

Together, MongoDB and Azure provide customers the tools to build limitlessly scalable applications in the cloud.

Users interested in deploying MongoDB directly on Azure can do so using Azure VM (Azure Infrastructure-as-a-Service) on Linux or Windows, or Azure Worker Roles (Azure Platform-as-a-Service) on Windows.

Deployment Recommendations

For all MMAPv1 MongoDB deployments using Azure, you must mount volume that hosts the mongod instance’s dbPath with the Host Cache Preference READ/WRITE.

This applies to all Azure deployments, using any guest operating system.

If your volumes have inappropriate cache settings, MongoDB may eventually shut down with the following error:

[DataFileSync] FlushViewOfFile for <data file> failed with error 1 ...
[DataFileSync] Fatal Assertion 16387

These shut downs do not produce data loss if when storage.journal.enabled is set to true. You can safely restart mongod at any time following this event.

The performance characteristics of MongoDB may change with READ/WRITE caching enabled.

The TCP keepalive on the Azure load balancer is 240 seconds by default, which can cause it to silently drop connections if the TCP keepalive on your Azure systems is greater than this value. You should set tcp_keepalive_time to 120 to ameliorate this problem.

On Linux systems:

  • To view the keep alive setting, you can use one of the following commands:

    sysctl net.ipv4.tcp_keepalive_time


    cat /proc/sys/net/ipv4/tcp_keepalive_time

    The value is measured in seconds.

  • To change the tcp_keepalive_time value, you can use one of the following command:

    sudo sysctl -w net.ipv4.tcp_keepalive_time=<value>


    echo <value> | sudo tee /proc/sys/net/ipv4/tcp_keepalive_time

    These operations do not persist across system reboots. To persist the setting, add the following line to /etc/sysctl.conf:

    net.ipv4.tcp_keepalive_time = <value>

    On Linux, mongod and mongos processes limit the keepalive to a maximum of 300 seconds (5 minutes) on their own sockets by overriding keepalive values greater than 5 minutes.

For Windows systems:

  • To view the keep alive setting, issue the following command:

    reg query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v KeepAliveTime

    The registry value is not present by default. The system default, used if the value is absent, is 7200000 milliseconds or 0x6ddd00 in hexadecimal.

  • To change the KeepAliveTime value, use the following command in an Administrator Command Prompt, where <value> is expressed in hexadecimal (e.g. 0x0124c0 is 120000):

    reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ /v KeepAliveTime /d <value>

    Windows users should consider the Windows Server Technet Article on KeepAliveTime for more information on setting keep alive for MongoDB deployments on Windows systems.


Users deploying MongoDB on Azure may be interested in the following presentations: