Home / Azure

AzureHow-toAdvanced

Tune NFS Azure Files on Linux: nconnect, read-ahead, metadata latency and provisioned limits

Find whether an NFS Azure file share is limited by provisioning, the client or metadata round trips, then tune nconnect, read-ahead and caching with measurements.

Deepak Bhardwaj7 min read

Applies toAzure Files NFSv4.1 on SSD (premium) shares, Linux clients with kernel 5.4 or later

An NFS share is provisioned for far more than your application gets, or it is fast in fio and slow when unpacking a source tree. Work through this in order: prove where the limit is, then change one setting at a time. NFS on Azure Files means NFSv4.1 on an SSD share, reached from a private or service endpoint on TCP 2049.

Step 1: classify the bottleneck

Symptom Likely limit Where to go
Utilization near 100%, server latency up Provisioned IOPS or throughput Step 2
Low utilization, one TCP connection busy Single connection Step 3
Sequential reads slow, writes fine Read-ahead Step 4
Many small files slow, throughput tiny Metadata round trips Step 5
E2E latency high, server latency low Client or network VM limits, zone placement
ls never returns on a huge directory Kernel bug Step 6

Take a client sample during the slow period:

nfsstat -m                       # negotiated options per mount
nfsiostat 5 3 /mnt/share         # RTT vs exe time per operation
mountstats --rpc /mnt/share      # per-RPC counts and latency
ss -tn '( dport = :2049 )'       # connections actually open
cat /proc/self/mountinfo | grep -i nfs

In nfsiostat, avg RTT is the time on the wire and at the server. avg exe also includes time queued in the client. A large gap points to the client, and more connections or concurrency tuning can help. If both are high, look at the server side.

With the AzNFS helper and TLS, traffic goes through a local proxy, so the mount shows 127.0.0.1 and you should also look at CPU used by stunnel.

Step 2: check the share's limits

SA=stnfsprod; RG=rg-files
FS_ID=$(az storage account show -n $SA -g $RG --query id -o tsv)/fileServices/default

az monitor metrics list --resource $FS_ID --interval PT1M \
  --metrics SuccessE2ELatency SuccessServerLatency --aggregation Average \
  --start-time 2026-11-25T08:00:00Z --end-time 2026-11-25T09:00:00Z -o table

az monitor metrics list --resource $FS_ID --interval PT1M \
  --metrics Transactions --aggregation Total \
  --filter "FileShare eq 'appdata' and ResponseType eq '*'" -o json

Group by ResponseType and look for values that mention throttling. SuccessWithMetadataWarning and SuccessWithMetadataThrottling point at metadata operations, which have their own limit. More provisioned IOPS does not raise it.

Also chart FileShareMaxUsedIOPS and FileShareMaxUsedBandwidthMiBps against FileShareProvisionedIOPS and FileShareProvisionedBandwidthMiBps. One-minute averages hide short bursts. The "max used" metrics do not.

Two traps:

  • Burst credits flatter short tests. A new share starts with credits. Test long enough to use them up, or you will size to burst.
  • Limits add up elsewhere. The VM has a network bandwidth cap, and the storage account has its own total across all shares.

If the share is the limit, raise provisioning. The controls depend on the billing model of the account (provisioned v1 ties performance to size; v2 sets it separately):

# provisioned v1: size drives IOPS and throughput
az storage share-rm update -g $RG --storage-account $SA -n appdata --quota 4096

Tip

Reducing a share's provisioned size is restricted for a period after a change. Check the current rule before scaling up for a one-off test.

Step 3: use nconnect, and confirm it

By default, a client uses one TCP connection to the server. nconnect opens several. Microsoft's guidance is 4: Azure Files accepts more, but does not gain from more than four.

sudo mkdir -p /mnt/share
sudo mount -t nfs stnfsprod.file.core.windows.net:/stnfsprod/appdata /mnt/share \
  -o vers=4,minorversion=1,sec=sys,nconnect=4,rsize=1048576,wsize=1048576,noresvport,actimeo=30

Encrypted, with the AzNFS mount helper installed:

sudo mount -t aznfs stnfsprod.file.core.windows.net:/stnfsprod/appdata /mnt/share \
  -o vers=4,minorversion=1,sec=sys,nconnect=4

noresvport matters on kernels before 5.18: it helps the client reconnect after a network event.

