Web Hosting Talk







View Full Version : No SWAP memory on a VPS?


rezilient
04-29-2011, 09:47 AM
When I asked why my managed VPS was configured with no swap, and that it please be configured I was told this by my VPS provider:

Its not possible to add swap partition on a VPS, and there is no need to create separate swap file. You can keep track of the memory usage in power panel under resource alerts. If the VPS is using up the memory allocated, you can see the alerts there.

I realize that it's "best" to never start swapping a lot, but my understanding was that if memory was low, some virtual memory would keep you going at least, to avoid services from crashing or worse.

Thoughts?

rds100
04-29-2011, 09:51 AM
If it is an OpenVZ VPS there is simply no such thing as swap.
If it is Xen you can easily add swap yourself.

rezilient
04-29-2011, 09:55 AM
If it is an OpenVZ VPS there is simply no such thing as swap.
If it is Xen you can easily add swap yourself.

What about Parallels Virtuozzo?

I'm coming from a Xen VM, so the information about OpenVZ is new to me. Can someone explain?

rds100
04-29-2011, 09:58 AM
Virtuozzo is OpenVZ so there is no swap. OpenVZ has "guranteed RAM" and "burst RAM".

rezilient
04-29-2011, 10:04 AM
Virtuozzo is OpenVZ so there is no swap. OpenVZ has "guranteed RAM" and "burst RAM".

Ok interesting, so if I'm down to 0MB free what will I see on my VM? Will the amount of memory change when it "bursts"? Here is what I'm seeing now in free -m. Also what about the typical "cached" RAM that Linux would reserve, right now I'm seeing none.


[root@host ~]# free -m
total used free shared buffers cached
Mem: 768 80 687 0 0 0
-/+ buffers/cache: 80 687
Swap: 0 0 0


Thanks!

rds100
04-29-2011, 10:08 AM
No, the maximum memory you can burst to is 768MB. How much of that is guranteed cannot be seen this way.
cat /proc/user_beancounters to see various OpenVZ limits and statistics. And then look at http://wiki.openvz.org/UBC to see what they mean.

Also there is not cached memory because the VPS doesn't do any caching, it doesn't even have its own kernel. There is only one kernel on the hardware node, and your VPS just has processes isolated in a container. The chaching is done at the hardware node level.

stardust_x7
05-11-2011, 07:46 PM
If it is an OpenVZ VPS there is simply no such thing as swap.
If it is Xen you can easily add swap yourself.

Under Xen how can we add swap?

Crothers
05-11-2011, 07:47 PM
Under Xen how can we add swap?
Create a partition on your disk and format it to be swap?

IE: The same way you add swap on all Linux systems.

dmmcintyre3
05-23-2011, 05:05 PM
Under Xen how can we add swap?

http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

monty1983
05-23-2011, 09:03 PM
Most hosts don;t like to offer swap because of the load it generates on the SANs, I/O from alot of random reads and writes.

If swap is something you really need you can create a swap file, adjust to following to suit your needs:

1) Create a file to use as swap:
-this command will create 1GB file
dd if=/dev/zero of=/swapper bs=1M count=1024

2) Create a swap are in the file:
mkswap /swapper

3) Turn the swap on:
swapon /swapper

4) To make the swap area persistent on reboot add the following line to /etc/fstab:

/swapper swap swap defaults 0 0

5) Run:

free -m

You should now see your available swap space.

Dig1
05-30-2011, 04:16 PM
Openvz swap file install works perfect
[root@s1 ~]# free -m
total used free shared buffers cached
Mem: 512 325 186 0 0 0
-/+ buffers/cache: 325 186
Swap: 1024 0 1024
[root@s1 ~]#
i only have 512mb ram
now i have a swap as seen in root also as seen in webmin running proc
Display : PID | User | Memory | CPU | Search | Run..

Real memory: 512 MB total / 186.25 MB free Swap space: 1024 MB total / 1024 MB free
i dont run outa memory no more
OpenVZ does not support Swap. If you have a program that requires swap, then you can create and use a fake swap.
1) Log into your vps as root.
2) Download fake-swap.sh shell-script.
wget XXhttpX:X/X/service.welcome2inter.net/downloads/fake-swap.sh
3) Make script executeable
chmod u+x fake-swap.sh
4) Run script to create fake swap ...
... with 512MB (default)
./fake-swap.sh
Enjoy



... with 1024MB

./fake-swap.sh 1024

skoh
07-05-2011, 05:11 AM
Openvz swap file install works perfect
...
i dont run outa memory no more


The swap is fake. It is used to fool applications so that they think there is swap space available but in actual fact there is none. You will still run out of memory if you use that fake-swap.sh.

karigaalan
07-18-2011, 04:36 AM
my vps too have the same problem

Echizen
07-18-2011, 02:13 PM
virtuozzo/openvz vps doesn't support swap, if you need swap for your development move your app to Xen box!

Harel
07-20-2011, 12:50 PM
Yes and shared between other boxes too.

Kind Regards
.
.

Virtuozzo is OpenVZ so there is no swap. OpenVZ has "guranteed RAM" and "burst RAM".

BassHost
07-29-2011, 03:52 PM
Honestly the best way to remedy the problem of not enough ram is to upgrade the amount of ram that you have. :/ That is really the best way. Whether you are on OpenVZ or Xen, you NEVER want to start swapping. You are best off just putting up some more dough for the extra bit of ram. Most times it doesnt cost that much.

Simon-Orqoo
07-29-2011, 03:57 PM
As others have said, OpenVZ does not use swap, that is why you have burst RAM on OpenVZ.

Dig1
07-29-2011, 04:15 PM
As stated on this forum in many articles
OpenVZ does not use swap!
OpenVZ does not Support swap!
OpenVZ is designed to use Burst Ram!
If you really need Swap Migrate to XEN!
Or buy more Ram if using OpenVZ!

mustardman
09-08-2011, 05:13 PM
Well I guess I may as well break the bad news to you all and muddy the waters. OpenVZ does now support swap with their new RHEL6 kernel that recently went into the stable branch.

It's not the same as real swap which is why they call it "vswap" but from inside the container it looks exactly the same. Oh and memory caching is now supported too. So now all memory inside a container behaves exactly the same as on dedicated hardware. Thankfully these new features supersede burst memory which was confusing to a lot of people and not useful for anything anyways.
http://wiki.openvz.org/VSwap

In my limited testing so far it seems to work well. It seems to have tamed Java behaviour which was an annoying problem with the old memory management model.