HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   HOWTO-Related Questions (http://www.howtoforge.com/forums/forumdisplay.php?f=2)
-   -   OpenVZ VSwap Memory Is it RAM or Hard Disk (http://www.howtoforge.com/forums/showthread.php?t=61243)

darinpeterson 31st March 2013 22:58

OpenVZ VSwap Memory Is it RAM or Hard Disk
 
Hi,

I'm currently working with CentOS 6.4, and installing multiple virtual servers. The VSwap implementation is a little confusing to me. Does the swapping of VSwap happen in RAM or on the hard disk? :confused:

If it's on the RAM, then I should configure my memory not to over run the hardware amount available, right?

Thank you,
Darin

MaddinXx 31st March 2013 23:31

Hi Darin

Lastly there was a discussion about that in the OpenVZ IRC channel and here's what I've picked up from it:

- OpenVZ vSwap is not like normal swap
- therefor it doesn't depend on the HW node swap size

but it is:

- happing in normal RAM
- like RAM allocation, but highly slowed down (so it's like swap from speed etc.)

Therefor yes, RAM + vSWAP of all containers should not be higher than total amount of memory (= totally no overselling).

However, always all RAM is used by all containers if needed and only limited if resources are busy. Same seems to apply for vSWAP - since it's located in memory, it cannot be used if all other containers use the total amount of their allocated RAM (if it fills HW total).

Don't take this as carved in stone - but I'm 90% sure I didn't get it that wrong :)

Hope this helps :)

darinpeterson 31st March 2013 23:37

Thank you Michel...

So that begs the question, "why would I use VSwap at all instead of allocating the memory that I want to use for that container?" I don't want the operation to be slow...

It seems I would be better off instead of doing:

6144 Memory
2048 VSwap

to do

8192 Memory
0 VSwap

Don't you think so?

Thanks,
Darin

MaddinXx 1st April 2013 00:03

This is pure speculation now, but what comes to mind:

- some apps require swap, otherwise they won't install (but this will not be the reason for implementing it)
- commercial aspect - doesn't it sound good if you get RAM + vSWAP rather than just RAM (must not be, but I think this could be since a lot of commercial vendors are "leading" the projects direction (Parallels))

But what about:

You have a total of 2GB Ram and create 2 VEs. Each gets 1GB Ram = no problems (but most hosting providers do oversell - it's only for them)

You give 1 VE 1GB and the other gets 1.5GB. Well, what happens if all memory is busy? e.g. 2.5GB RAM (500MB that is not available). It will lead to problems and I if the 1.5GB needs 1.5GB before the other, the 1st VE will only get 500MB.

But if you give 1GB each and 500MB swap for the 2nd VE - both will have the same amount if memory is full (swap will be ignored (that's what I'm not sure about, but as said, I thought it is like that). You won't have problems that way. However, if the one without swap only takes 500MB the 2nd one will have 1GB Ram + 500 swap.

darinpeterson 1st April 2013 01:22

Yeah, i don't know. I just don't know enough about VSwap, but you're probably right, it's better to have some. I'm going to dig into it, and see what else I can learn as soon as I finish server configurations. Then I'll do some fine tuning.

darinpeterson 8th April 2013 21:14

Might want to dig deeper on this.
 
Quote:

Originally Posted by MaddinXx (Post 295099)
Hi Darin
Therefor yes, RAM + vSWAP of all containers should not be higher than total amount of memory (= totally no overselling).

You may want to look a little deeper on this. After a response from Falko on this thread: http://www.howtoforge.com/forums/showthread.php?t=61272

And after using vzsplit, I found that RAM + vSWAP != TOTAL MEMORY

It looks to me like VSwap may be sharing the swap space between containers. If this is not the case, the only other conclusion I can come up with is that vspilt is very broken.

You can simply run the command on your hardware node, and see that the sum of just the VSwap memory exceeds the RAM in the system.

MaddinXx 8th April 2013 21:30

Hi Darin

I'm sure you've seen this as well: http://openvz.org/VSwap but I noted these sentences:

"The sum of physpages.limit and swappages.limit limits the maximum amount of allocated memory which can be used by a container. When physpages limit is reached, memory pages belonging to the container are pushed out to so called virtual swap (vswap). The difference between normal swap and vswap is that with vswap no actual disk I/O usually occurs. Instead, a container is artificially slowed down, to emulate the effect of the real swapping. Actual swap out occurs only if there is a global memory shortage on the system."

"no actual disk I/O" -> it's in memory. And "Actual swap out occurs only if there is a global memory shortage on the system" let me still think that it actually is/should be = total memory amount...

hmm...we have something to kill hours with hehe :)

darinpeterson 9th April 2013 03:00

Hi MaddinXx,

I did not read that yet, but I'm going to spend some time looking through it. Thanks for your reply.

Here is the result of running vzsplit on my hardware node, which has 32GB ram and 1.3TB disk space:

Code:

[root@hw ~]# vzsplit
Enter the number of containers: 5
The optimal swap space size is 64074 Mb, twice bigger than the RAM size

# Configuration file generated by vzsplit for 5 containers
# on HN with total amount of physical memory 32037 Mb,
# low memory 32037 Mb, swap size 95999 Mb, max threads 16000.
# Resource commit level 0:
# Free resource distribution. Any parameters may be increased

# This is VSwap-enabled configuration
# NOTE this configuration needs OpenVZ kernel 042stab042 or newer!

PHYSPAGES="0:4920936"
SWAPPAGES="0:9841872"

KMEMSIZE="unlimited"
DCACHESIZE="unlimited"
LOCKEDPAGES="unlimited"
PRIVVMPAGES="unlimited"
SHMPAGES="unlimited"
NUMPROC="unlimited"
VMGUARPAGES="0:unlimited"
OOMGUARPAGES="0:unlimited"
NUMTCPSOCK="unlimited"
NUMFLOCK="unlimited"
NUMPTY="unlimited"
NUMSIGINFO="unlimited"
TCPSNDBUF="unlimited"
TCPRCVBUF="unlimited"
OTHERSOCKBUF="unlimited"
DGRAMRCVBUF="unlimited"
NUMOTHERSOCK="unlimited"
NUMFILE="unlimited"
NUMIPTENT="unlimited"

DISKSPACE="105109876:115620864"
DISKINODES="6726221:7398844"                                                                       
CPUUNITS="1000"

That's some food for thought. :)

Darin


All times are GMT +2. The time now is 09:30.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.