Running SQL Server and IIS 7.5 with 15 applications on a Windows Server 2008 R2 with just 4GB RAM creates significant memory pressure. The server likely experiences:
- Memory leaks from long-running processes
- Fragmented system resources
- Unreleased handles and connections
- Cache buildup that's never properly cleared
While scheduled reboots aren't ideal for production systems, they can provide measurable benefits in constrained environments:
# PowerShell script to check memory before reboot
$mem = Get-WmiObject -Class Win32_OperatingSystem |
Select-Object @{Name = "MemoryUsage"; Expression = {"{0:N2}" -f (($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)/$_.TotalVisibleMemorySize * 100)}}
Write-Host "Current memory usage: $($mem.MemoryUsage)%"
# Check SQL Server memory pressure
Import-Module SqlServer
$sqlMem = Invoke-Sqlcmd -Query "SELECT physical_memory_in_use_kb/1024 AS memory_in_use_mb FROM sys.dm_os_process_memory"
Write-Host "SQL Server memory usage: $($sqlMem.memory_in_use_mb)MB"
For a bi-nightly reboot schedule at 2 AM:
# Create scheduled task via PowerShell
$action = New-ScheduledTaskAction -Execute "shutdown.exe" -Argument "/r /t 0 /d p:4:1"
$trigger = New-ScheduledTaskTrigger -Daily -At 2am -DaysInterval 2
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "BiNightlyReboot" -Action $action -Trigger $trigger -Settings $settings
Before committing to reboots, implement these monitoring solutions:
# IIS Application Pool Recycling Settings
Import-Module WebAdministration
Set-ItemProperty "IIS:\AppPools\DefaultAppPool" -Name recycling.periodicRestart.time -Value "1.05:00:00"
Set-ItemProperty "IIS:\AppPools\DefaultAppPool" -Name recycling.periodicRestart.memory -Value 2000 # 2GB
For SQL Server memory optimization:
-- Configure max server memory (MB)
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'max server memory', 3072; -- Leave 1GB for OS
RECONFIGURE;
Track these key indicators before/after implementing reboots:
Metric | Pre-Reboot | Post-Reboot |
---|---|---|
Available Memory | Check at 18:00 | Check at 08:00 |
SQL Page Life Expectancy | SELECT [cntr_value] FROM sys.dm_os_performance_counters WHERE [counter_name] = 'Page life expectancy' | Same query after stabilization |
IIS Request Queue Length | Get-Counter '\Web Service(_Total)\Current Connections' | Compare after 24h uptime |
On a resource-constrained Windows Server 2008 R2 running SQL Server and IIS 7.5 with 15 applications, memory leaks and accumulated processes can significantly degrade performance. With only 4GB RAM, scheduled reboots might seem like a quick fix.
Before implementing scheduled reboots, consider these factors:
- SQL Server's buffer pool may take hours to repopulate after reboot
- IIS application pools will lose all session state
- Any in-memory caching will be wiped clean
Try these optimizations before resorting to reboots:
-- SQL Server memory optimization
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'max server memory', 3072; -- Leave 1GB for OS/IIS
RECONFIGURE;
# PowerShell to recycle IIS app pools without full reboot
Import-Module WebAdministration
Get-ChildItem IIS:\AppPools | ForEach-Object { $_.Recycle() }
If reboots are necessary, here's a more surgical approach using Task Scheduler:
schtasks /create /tn "Nightly Maintenance" /tr "shutdown /r /t 30" /sc weekly /d MON,WED,FRI /st 02:00 /ru "System"
Track performance before and after reboots with Performance Monitor. Key counters:
- \Memory\Available MBytes
- \SQLServer:Buffer Manager\Page life expectancy
- \Web Service(_Total)\Current Connections
For sustainable performance:
- Upgrade to at least 8GB RAM
- Migrate to newer Windows Server version
- Implement proper application memory management