Editing
Memory Limits
(section)
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Memory Limits = <div id="bodyContent"> <span id="siteSub"></span> === From Linux-VServer === <div id="contentSub"> </div> <div id="jump-to-nav"> Jump to: [[#column-one|navigation]], [[#searchInput|search]] </div> A vserver kernel keeps track many resources used by each guest (context). Some of these relate to memory usage by the guest. You can place limits on these resources to prevent guests from using all the host memory and making the host unusable. Two resources are particularly important in this regard: * The '''Resident Set Size''' (<code>rss</code>) is the amount of pages currently present in RAM. * The '''Address Space''' (<code>as</code>) is the total amount of memory (pages) mapped in each process in the context. Both are measured in '''pages''', which are 4 kB each on Intel machines (i386). So a value of 200000 means a limit of 800,000 kB, a little less than 800 MB. Each resource has a '''soft''' and a '''hard limit'''. * If a guest exceeds the <code>rss</code> hard limit, the kernel will invoke the Out-of-Memory (OOM) killer to kill some process in the guest. * The <code>rss</code> soft limit is shown inside the guest as the maximum available memory. If a guest exceeds the <code>rss</code> soft limit, it will get an extra "bonus" for the OOM killer (proportional to the oversize). * If a guest exceeds the <code>as</code> hard limit, memory allocation attempts will return an error, but no process is killed. * The <code>as</code> soft limit is not in utilized until now. In the future it may be used to penalizing guests over that limit or it could be used to force swapping on them and such ... Bertl explained the difference between '''rss''' and '''as''' with the following example. If two processes share 100 MB of memory, then only 100 MB worth of virtual memory pages can be used at most, so the RSS use of the guest increases by 100 MB. However, two processes are using it, so the AS use increases by 200 MB. This makes me think that limiting AS is less useful than limiting RSS, since it doesn't directly reflect real, limited resources (RAM and swap) on the host, that deprive other virtual machines of those resources. Bertl says that AS limits can be used to give guests a "gentle" warning that they are running out of memory, but I don't know how much more gentle it is, or how to set it accurately. For example, 100 processes each mapping a 100 MB file would consume a total of 10 GB of address space (AS), but no more than 100 MB of resources on the host. But if you set the AS limit to 10 GB, then it will not stop one process from allocating 4 GB of RAM, which could kill the host or result in that process being killed by the OOM killer. You can set the hard limit on a particular context, effective immediately, with this command: <pre> /usr/sbin/vlimit -c <xid> --<resource> <value></pre> <xid> is the context ID of the guest, which you can determine with the <code>/usr/sbin/vserver-stat</code> command. For example, if you want to change the '''rss''' hard limit for the vserver with <xid> 49000, and limit it to 10,000 pages (40 MB), you could use this command: <pre> /usr/sbin/vlimit -c 49000 --rss 10000</pre> You can change the soft limit instead by adding the -S parameter. Changes made with the vlimit command are effective only until the vserver is stopped. To make permanent changes, write the value to this file: <pre> /etc/vservers/<name>/rlimits/<resource>.hard</pre> To set a soft limit, use the same file name without the <code>.hard</code> extension. The <code>rlimits</code> directory is not created by default, so you may need to create it yourself. Changes to these files take effect only when the vserver is started. To make immediate and permanent changes to a running vserver, you need to run vlimit '''and''' update the rlimits file. The safest setting, to prevent any guest from interfering with any other, is to set the total of all RSS hard limits (across all running guests) to be less than the total virtual memory (RAM and swap) on the host. It should be sufficiently less to leave room for processes running on the host, and some disk cache, perhaps 100 MB. However, this is very conservative, since it assumes the worst case where all guests are using the maximum amount of memory at one time. In practice, you can usually get away with contended resources, i.e. allowing guests to use more than this value. <div class="printfooter"> Retrieved from "http://wiki.linux-vserver.org/Memory_Limits" </div> <div class="visualClear"> </div> </div> </div>
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information