Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


VPS "swap"?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

VPS "swap"?

I sometimes see VPS providers listing "Swap" (NOT vSwap) in their offer.

What kind of "Swap" is this and how is it different from just making/mounting a swapfile myself?

«1

Comments

  • Probably like pagefile. I would never use swap unless your system has a really low amount of RAM. Turn swap off with sysctl.conf if you have more then 2GB of ram.

  • and bear in mind that on most clouds / VPS - swap performance will likely be bad enough to impact your IOwait and load if you use it a lot anyway

  • MaouniqueMaounique Host Rep, Veteran
    edited January 2015
    1. Xen-PV is likely pre-partitioned. You may remove the swap and use it as simple partition instead, however, not everyone knows how to repartition the root vdrive.
    2. Linux needs swap for various things. It IS needed, but I suppose it does work without it, like a man with one eye is still able t see. Turning it off, in most cases, results in degrading the performance. It will impact your IO and performance when used instead of RAM which should NEVER be the case. It will likely results in disk abuse and your host will shut you down.
      When it is only needed to dump some unused allocated memory, as designed, not only that frees cache size for better IO, but also can give more ram to applications which are designed to cache and improve performance.
    Thanked by 2Pwner vimalware
  • vSwap is usually in reference to OpenVZ; it refers to virtual swap, which is just memory on the node that's artificially slowed down to simulate paging to disk.

    Swap for virtualization like KVM or Xen is actual virtual memory that is on the disk. Some providers make available templates and these templates can have pre-determined amounts of swap allocated (which is probably the swap number you see advertised). If you install from an ISO you can set swap to whatever you want. You can also change it after the fact if you want to go that route as well.

    Some swap is ok. For instance, if you have a bunch of processes and some are hardly ever used, and the really actives ones need more memory, then the seldom use processes can be paged to disk to free memory. The problem arises when your really active processes run out of memory and start using swap. At that point the server is going to become unresponsive. This is why large swap values probably aren't beneficial on a server.

    I typically keep a bit of swap but set the "swapiness" to a low value so it's not used unless absolutely needed.

  • jarjar Patron Provider, Top Host, Veteran
    edited January 2015

    @ECNetworks said:
    Probably like pagefile. I would never use swap unless your system has a really low amount of RAM. Turn swap off with sysctl.conf if you have more then 2GB of ram.

    This is poor advice. Don't do this. Swap is expected and many applications (Java, for example) will make a grab for more memory when swap is not available. It may not be documented, but it is observable.

  • Not poor advice at all. SWAP reduces speed and increases overhead and was actually a tip given to me in ways to increase debian's performance.

  • jarjar Patron Provider, Top Host, Veteran
    edited January 2015

    @ECNetworks said:
    Not poor advice at all. SWAP reduces speed and increases overhead and was actually a tip given to me in ways to increase debian's performance.

    Yes it is poor advice. No offense, it just is. Read my edit above. Swapping when you go OOM may not be a preferred state, but that does not mean you should disable swap. You probably just needed to adjust swappiness on your Debian system.

  • If you have more then 2GB of ram and are running linux you're not likely to run outta memory.

    • Always restart java applications every 3-6 hours.
  • jarjar Patron Provider, Top Host, Veteran
    edited January 2015

    @ECNetworks said:
    If you have more then 2GB of ram and are running linux you're not likely to run outta memory.

    ...

    Jar said: Swap is expected and many applications (Java, for example) will make a grab for more memory when swap is not available. It may not be documented, but it is observable.

    As for...

    @ECNetworks said:

    • Always restart java applications every 3-6 hours.

    No. You don't just restart production applications constantly because they are poorly coded or you don't know how to manage your system.

  • Does that mean "Swap" that is advertised is just marketing unless it's vSwap?

  • jarjar Patron Provider, Top Host, Veteran

    @radry said:
    Does that mean "Swap" that is advertised is just marketing unless it's vSwap?

    Depends on the virtualization. If it's OpenVZ, swap means vSwap. If it's Xen, @Maounique knows that better than I do. If it's KVM, shouldn't matter much because you typically control the partitions :)

  • I guess so.

    Jar if you start your java application with a MAX MEMORY aka -Xmx flag then you shouldn't have any issue.

    All my server machines have between 32-512GB of ram so i will never need swap.

  • jarjar Patron Provider, Top Host, Veteran

    ECNetworks said: All my server machines have between 32-512GB of ram so i will never need swap

    Well that kind of makes you not like everyone else, so I'm not sure I'd carry over your advice from a 512GB RAM box to LowEndTalk where the standard is more like 512MB ;)

  • I agree with @Jar. Don't disable swap.

    Have enough RAM for what you need. Set swapiness low to prevent unnecessary swapping.

    Modern operating systems aren't stupid, they'll manage it just fine but for the most part it's expected that some virtual memory be there. Besides, it's a safety net if something goes awry; it gives the system a bit of time to recover instead of killing processes because there's absolutely no memory available. This could mean the difference between a corrupt database or not.

    Thanked by 2jar Maounique
  • If you have 512MB of ram don't disable swap. I suppose 2GB is a bit low.

    If you have 6GB+ of ram you won't need swap.

    Thanked by 1jar
  • @ECNetworks said:
    If you have 512MB of ram don't disable swap. I suppose 2GB is a bit low.

    If you have 6GB+ of ram you won't need swap.

    Might as well just run everything on RAM, huh? I mean, the DD tests will be out of this world, but if I need to restart my program every 6 hours like you recommend, I'd lose all my data...

  • netomxnetomx Moderator, Veteran

    ECNetworks said: tip given to me

    You were saying you have lots of RAM on that box, and it was only your an app, that's why I suggested. Not having swap on small RAM boxes is just silly.

  • I have a large ram box and Im running a single application which can restart every 6 hours or so without loss of anything. I don't need swap. So i disabled it.

  • MaouniqueMaounique Host Rep, Veteran

    ECNetworks said: I have a large ram box and Im running a single application which can restart every 6 hours or so without loss of anything. I don't need swap. So i disabled it.

    Man, everyone here tells you you are wrong. Are we all drunk or just you?
    Swap is intended to dump memory pages which are very rarely used or not at all, just there for various purposes. it has the unintended consequence that, IF your box runs out of RAM, will start putting on the disk even data which IS needed and/or changes often, making a lot of disk accesses and slowing down not only you, but also the node if not setup well with io quota per user, most low end nodes are that way.
    If you do disable swap, you may not have the buffer for when the system DOES run out of ram, the largest ram servers can run out of ram in case of multiple child processes with memory leaks, you will notice immediately the sluggishness, while without swap it will start failing mysteriously, killing processes and it may be difficult for someone which disables swap because "it was sound advice" to actually diagnose the problem.
    Everyone, please DO NOT DISABLE SWAP! I am doing it ONLY on very low end in terms in disk (usb sticks) with full encryption when I do something highly sensitive. The tradeoff is worth it in this case.
    If you say your systems do not run out of RAM, then the risk of running swap partitions will never materialize, so it is even more stupid to disable it. Apart, of course, for the encryption and very delicate activities where you may choose to reduce the attack surface even further.

    Thanked by 3jar netomx vimalware
  • No. I don't need swap and never will.

  • jarjar Patron Provider, Top Host, Veteran
    edited January 2015

    @ECNetworks said:
    No. I don't need swap and never will.

    Which is fine, and certainly you should run your systems as you see fit. The point is that if you truly do not need it, you have nothing to lose by having it. If removing it speeds up your system, you should learn why that is and address the actual problem instead of removing swap. At least, if you want to do things the correct way and learn how the system operates as you go, which benefits you when the next problem arises. If a short term resolution without understanding the reason is sufficient for you, that's fine, but it isn't a solution...it's a bandaid.

  • netomxnetomx Moderator, Veteran
    edited January 2015

    And there's where @Maounique experience beats mine :p

  • @Maounique said:

    @ECNetworks said:

    No. The point to use swap is due to over commit policy. The actual usage of memory is the memory you use, while the limit of usage is the memory you request.

    Suppose you have an app allocating 2gb memory but only using 10mb. When looking at your free status there's nothing wrong, but you are actually in OOM status and your database will probably be killed in seconds even you have 1990mb free memory. Swap, in this case, provides the room for the allocated yet not used memory space. Swapping out the commit part costs zero.

    You do have other choice. You can change the over commit settings on kernel, and ask oomkiller to be nicer. But still, using swap is much easier for beginners, at least.

  • jarjar Patron Provider, Top Host, Veteran
    edited January 2015

    msg7086 said: No. The point to use swap is due to over commit policy.

    wat

    Either I'm misunderstanding you entirely or that's the most insane thing I've read all week. Admittedly, I'm open to both possibilities. I could be misinterpreting some of your words.

    Thanked by 1Maounique
  • MaouniqueMaounique Host Rep, Veteran
    edited January 2015

    Jar said: wat

    I was as surprised as you when I heard this theory the first time. Apparently, some people believe that if a provider gives you swap, that is to mask the overselling. Furthermore, it means that overcommited nodes in terms of ram are using swap instead, and some providers use a fast SSD for this, hence the ssd-cached term.
    I would laugh if it was not sad.

    Thanked by 1jar
  • jarjar Patron Provider, Top Host, Veteran

    Maounique said: some people believe that if a provider gives you swap, that is to mask the overselling

    Which would be absolutely humorous if they knew what swap on OpenVZ is allocated with ;)

    Thanked by 1Maounique
  • MaouniqueMaounique Host Rep, Veteran
    edited January 2015

    @Jar said:
    Which would be absolutely humorous if they knew what swap on OpenVZ is allocated with ;)

    Hahahah, indeed :P

    Thanked by 1jar
  • MicrolinuxMicrolinux Member
    edited January 2015

    Just wow. Some of the dumbest shit I have ever read is in this thread.

    Thanked by 2jar MCHPhil
  • @Microlinux ikr. I try my best.

Sign In or Register to comment.