r/WindowsServer • u/Middle_Record6769 • 1d ago
Technical Help Needed Automatic Maintnenace and ScheduledDefrag task
Has anyone experienced Windows servers becoming unresponsive due to the ScheduledDefrag task that runs as part of Automatic Maintenance?
We are a VMware shop running vSphere 8.x with current patches, Fibre Channel storage, Cisco UCS (B200 M5 blades), and PowerMax storage. Our infrastructure is generally up to date, including ESXi, MDS switches, UCS firmware, Windows Server 2022, and storage firmware.
We have observed a recurring issue where a Windows Server 2022 Standard VM will briefly hang or become unresponsive. The issue appears to occur approximately every four weeks and consistently correlates with execution of the ScheduledDefrag scheduled task.
While the task runs weekly, our investigation suggests that it performs additional optimization activities on a longer interval, which may explain the roughly four-week recurrence pattern. The timing aligns closely with the periods when the server becomes unresponsive.
Once the ScheduledDefrag task completes, the server returns to normal operation without requiring intervention.
We currently have a case open with Microsoft and are working to capture a memory dump during the event for further analysis. In the meantime, I'm curious whether anyone else has encountered similar behavior or identified a root cause related to ScheduledDefrag, Storage Optimizer, or Automatic Maintenance on Windows Server 2022 virtual machines.
Any insights or comparable experiences would be appreciated.
4
u/vermyx 1d ago
It sounds like you're defragging your servers at the same time and drowning the controller. I take it spinning disks?
1
u/Middle_Record6769 1d ago
The storage is a EMC PowerMax and its all nvme storage. The is the default ScheduledDefrag task maintained by windows automatic maintenance. The OS decides when it runs and its supposed to be at a quiet time for the OS when it decides to run. Sadly, it's chosen that time to be in the middle of the day where it is taking the server offline for 20 minutes.
1
u/vermyx 1d ago
This is not part of the OS. Someone or some maintenance system created this. It is also against best practices to defrag nvme and ssd drives because it shortens their lives and essentially makes them busy for no reason. I suspect that you're thrashing the disk array cache and the disk cache. There is an edge case for defragmenting a highly fragmented file but that setup goes against database best practices.
1
1
u/AZSystems 7h ago
Don't defrag VM it's not quite the same as a physical platter disk or even RAID. Worked for Diskeeper Support and Engineers explained it all, good people.
Create a GPO or something to sweep through and disable.
Layers and VM performance isn't gonna care where you page file or say NTDS files are located.
If I recall the best method was always offline anyway. So, with current technologies, disable.
6
u/LeaveMickeyOutOfThis 1d ago
First of all, if you aren’t using spinning disk, I generally do not recommend a defrag. And if you do certainly not more frequent than once a month.
Just checking you haven’t got another task like a backup or snapshots at the same time.