LANified!-hosted tracking url

LANified! IT Services Logo

🇨🇦 Proudly Canadian Since 2006 🇨🇦

.

You're using Swap Memory incorrectly

Published on 12/31/24, 4:36 p.m.


How much swap memory am I using? Does swap memory cause performance problems? Why should I care about swap memory usage? Do I have enough RAM?

If you have not thought about questions like these for swap memory, then there's a high chance that you have swap memory problems in your IT Environment.


We at LANified! have worked in the smallest IT environments up to the largest of Top 500 Enterprise environments. And we consistently see Swap Memory being used incorrectly in all of them.

Every organisation uses Swap Memory incorrectly across their entire IT Environment. That is, until we implement the appropriate corrections. Windows, Linux, Unix, this applies to every Operating System. This incorrect usage typically stems from a lack of comprehension or other forms of misunderstandings & misconceptions around how Swap Memory works in practice. Even extremely seasoned IT veterans hold inaccurate understandings of Swap Memory and the problems that occur when not properly managed.

We do not recommend that Swap Memory be fully disabled, except for specific implementations where that is warranted such as Kubernetes nodes. We instead advocate for Swap Memory to be more correctly managed, and planned for with periodic regularity. Namely in a combination of IT Systems Architecting in advance of Swap Memory problems, but additionally through Monitoring, Metrics, & Alerting leading to appropriate environmental adjustments over time.

What's the problem?

When Swap Memory is incorrectly used it leads to tangible (and compounding) performance problems across IT Environments.

When data is moved out of RAM and into Swap Memory (regardless of the reason) this is where the performance problems start. Swap Memory always has to exist on a permanent storage device, which is significantly slower than RAM, and this becomes even more pronounced of a performance hit if network storage is involved. This then becomes a compounding problem when you have mutliple IT Systems (such as Virtual Machines) following the same behaviour, and is further magnified when network storage is involved. In addition to performance problems, this can lead to accelerated wear of the permanent storage devices backing this Swap Memory.

All data that is moved from RAM into Swap Memory leads to these performance problems without exception. When any IT System has to manage data that is in Swap Memory, simply managing Swap Memory contents without interacting with it involves reading from the permanent storage, instead of from RAM, and that action alone significantly slows down that IT System. This performance hit is even larger when applications actually interact with data in Swap Memory. When you expand this scenario out to 10 IT Systems, 100, or 1000+, this leads to a compounding magnification effect whereby all these IT Systems are managing and reading said data from Swap Memory instead of RAM, and they are all now choking waiting for the permanent storage to keep up with their requests (instead of RAM). If this permanent storage is accessed over a network this further throttles these IT Systems, even in 10 gigabit and faster environments. As now interacting with Swap Memory has to contend with many other legitimate traffic users on the same network, all contesting for limited performance.

Example numbers demonstrating the magnitude

  • DDR5 RAM: (6000MT/s)
    • Throughput: 96 Gigabytes per second
    • Latency: 8-10 Nanoseconds
    • Typical performance of data kept in RAM
  • SATA HDD: (Seagate 16TB IronWolf Pro)
    • Throughput: 0.27 Gigabytes per second, 0.28% the throughput of DDR5 RAM
    • Latency: 4,160,00 Nanoseconds, 520,000% slower than DDR5 RAM
  • SATA SSD: (Crucial BX500 480GB)
    • Throughput: 0.5 Gigabytes per second, 0.52% the throughput of DDR5 RAM
    • Latency: 136,000 Nanoseconds, 17,000% slower than DDR5 RAM
  • NVMe: (Kingston KC3000 2TB)
    • Throughput: Gigabytes per second, 6.25% the throughput of DDR5 RAM
    • Latency: 89,000 Nanoseconds, 11,125% slower than DDR5 RAM

Need help tuning your Linux kernel, RAM management, or workstation performance in Calgary? Check out our Professional Linux Workstation Support & Tuning Tiers.


How did we get here?

These are common causes we have seen lead to incorrect usage of Swap Memory:

  • Swap Memory is treated as if it were RAM intentionally
  • Swap Memory usage is not tracked and alerted for at all
  • IT Systems are incorrectly sized or architected for RAM usage and other related aspects
  • Inappropriate methods are implemented, such as ZRAM, that typically perpetuate or exacerbate the problems

Whatever the cause, Swap Memory usage grows over time and this slows down all IT Environments in ways that are invisible, until properly addressed.

How do you help us?

This is roughly how we properly address incorrect usage of Swap Memory:

  1. Establish and validate appropriate IT Systems Metrics, Monitoring, & Alerting services to provide valuable insights for planning, periodic improvements, and related efforts.
  2. Review the nature of each IT System in-tandem with information gleamed from Step #1 and elsewhere. Identify and implement appropriate adjustments to RAM, Swap Memory, and other technical resource allocations per IT System such that Swap Memory stops being consumed except in very brief extremely irregular scenarios.
  3. Tune Alerting for corrected IT Systems to raise alarm when Swap Memory usage occurs, to enable implementing further improvements if prior changes were insufficient.
  4. As new IT Systems emerge and need architecting, include these improvements to convert them into habits.

Easy Contact

If you want our help with this and other areas of your IT Environment, we recommend you fill out this form and we will contact you promptly!

Required
Required
Required
Required

.