Solved

How do i could limit memory use to an service?

Posted on 2010-09-10
5
1,526 Views
Last Modified: 2013-12-16
How do i could limit memory use to an service?.

%MEM of service/ process "drwebd.real" in my linux box its always  around 85-90%...

  PID USER      PR  NI  VIRT  RES  SHR S %CPU     %MEM    TIME+  COMMAND
16097 drweb     16   0 1947m 1.8g  440 D  5.6      90.0   1:03.10 drwebd.real


thanks
0
Comment
Question by:VMWARE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 500 total points
ID: 33645761
Hi,
you could try to set the "memory" ulimit for the user "drweb" before starting "drwebd.real". Create a script, if needed, containing the "ulimit" command and the call to "drwebd.real".
As an alternative you could set this value permanently and globally for user "drweb" in /etc/security/limits.conf.
Display all settings with
ulimit -a
and change the "memory" limit by issuing
ulimit -m new_value_in_kilobytes
wmp
0
 

Author Comment

by:VMWARE
ID: 33646200
Hello woolmilkporc,

How do I for  that user "drweb", was limited to 75% of maximum memory, using the second option?

Thanks
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33646637
To avoid a possible misunderstanding - there is no limit controlling total memory available to all processes belonging to one user!
The virtual memory limit is enforced per process only!
Anyway, to limit the processes started by drweb to "see" only 75% of memory each, add to /etc/security/limits.conf (as root)
drweb     hard     as    (75%_of_memory_in_kilobytes)
drweb     soft      as    (75%_of_memory_in_kilobytes)
This sets both the initial value (soft) as well as the limit up to which the user can change this value by means of "ulimit (hard).
 Remeber to logout and re-login as drweb, once this setting has been changed by root in limits.conf!
0
 

Accepted Solution

by:
VMWARE earned 0 total points
ID: 33657592
Hello woolmilkporc,

could be something of that sort?

drweb           hard                    1572864 (75% of 2GB)
drweb           soft                    1572864

after, its enought restart the service drwebd as root?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33657914
Nearly!

drweb           hard            as      1572864
drweb           soft              as      1572864

"as" means "address space" and has to appear literally!

And the first column indicates the userid which is the owner of the process! So "restart the service drwebd as root" sounds a bit strange, since the "ps" output you posted in your question indicates "drweb" as the owner of "drwebd.real"!

The "normal" procedure would consist in starting the process as user "drweb" after a fresh login.

OK, it might be that you actually start drwebd as root and the script/program involved would do a switch to the "drweb" userid. If this is the case you can only try out if it works, because I don't know whether you OS will indeed respect the limit settings of the target userid in such a case - but I think it will.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question