SQL Server on Linux performance
These are OS-level tuning notes for running SQL Server (Standard or Express) on Linux (VM or bare metal), including containerized deployments (Podman/Docker).
Last updated: 2025-07-02
Prerequisites
Section titled “Prerequisites”- Root access on the Linux host.
tunedinstalled (for tuned profiles).
Tuned profile (throughput-performance)
Section titled “Tuned profile (throughput-performance)”Use a tuned profile designed for high-throughput server workloads:
tuned-adm profile throughput-performanceCheck the active profile:
tuned-adm active
# Output: Current active profile: throughput-performanceDisable Transparent Huge Pages (THP)
Section titled “Disable Transparent Huge Pages (THP)”SQL Server recommends disabling THP to avoid memory compaction delays that affect query performance.
Temporary (runtime only)
Section titled “Temporary (runtime only)”echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defragPersistent (systemd unit)
Section titled “Persistent (systemd unit)”cat <<EOF > /etc/systemd/system/disable-thp.service
[Unit]
Description=Disable Transparent Huge Pages
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo never > /sys/kernel/mm/transparent_hugepage/enabled && echo never > /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reexec
systemctl enable --now disable-thpVerify:
cat /sys/kernel/mm/transparent_hugepage/enabled
# Expected: [never]NUMA awareness (2+ NUMA nodes)
Section titled “NUMA awareness (2+ NUMA nodes)”On bare-metal or large VMs with more than one NUMA node, pin containers to reduce cross-node latency.
Check layout
Section titled “Check layout”lscpu | grep -i numa
numactl --hardwareExample: Pin a container to NUMA node 0
Section titled “Example: Pin a container to NUMA node 0”podman update --cpuset-cpus=0-5 your-sql-container
podman update --cpuset-cpus=6-7 your-api-containerI/O scheduler
Section titled “I/O scheduler”Recommended scheduler for fast disks (NVMe or SSD):
cat /sys/block/sda/queue/scheduler
# Expected: [none] mq-deadline kyber bfqnone: Best for modern fast storage (default withthroughput-performance)mq-deadline: Optionally useful on SATA if contention observed
SQL Server Express limits (reminder)
Section titled “SQL Server Express limits (reminder)”When using SQL Server Express, resource limits apply automatically but you can still enforce them at the container level.
resources:
limits:
memory: "2Gi"
cpu: "4"Express Edition limits:
- 1.41 GB max memory
- 1 socket / 4 cores
- 10 GB per database
Checklist
Section titled “Checklist”- Enable
throughput-performancetuned profile - Disable THP persistently
- Confirm I/O scheduler (
noneormq-deadline) - If multi-NUMA: pin SQL/container workloads
- If Express: enforce container limits when appropriate
Known risks / failure modes
Section titled “Known risks / failure modes”- Changing tuned profiles can impact other workloads on the host; validate with the full stack running.
- THP settings may revert after kernel changes if not applied via systemd.
- CPU pinning can make performance worse if the container threads are starved; validate with real load.