The trap is connection sharing. Linux reuses connections for mounts that resolve to the same server, so the first mount decides. Remounting with -o remount,nconnect=4 does not change it. Unmount all shares from that account, then mount again:

sudo umount /mnt/share
sudo mount /mnt/share
ss -tn '( dport = :2049 )' | grep -c ESTAB

Warning

Unmounting stops applications. Drain the node and check sudo fuser -vm /mnt/share. Avoid umount -l in production: open files stay attached to the old mount, with the old settings.

Per-mount settings are supported for one share per account over a private endpoint. If different shares need different settings, put them in separate accounts.

Do not expect a gain from nconnect with a single-threaded application at low queue depth. Measure latency for that case, because it may get worse. Keep queue depth at or below 64.

Step 4: raise read-ahead for sequential reads

From kernel 5.4, the NFS client default read-ahead is 128 KiB, which is small for a 1 MiB rsize over a network. Set 15 MiB through udev so it survives remounts:

sudo tee /etc/udev/rules.d/99-nfs.rules >/dev/null <<'EOF'
SUBSYSTEM=="bdi" \
, ACTION=="add" \
, PROGRAM="/usr/bin/awk -v bdi=$kernel 'BEGIN{ret=1} {if ($4 == bdi) {ret=0}} END{exit ret}' /proc/fs/nfsfs/volumes" \
, ATTR{read_ahead_kb}="15360"
EOF
sudo udevadm control --reload

The rule runs when a device is added, so remount. Then verify:

cat /sys/class/bdi/$(mountpoint -d /mnt/share)/read_ahead_kb

The rule applies to every NFS mount on the host. Random-read workloads such as databases can waste throughput with large read-ahead, so do not roll it out to them without a test.

Step 5: reduce metadata round trips

Unpacking archives, git status, package installs and web roots with many small files cost one or more round trips per file. Throughput settings do not help. In order of effect:

  1. Place the client in the same zone as the share where zonal placement is supported. Every synchronous operation pays the network latency.
  2. Parallelize. Many small operations at once hide latency: use parallel copy tools in place of one cp -r.
  3. Cache attributes. Set actimeo between 30 and 60. Lower values increase the request rate.
  4. Avoid small files on the share. Pack them into an image or archive and extract onto local disk at start.
  5. Shard hot directories across shares if you reach the metadata limit.

Caution

A longer actimeo means other clients' changes appear later. Do not use it to speed up an application that coordinates through file existence or modification time.

Step 6: rule out known client faults

Symptom Cause Fix
ls loops on large directories Kernel bug from 5.11, fixed in 5.12.5; some vendor kernels affected Move to a fixed kernel
Plain NFS mount refused Secure transfer or NFS encryption required Mount with aznfs, or change the setting deliberately
"Mount to the same endpoint ... using TLS" TLS and non-TLS mixed to one server Unmount, then use the clean option
chgrp Invalid argument ID mapping enabled Set nfs4_disable_idmapping to Y and remount
Root cannot chown Root squash Change the share's squash setting if policy allows
sudo nc -zv stnfsprod.file.core.windows.net 2049
sudo journalctl -t aznfs -t stunnel --since "1 hour ago"

Step 7: benchmark what you run

fio --name=seqread --directory=/mnt/share/fio --rw=read --bs=1M --size=8G \
    --numjobs=4 --iodepth=16 --ioengine=libaio --direct=1 \
    --time_based --runtime=600 --group_reporting

fio --name=sync --directory=/mnt/share/fio --rw=randwrite --bs=4k --size=1G \
    --numjobs=1 --iodepth=1 --ioengine=libaio --direct=1 --fsync=1 \
    --time_based --runtime=300 --group_reporting

Run on a spare client with its own directory. The first job shows the throughput ceiling. The second shows the latency your database-like workload will feel, and no amount of provisioning fixes that if it is too high. --direct=1 bypasses the page cache, so it also bypasses read-ahead: repeat the first job with --direct=0 on a file larger than memory to test step 4.

Prevent it next time

  • Put mount options in the image or /etc/fstab, with _netdev,nofail, so nodes do not drift.
  • Check nfsstat -m across the fleet after each rebuild.
  • Alert on throttled response types and on server latency, not only share capacity.
  • Re-test after kernel upgrades. Read-ahead and NFS defaults change there.