So you think your OpenVZ VPS really has “guaranteed memory”? Well. Not quite. I have got an OpenVZ VPS from one of the providers listed here — 256MB guaranteed and 512MB burstable memory. When I run free
it shows
$ free -m total used free shared buffers cached Mem: 512 65 446 0 0 0 -/+ buffers/cache: 65 446 Swap: 0 0 0
So — 512MB total memory and 0 swap? After all I am only using 65MB of memory so well below my “guaranteed” amount. Zero swap because it is just how OpenVZ does its memory account. But is it really the case that all my processes reside in physical RAM?
Let’s dig out the good ol’ user_beancounters.
$ sudo cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)' uid resource held maxheld barrier limit failcnt physpages 6662 11570 0 2147483647 0 oomguarpages 8085 12750 65536 2147483647 0
I am trying to highlight the “physpages” and “oomguarpages” amount. According to OpenVZ Wiki:
physpages
Total number of RAM pages used by processes in this container.
oomguarpages
oomguarpages parameter accounts the total amount of memory and swap space used by the processes of a particular container.
Sounds like one is the total number of physical pages used by the container, and the other one is the total number of pages (physical + swap) used by the container. That means when you take oomguarpages – physpages you get — the number of swapped pages from processes in this container! Now back to my UBC readouts, I have
(8085 – 6662) * 4096 / 1024 / 1024 = 5.56MB!
out of 31.58MB (8,085 pages) that has been swapped out. And the 65MB figure returned by “free” is merely how much my processes have been allocating — so only 1/2 are actually used, and 18% of that is already swapped out.
So, has your low end provider been overselling the memory and caused your pages to swap out?
Related Posts:
- 5 Reasons Why You Want a Low End Box - May 26, 2021
- Dead Pool January 2012 - February 2, 2012
- exit(0); - January 19, 2012
Wow! That is real? That can show us the real scenary of our VPS providers.
Another reason to setup a machine with openVZ and understand better the behavior of vps’s
Thanks!
At this moment, none of my providers show that problem n_n
Hi, one thing to remember is that some hosts determine the saturation point, 65MB in your case. The real question is what value, (if any), the web host determines that the memory is oversold.
Based on my experience, it is not necessary to oversell memory. The disk io bandwidth is a much more finite and valued number for real-time processing (think 60MB database->website).
What type of disk configuration is this server running?
On my main VPS, 4.5 of 344.6MB is swapped out.
The rogue’s gallery of low-end (and not-so-low-end) OpenVZ VMs, in no particular order:
“256MB Dedicated RAM” ‘1 Power Unit’ @ Hostrail: ( 4892 – 3074) * 4096 / 1024 / 1024 = 7.1MB out of 19.1MB used. *Ouch*
256MB BuyVM: 0 – yes, zero – MB out of 89.1MB used.
128MB NixCom: 0.86MB of 79.9MB used.
256MB Spacerich: 3KB of 143.8MB used.
256MB 123Systems: 4MB of 43.9MB used.
128MB HostinginCanada: 0 – yes, zero – MB out of 15.6MB used.
Second 128MB HostinginCanada: 0 – yes, zero – MB out of 18.5MB used.
128MB VPS4LESS: 0 – yes, zero – MB out of 15MB used.
Ancient 256MB ex-NYNOC (now Steadfast): 0 – yes, zero – MB out of 58.4MB used.
368MB(?) ThrustVPS: 0.1MB out of 18.6MB used.
So, overally, I’ve been somewhat lucky, I guess…
My HostRail VPS (4 power units) only swapped out 998 pages, or 3992 KiB of it’s 316 MB used.
After this afternoon’s reboot of the Uranus node, the same VM above is now swapping zero of its 30.9MB used. I suspect they might have craftily adjusted a few things when they did the processor upgrade. (Or just added another couple gigs of RAM while they were at it.)
It’s actually running at 0.00 load right now, i.e. no blocking iowait. If it stays like this for a couple days, I might even be willing to put it into production…
Heh heh heh…. there goes “the secret of overselling” good I/O and HDD.
512MB – Europhase.net VPS – Zero (0.00MB) of 394MB used. *Phew*
Thanks for the great info!
Here is a small script to do the calculation automatically:
#!/bin/bash
cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)'
PHYS=`cat /proc/user_beancounters | grep " physpages " | awk '{print $2}'`
OOMGUAR=`cat /proc/user_beancounters | grep " oomguarpages " | awk '{print $2}'`
SWAP=$(($OOMGUAR-$PHYS))
echo
echo Swapped out: $SWAP pages, or $(($SWAP*4096/1024)) KiB
Too useful :D
Thanks!
BTW, nice grep usage LEAdmin
Run the script on my 99 cents 64MB vpstree box:
uid resource held maxheld barrier limit failcnt
physpages 3554 12489 0 2147483647 0
oomguarpages 3554 12489 16384 2147483647 0
Swapped out: 31 pages, or 124 KiB
Ah, 3554/3554 and still 31 pages… the script makes 3 separate accesses to that file, so it will be a bit imprecise. Still not by much and your result is nothing to worry about. Here’s a better version:
#!/bin/bash
cp /proc/user_beancounters /tmp/
cat /tmp/user_beancounters | grep -E '(uid|physpages|oomguarpages)'
PHYS=`cat /tmp/user_beancounters | grep " physpages " | awk '{print $2}'`
OOMGUAR=`cat /tmp/user_beancounters | grep " oomguarpages " | awk '{print $2}'`
SWAP=$(($OOMGUAR-$PHYS))
rm /tmp/user_beancounters
echo
echo Swapped out: $SWAP pages, or $(($SWAP*4096/1024)) KiB
Thanks for the script.
thx rm, i used the new version of the script on my 99 cents 64MB vpstree box:
uid resource held maxheld barrier limit failcnt
physpages 3579 12489 0 2147483647 0
oomguarpages 3579 12489 16384 2147483647 0
Swapped out: 0 pages, or 0 KiB
This does not seem to work on 2 out of 3 of my OpenVZ VPSs.
Lol, forgot sudo? xD
Yes, I didn’t advised the mistake in the script, now is consistent.
Ty, rm n_n
My 99C vps doesn’t swap :D and is the VPS with BEST I/O I have o_O
I was running it from root on all 3.
uid resource held maxheld barrier limit failcnt
physpages 26999 46999 0 2147483647 0
oomguarpages 29897 47318 131072 2147483647 0
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options: GNU long options:
-f progfile --file=progfile
-F fs --field-separator=fs
-v var=val --assign=var=val
-m[fr] val
-W compat --compat
-W copyleft --copyleft
-W copyright --copyright
-W dump-variables[=file] --dump-variables[=file]
-W exec=file --exec=file
-W gen-po --gen-po
-W help --help
-W lint[=fatal] --lint[=fatal]
-W lint-old --lint-old
-W non-decimal-data --non-decimal-data
-W profile[=file] --profile[=file]
-W posix --posix
-W re-interval --re-interval
-W source=program-text --source=program-text
-W traditional --traditional
-W usage --usage
-W version --version
To report bugs, see node `Bugs' in `gawk.info', which is
section `Reporting Problems and Bugs' in the printed version.
gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.
Examples:
gawk '{ sum += $1 }; END { print sum }' file
gawk -F: '{ print $1 }' /etc/passwd
/bin/swapcheck: line 7: {print $2}: command not found
/bin/swapcheck: line 7: - physpages 27065 46999 0 2147483647 0: syntax error in expression (error token is "27065 46999 0 2147483647 0")
/bin/swapcheck: line 9: *4096/1024/1024: syntax error: operand expected (error token is "*4096/1024/1024")
/bin/swapcheck: line 10: *4096/1024/1024: syntax error: operand expected (error token is "*4096/1024/1024")
#!/bin/sh
awk '
$1 ~ /^physpages$/ { phys=$2 }
$1 ~ /^oomguarpages$/ { oomguar=$2 }
END { printf "%.1fM / %.1fM\n", (oomguar - phys) / 256, oomguar / 256 }
' /proc/user_beancounters
Thanks!
Nice script
Thanks for sharing this,
@Everyone, Remember this is only shows how much SWAP you are using (NOW), it is not necessarily over selling, it could simply means the provider doesn’t do good monitoring and controlling over the node. And in case of over selling, it many not give you the real picture, since most of clients may not be using the ALL guaranteed RAM. You need to repeatedly get these numbers to get a clear picture.
BuyVM Freemont 1GB ram, (2GB burstable)
uid resource held maxheld barrier limit failcnt
physpages 96214 119778 0 2147483647 0
oomguarpages 121540 142563 262144 2147483647 0
98MB out of 474MB
Damn, I knew BUYVM sucked from the first month I got them. ah well. using for backup storage now.
I wrote a Munin Plugin to graph this behavior on openVZ, and also have a cron bash script to check and alert by email.
check on my blog:
bash script: http://www.frederico-araujo.com/2010/07/09/check-guaranteed-ram-burstable-ram-o-openvz/
Munin plugin on github: http://github.com/fred/munin_plugins
and the code is in my github.
contributions and improvements are welcome :)
Nothing in swap at Ramhost :)
root@lalalalala:~# bash calc.sh
uid resource held maxheld barrier limit failcnt
physpages 58041 118340 0 9223372036854775807 0
oomguarpages 58041 118340 131072 131072 0
Swapped out: 0 pages, or 0 KiB
this at bluemilecloud. is this swaped?
this is from hostrail
sh calc.sh
uid resource held maxheld barrier limit failcnt
physpages 2321 8219 0 2147483647 0
oomguarpages 2321 8219 98304 2147483647 0
Swapped out: 0 pages, or 0 KiB
BuyVM
free
Alright. Here is the script I use. Coded in C so minimum memory usage.
It compiles the C code into an executable, and then run the program “vzfree”. It needs root access to read /proc/user_beancounters.
Also don’t trust me — read the code! :) Just in case you want to know what gets executed with root privilege.
sweet. that is fast.
Good to know you do C. I love C too.
I actually had that for ~2 years.
It looks like that script was from this website.
http://hostingfu.com/article/vzfree-checking-memory-usage-inside-openvz-ve
I didn’t look exactly at the vzfree.c code, so no warannty at all,
but if you want use as a normal user, just do the following
cp vzfree /usr/local/bin/vzfree
chmod 4750 /usr/local/bin/vzfree
# check to which group the files belongs to in this folder
ls -la /usr/local/bin/vzfree
# add yourself to this group
Awesome Bro
ksx4system@ramses:~/skrypty$ sudo ./vzfree
Total Used Free
Kernel: 2048.00M 1.01M 2046.99M
Allocate: 1024.00M 5.05M 1018.95M (512M Guaranteed)
Commit: 512.00M 4.43M 507.57M (67.6% of Allocated)
Swap: 0.00M (0.0% of Committed)
done using vzfree.c on CityNetHost’s $2,50/month OpenVZ VPS :-)
HostRail :
sudo cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)'
uid resource held maxheld barrier limit failcnt
physpages 2795 20218 0 2147483647 0
oomguarpages 2795 20218 98304 2147483647 0
thanks LEA
hey,lowendadmin
By default, the page size is 4k , but you have to run
getconf PAGE_SIZE
to see if it is not 8k or 16k
True. Just that I haven’t seen one that is not 4k :)
i have seen a lot. Note that 4k page size can only map 4G memory directly. If you have a server with 32G memory and you want a high performance, larger page size is needed(8k or 16k).
and in 64bit OS
You sure? :) Variable pagesize is usually only for x86 Linux boxens. All x86_64 ones I came across with are fixed to 4kb (and have no problem accessing over 4GB of memory address either for obvious reason).
mine look ok;
quickweb SupaVZ1
Total Used Free
Kernel: 2048.00M 4.12M 2043.88M
Allocate: 768.00M 221.47M 546.53M (512M Guaranteed)
Commit: 512.00M 104.13M 407.87M (45.2% of Allocated)
Swap: 0.00M (0.0% of Committed)
quickweb testbox01
Kernel: 2048.00M 2.72M 2045.28M
Allocate: 150.00M 45.26M 104.74M (128M Guaranteed)
Commit: 128.00M 18.82M 109.18M (35.6% of Allocated)
Swap: 0.00M (0.0% of Committed)
Thanks for the script and c code:)
./vzfree
Total Used Free
Kernel: 2048.00M 3.38M 2044.62M
Allocate: 1024.00M 28.01M 995.99M (512M Guaranteed)
Commit: 512.00M 18.88M 493.12M (55.3% of Allocated)
Swap: 0.00M (0.0% of Committed)
Using LEA’s vzfree.c none of the following rockmyweb, nordicvps, buyvm have any swap =]
Give some updates on rockmyweb man… how’s it going with them. Any issues? How long have you had them? etc etc.
I almost went with them, but then xen called.
Same RockMyWeb (Virtually Dedicated) No swap
BuyVM – 128mb OpenVZ
Total Used Free
Kernel: 2048.00M 2.72M 2045.28M
Allocate: 256.00M 37.11M 218.89M (128M Guaranteed)
Commit: 128.00M 22.36M 105.64M (52.9% of Allocated)
Swap: 0.51M (2.6% of Committed)
NordicVPS
512 – OVZ
Total Used Free
Kernel: 2048.00M 5.56M 2042.44M
Allocate: 1024.00M 142.35M 881.65M (512M Guaranteed)
Commit: 512.00M 83.90M 428.10M (55.0% of Allocated)
Swap: 0.00M (0.0% of Committed)
Very neat.
Now for something to test oversold disk IO :)
Yard VPS (lead-1 the $15 a year plan)
Swapped out: 1 page or 4 Kib.
Another run-
Swapped out: 0 pages or 0 Kib.
This guy was pretty fast till about yesterday; now there is a noticeable lag when entering commands; but no other issues. Ok one: All the OS images come with Apache+sendmail by default. I don’t know how to use anything except nginx.
bluemile vz512
Total Used Free
Kernel: 14.11M 2.89M 11.21M
Allocate: 1024.00M 28.67M 995.33M (512M Guaranteed)
Commit: 512.00M 19.65M 492.35M (58.5% of Allocated)
Swap: 0.00M (0.0% of Committed)
BUYVM does swap, and badly.
Total Used Free
Kernel: 2048.00M 5.26M 2042.74M
Allocate: 2048.00M 596.22M 1451.78M (1024M Guaranteed)
Commit: 1024.00M 429.15M 594.85M (71.1% of Allocated)
Swap: 117.46M (27.7% of Committed)
a lot of swap as you can see.
I would propose that instead of
sudo cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)'
use
sudo grep -E '(uid|physpages|oomguarpages)' /proc/user_beancounters
Here a small benchmark
$> time for i in `seq 1 10000`; do cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)' >/dev/null; done
real 0m31.412s
user 0m9.864s
sys 0m21.486s
$> time for i in `seq 1 10000`; do grep -E '(uid|physpages|oomguarpages)' /proc/user_beancounters >/dev/null; done
real 0m17.727s
user 0m6.532s
sys 0m11.193s
$>
Or read about useless use of cat award.
LOL. cat or grep –> which one would I rather give root privilege to?! :)
If you didn’t restrict the permissions, then both cat and grep can be executed by the user. What you need here are terms to this one file. You can configure sudo either cat or grep for ubc file . And since we are dealing here will lowend machines I would go for grep.
Indeed “cat | grep” is UUOC (Useless Use if Cat)..
also seq(1) is GNU/Linux”ish”, for i in {1..1000}; .. (bash 3) is more portable .. for the BSD centric people here.
@Joshbaptiste
Okay, optimizing cat vs grep for microsecond-scale performance gain was already dumb enough, but “for the BSD centric people here”, really? And your BSD runs OpenVZ too, I suppose? Being a shell syntax nazi helps no one in a script that is run once in a while (no one cares if it’s 0.01 sec or 0.02 sec), and only on one platform (GNU/Linux).
GigeVPS cheapest Package:
Total Used Free
Kernel: 2048.00M 4.64M 2043.36M
Allocate: 768.00M 97.62M 670.38M (384M Guaranteed)
Commit: 384.00M 46.75M 337.25M (43.1% of Allocated)
Swap: 0.00M (0.0% of Committed)
Ok, here goes. :)
ITExperts (VPS ITE FR- 256)
hostrail (1 unit)
GigeVPS (Silver)
TinyVPS (Standard package)
AvailableVPS ($14/year deal from here)
KnowinServers (KS L 300)
Hostfolks (Deluxe)
NixcomCA
Total Used Free
Kernel: 2048.00M 1.91M 2046.09M
Allocate: 1024.00M 40.75M 983.25M (512M Guaranteed)
Commit: 512.00M 33.02M 478.98M (76.3% of Allocated)
Swap: 5.43M (17.5% of Committed)
Don’t know if its good or bad.
At least it’s not 100% swapped. :)
Thanks for this. Kind of wondered how some hosts were guaranteeing all this memory.
Certain amount of swap is actually okay — some program could load tens or hundreds megabytes of data into RAM, and then not access it for hours. What’s the point of keeping that in RAM, it is perfectly fine for the OS to shift those pages from memory to disk, to allow for more file cache, for example.
It is ONLY when you notice unexplained slowdowns on your VPS, that you should care about the swap percentage. And then if it is high, then definitely the problem is too much RAM overselling.
Havent noticed any slowness in my VPS.
I guess the problem with OpenVZ is — it is the host OS who decides which pages should be swapped out, whereas it is your own kernel that decides. If I do prefer most my pages to be resident and don’t use cache much, I can tune my swapiness down on Xen/VMWare. I can’t do that on OpenVZ!
root@roubaix:~# sudo cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)'
uid resource held maxheld barrier limit failcnt
physpages 8715 16028 0 2147483647 0
oomguarpages 8715 16028 32768 2147483647 0
root@roubaix:~#
Why does mine display like this?
Perhaps you might want to read LEA’s comment #14?
Anyway both yours showed 8715 pages, indicating that there’s no swap used.
Anyone care to write a Nagios plugin? If not I will put it on my to-do list… it’ll probably take forever for me to get it though.
I can write a Nagios check for this in under 5 minutes. You can find my address on my site.
Or you can download my Nagios check skeleton and fill in the parts yourself.
Also, here is how to do the check in one line:
awk ‘{if ($1==”physpages”){p=$2} else if ($1==”oomguarpages”){o=$2} } END{s=(o-p)/256; print s}’ /proc/user_beancounters
Change the denominator on the end calculation if you want it in units other than megabytes.
Thanks Richard, that looks good. Will try out later.
YardVPS LEAF 2, 3.5$/mo
gigevps bronze, 4.46$/mo
thrustvps Aquatic, 4.95$/mo
Is these check method correctly ?
My result:
root@sunset:~# ./t.sh
uid resource held maxheld barrier limit failcnt
physpages 55880 100224 0 2147483647 0
oomguarpages 55890 100233 98304 2147483647 0
Swapped out: 106 pages, or 424 KiB
root@sunset:~# ./vzfree
Total Used Free
Kernel: 2048.00M 3.93M 2044.07M
Allocate: 512.00M 252.55M 259.45M (384M Guaranteed)
Commit: 384.00M 222.13M 161.87M (86.4% of Allocated)
Swap: 0.04M (0.0% of Committed)
what does these words mean?
Total Used Free
Kernel: 2048.00M 6.06M 2041.94M
Allocate: 512.00M 243.74M 268.26M (384M Guaranteed)
Commit: 384.00M 175.79M 208.21M (69.6% of Allocated)
Swap: 0.00M (0.0% of Committed)
Mine from Quickweb..
PhotonVPS BEAM2 $20.95/mo
YardVPS LEAF2 $3.5/mo
EnotchNetworks HADES $5.95/mo
Virpus Virtulpulse $5/mo
i need your advice guys… i dont know it is good or not
thanks
Of course is good n_n
Does this work on Debian?
Sure it works. I’m using only debian on all my servers.
for debian, to use/compile LEAs program, I had to apt-get install gcc, so didn’t work from bare install.
Properly, apt-get install build-essential
C’mon guys…I’m sure you realize the value of a low end box is to learn and to run simple or low traffic sites. You wouldn’t be using a cheap VPS for your folding@home clone (or whatever you want to do) lol
yardVPS $15/year VPS
[root@gallifrey ~]# sudo ./vzfree
audit_log_user_command(): Connection refused
Total Used Free
Kernel: 2048.00M 2.66M 2045.34M
Allocate: 256.00M 32.20M 223.80M (128M Guaranteed)
Commit: 128.00M 17.58M 110.42M (46.3% of Allocated)
Swap: 0.00M (0.0% of Committed)
[root@gallifrey ~]#
i love that server name
I thought it had already been destroyed by the Dalek?
No worries :) I used to have a server named “Alderaan”. Bad choice!
VPS FiberFirefly 5€/mo
[code] Total Used Free
Kernel: 2048.00M 8.03M 2039.97M
Allocate: 384.00M 128.46M 255.54M (256M Guaranteed)
Commit: 256.00M 109.17M 146.83M (78.7% of Allocated)
Swap: 0.00M (0.0% of Committed)
[/code]
Node 7 of citynethost =/
Kernel: 2048.00M 3.33M 2044.67M
Allocate: 1024.00M 247.96M 776.04M (512M Guaranteed)
Commit: 512.00M 81.47M 430.53M (31.5% of Allocated)
Swap: 4.57M (5.8% of Committed)
On my HostRail (1 Power Units) VPS.
endor:~# sudo ./vzfree
Total Used Free
Kernel: 2048.00M 2.26M 2045.74M
Allocate: 256.00M 81.19M 174.81M (256M Guaranteed)
Commit: 256.00M 70.99M 185.01M (84.7% of Allocated)
Swap: 0.00M (0.0% of Committed)
endor:~#
GigeVPS 384MB in UK
[root@uk2 ~]# ./vzfree
Total Used Free
Kernel: 2048.00M 2.80M 2045.20M
Allocate: 768.00M 21.07M 746.93M (384M Guaranteed)
Commit: 384.00M 15.45M 368.55M (60.1% of Allocated)
Swap: 0.00M (0.0% of Committed)
BuyVM 1GB
-01:31:04- zebes:~ root% ./vzfree
Total Used Free
Kernel: 2048.00M 2.77M 2045.23M
Allocate: 1024.00M 19.28M 1004.72M (512M Guaranteed)
Commit: 512.00M 12.86M 499.14M (52.4% of Allocated)
Swap: 0.00M (0.0% of Committed)
Nice.
My BuyVM VPS:
My other 2 are not swapping at all, but that might be because they are only allocating 16 to 20mb/committing to 10 to 6mb
UptimeVPS 5 EUR / year
This is in a Centos 5 node? Because in Centos 6 is so… funny (UptimeVPS)
@Yomero:
CentOS 6 and OpenVZ for 2.6.32 report values differently with the introduction of vSwap/deprecation of UBC.
Yes I know
Yeah with a typical VSwap host, it usually max out all the bean counter values so “vzfree” output would not make sense.
up2vps – Made me sad :(
Total Used Free
Kernel: 2048.00M 7.40M 2040.60M
Allocate: 1024.00M 678.14M 345.86M (1024M Guaranteed)
Commit: 1024.00M 336.08M 687.92M (48.5% of Allocated)
Swap: 55.24M (16.8% of Committed)
virtualsrv 4gb ram open vz
[root@matthew ~]# free -m
total used free shared buffers cached
Mem: 4096 447 3648 0 0 0
-/+ buffers/cache: 447 3648
Swap: 0 0 0
[root@matthew ~]#
[root@matthew ~]# cat /proc/user_beancounters | grep -E ‘(uid|physpages|oomguarpages)’
uid resource held maxheld barrier limit failcnt
physpages 26459 28331 0 2147483647 0
oomguarpages 26459 28331 524288 2147483647 0
[root@matthew ~]#
oomguarpages-physpages=0mb
not oversold
what if this is negative?
my first VPS:
Pretty good I guess. Because I was only using a very small bit of the resources I downgraded from 512M to 256M RAM. But now I have this result:
What should I make of this ??
Getting same as poster above , RocketVPS getting negative value , what to make of negative value anyone ?
physpages 120899
oomguarpages 40836
Kernel: 2048.00M 15.83M 2032.17M
Allocate: 1024.00M 579.37M 444.63M (512M Guaranteed)
Commit: 512.00M 176.55M 335.45M (27.7% of Allocated)
Swap: -312.91M (-194.7% of Committed)
free command:
total used free shared buffers cached
Mem: 1048576 482496 566080 0 0 304136
-/+ buffers/cache: 178360 870216
Swap: 0 0 0
root@coral [~]# cat /proc/user_beancounters | grep -E ‘(uid|physpages|oomguarpages)’
uid resource held maxheld barrier limit failcnt
physpages 374003 461463 0 393216 0
oomguarpages 100566 195973 9223372036854775807 9223372036854775807 0
Wellcome ;D
having swapped pages does not allways mean that the maschine is overselled.
e.g. having /proc/sys/vm/swappiness set to 60 and the maschines ram usage is 70% the kernel may decided to move some unused pages to swap to get more space for io-cache.
if the value of swapped pages is quite high, its an indicator for heavy overselling.
i run openvz maschines for some time and your can oversell memory quite a lot cause the kernel merges memorypages: 100 VMs with same distribution and same services won’t use (real) 100*n mb memory.
i wrote a script which sums all pages used by each container: overall usage: >40G while host’s ram was used only 12-14G.
this behavior i noticed while doing a live migration of a bigger container: after migration a container using ~ 4G ram, the host memory usage only increased by come hindret mb.
[root@Indiaovz data0]# sudo ./vzfree
Total Used Free
Kernel: 256.00M 51.83M 204.17M
Allocate: 36028797018963968.00M 230.80M 36028797018963736.00M (36028797018963967M Guaranteed)
Commit: 36028797018963968.00M 99.26M 36028797018963868.00M (20.6% of Allocated)
Swap: -458.82M (-967.4% of Committed)
What’s up?
What if
oomguarpages
is less than
physpages
? I got confused...OneAsiaHost 128MB OpenVZ SSD:
and
To those later commenters who are finding negative values when using this method:
You are using a newer implementation of OpenVZ memory management which uses vSwap – a fairer and more transparent system. In this system, the user_beancounters are mostly irrelevant – apart from the physpages.limit which shows the amount of guaranteed physical RAM you’ve been allocated.
To view the swap usage, just use “free -m”. For modern vSwap enabled OpenVZ systems, that value _is_ accurate.
On a non-oversold system, this vSwap is actually in memory, not on disk. It’s just slowed down a bit to emulate disk-based swap. This is a fair system that ensures everyone gets the physical memory they’re supposed to, but can use a little more as virtual swap. If host resources are tight, some of this vSwap may be actual disk-based swap.
Either way, you don’t need to resort to these scripts (which read user_beancounters) any more. “free -m” works fine now to show swap usage.
More info about vSwap:
http://www.daftdroid.com/2011/12/vswap-the-new-fairer-ram-allocation-for-openvz/