Back to posts
Post

Enforcing SMB Compression on Windows Server 2022 with PowerShell and Measuring CPU Impact

Enable SMB compression via Set-SmbServerConfiguration, monitor CPU usage with PerfMon, and assess real-world performance trade-offs on file transfers.

WindowsSMBPowerShellPerfMoncompression

In my environment, I recently needed to reduce bandwidth usage between two Windows Server 2022 nodes replicating large VM backups over a 1Gbps link. Enabling SMB compression seemed like a straightforward win — but I wanted to measure the actual CPU cost before rolling it out. Here’s how I enforced compression using PowerShell and tracked the impact with PerfMon.

Enabling SMB Compression via PowerShell

The core command is simple: set the server-wide SMB compression flag to true. This forces compression for all compatible SMBv3 connections unless overridden per-share or per-client.

Set-SmbServerConfiguration -EnableCompression $true -Force

The -Force flag skips the confirmation prompt, which is helpful in automation. After running this, I verified the setting with:

Get-SmbServerConfiguration | Select EnableCompression

It returned True, confirming the change took effect immediately — no reboot required. Keep in mind this only affects new connections; existing SMB sessions continue using their current settings until reestablished.

Choosing What Gets Compressed

By default, SMB compression targets files larger than a certain threshold and skips already-compressed formats like JPEG, ZIP, or PDF. You can tune this behavior if needed. For example, to lower the minimum file size for compression to 8KB (default is 64KB):

Set-SmbServerConfiguration -CompressionThreshold 8192

I left it at the default since my workload involved large VHDX and ISO files — well above the threshold. If you're dealing with lots of small files, adjusting this threshold can prevent wasting CPU on incompressible data.

Monitoring CPU Impact with PerfMon

To measure the real cost, I set up a PerfMon data collector focusing on:

  • Processor(_Total)\% Processor Time
  • SMB Server Shares\* (specifically Bytes Total/sec and Compressed Bytes/sec)
  • Memory\Available MBytes

I started a 10-minute baseline capture before enabling compression, then ran a controlled robocopy job transferring a 20GB VM backup file between servers. After capturing the baseline, I re-enabled compression (in case it had been reset) and repeated the transfer under identical network and disk conditions.

The results showed:

  • Baseline: ~15% avg CPU usage during transfer, ~110 MB/s throughput
  • With compression: ~28% avg CPU usage, ~160 MB/s effective throughput

CPU usage nearly doubled, but the effective throughput increased by ~45% due to reduced wire traffic. On a 1Gbps link, this meant the transfer completed in under 3 minutes instead of nearly 5 — a meaningful win for nightly replication windows.

When to Use (or Avoid) SMB Compression

SMB compression shines when:

  • Network is the bottleneck (WAN, congested LAN, or limited uplink)
  • Transferring compressible data (VM disks, logs, text backups, ISO images)
  • CPU headroom exists on the file server

Avoid or test carefully when:

  • Servers are already CPU-bound during peak hours
  • Working with pre-compressed media (video, audio, encrypted files)
  • Using older NICs or drivers with poor offload support — compression adds CPU work that can interfere with interrupt moderation

As I mentioned before in my post about tuning Linux tc for VoIP, offload and CPU budgeting are always linked — what you gain on one side, you may lose on the other.

Tip: Combine with SMB Multichannel for Better Balance

If your NICs support RSS or RDMA, consider enabling SMB Multichannel alongside compression. This lets multiple CPU cores handle SMB traffic, reducing the per-core impact of compression. You can check multichannel status with:

Get-SmbMultichannelConnection

In my setup, enabling both features kept individual core usage under 35% while maintaining high throughput — a much smoother profile than compression alone.

Final Thoughts

Enforcing SMB compression on Windows Server 2022 is a low-effort, high-visibility tweak — but it’s not free. Measure first, don’t assume. In my case, the CPU cost was justified by the time savings and reduced network load. If you’re replicating backups or moving large datasets between sites, it’s worth testing. Just keep PerfMon running, and let the data decide.


Cover image: Negative Space · CC0 (Openverse / kamu malı) · https://stocksnap.io/photo/macbook-laptop-X0CYLUO8E0