Solved

How do i could limit memory use to an service?

Posted on 2010-09-10
5
1,538 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

717 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