LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 02-10-2010, 11:31 AM   #1
Rundi
Member
 
Registered: Jun 2003
Location: USA
Distribution: Ubuntu
Posts: 169

Rep: Reputation: 30
Question Limit User Processes


I have some domains on a VPS server. Typical account memory usage for all domains runs at 50% of available, but I have a problem. One domain is causing me trouble because intermittently traffic will spike on that domain, causing so many requests within 1 min that I exceed my memory allocation for my entire VPS package. Apache is then killed but the virtualization software and Apache must then be restarted. A sample snippet from tops right before the sever went down would like like this:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27816 coldclim 18 0 39524 26m 5880 R 3.7 5.1 0:00.77 php
27710 coldclim 18 0 34876 21m 5592 R 2.3 4.2 0:00.40 php
27850 coldclim 18 0 29444 15m 5432 R 1.1 3.1 0:00.25 php
27860 coldclim 17 0 32412 18m 5516 R 1.1 3.7 0:00.33 php
27858 coldclim 18 0 35136 21m 5592 R 0.8 4.2 0:00.42 php
27987 coldclim 17 0 21028 5556 3232 R 0.8 1.1 0:00.03 php
27856 coldclim 18 0 32420 18m 5516 R 0.6 3.7 0:00.34 php
27947 coldclim 16 0 25804 12m 5432 R 0.6 2.4 0:00.13 php
27958 coldclim 16 0 25544 12m 5432 R 0.6 2.4 0:00.12 php
27960 coldclim 16 0 24104 10m 5376 R 0.6 2.1 0:00.10 php
27962 coldclim 18 0 27884 14m 5432 R 0.6 2.8 0:00.19 php
27854 coldclim 18 0 34880 21m 5592 R 0.3 4.1 0:00.40 php
27830 coldclim 18 0 36176 22m 5732 R 0.0 4.4 0:00.50 php
27831 coldclim 18 0 32932 19m 5528 R 0.0 3.8 0:00.35 php
27851 coldclim 18 0 32412 18m 5524 R 0.0 3.7 0:00.34 php
27852 coldclim 18 0 29176 15m 5432 R 0.0 3.1 0:00.24 php
27855 coldclim 18 0 27612 14m 5432 R 0.0 2.8 0:00.18 php
27857 coldclim 18 0 31364 17m 5496 R 0.0 3.5 0:00.29 php
27861 coldclim 18 0 24500 11m 5428 R 0.0 2.2 0:00.11 php
27862 coldclim 18 0 30848 17m 5476 R 0.0 3.4 0:00.28 php
27956 coldclim 18 0 25800 12m 5432 R 0.0 2.4 0:00.14 php
27961 coldclim 18 0 22400 8440 4584 R 0.0 1.6 0:00.04 php
27973 coldclim 18 0 24376 10m 5388 R 0.0 2.1 0:00.09 php
27974 coldclim 18 0 23188 9204 4900 R 0.0 1.8 0:00.05 php

All of that memory usage adds up. I would like to "throttle" the number of processes that user/domain can run. I think this would be a quick and easy way to keep the domain from taking down my entire VPS. My understanding is that I could do this with the /etc/security/limits.conf file.

Is that correct?

I have never done this before. Do I want to set a hard or soft limit? I think if I wanted to limit the number of processes for "coldclim" to 15 I would add a line to limits.conf like this:
Code:
coldclim  hard  nproc 15
Assuming that is correct, can anyone tell me how the website would respond once it reached its limit? Would visitor queries become sluggish, or would the website not come up for them at all?

Thanks for the help!
 
Old 02-10-2010, 12:05 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
If it's exhausting the memory of the server your maxclients is probably set to high or you need to do some optimizations to get rid of modules you don't need to lower the memory foot print. You could also probably optimize and limit php a bit further if you cared to.

As far as your limits.conf entry goes that looks correct provided the full username in /etc/passwd (or whatever pam is authenticating off of) is coldclim. A hard limit is enforced by the kernel, any attempt to exceed it will fail. The exact behavior would be determined by your apache settings (like is keepalive off or on, etc.) That being said, it's going to prevent the site from being viewed at some level.

Last edited by rweaver; 02-10-2010 at 12:07 PM.
 
Old 02-10-2010, 12:54 PM   #3
Rundi
Member
 
Registered: Jun 2003
Location: USA
Distribution: Ubuntu
Posts: 169

Original Poster
Rep: Reputation: 30
Adjusting maxclients is another way to go about it, but my understanding is that maxclients limits *all* the domains on the VPS, not just the one domain. Since the other domains are run under other users my idea was to use the limits.conf to selectively limit the one domain which is being a hog and leave the others alone.

. . . the troublesome domain is a website of my Mom's and I am getting tired of troubleshooting stuff all the time for her, so I am looking for a simple way to keep her "mess" boxed in so as to not take the rest of the server down.
 
Old 02-10-2010, 01:54 PM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
The maxclients setting determines the maximum number apache can spawn.

Lets say all the sites you host have a 75% increase in traffic and that puts them on par with the traffic this one site gets but none of them high enough to be effected by the limits... the server will still crash.

Your maxclients is to high for the amount of ram you have, so when you reach that top end there are more clients being spawned than you have memory to work with, it starts to swap, and eventually crashes once the iowait reaches absurd amounts.

Take a look at this:
http://2bits.com/articles/tuning-the...parameter.html

This is an entirely different issue from limiting via limits.conf

Placing a hard limit via the limit.conf prevents one user from 'stealing' others resources in a shared environment. Having a limit that is to high for maxclients means that your server will crash under load (even if its spread over all the users so that none are reaching a hard limit) rather than just slow down.

You've got two issues: One a user who utilizes more resources than you find acceptable (hard limits fix that), and two your maxclients is too high for the amount of ram in the system (thus just setting a hard limit for one user will just offload the problem temporarily until another site spikes in traffic, even if you set it for all the sites if you had enough traffic spread over them all the problem would still occur).

Last edited by rweaver; 02-10-2010 at 01:58 PM.
 
1 members found this post helpful.
Old 02-10-2010, 02:08 PM   #5
Rundi
Member
 
Registered: Jun 2003
Location: USA
Distribution: Ubuntu
Posts: 169

Original Poster
Rep: Reputation: 30
Okay, yes. That makes sense. I will need to do both. Thanks for the link.
 
  


Reply

Tags
limit, processes, ulimit, user


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit amount of unix sockets used by processes MikeyCarter Linux - Server 1 04-01-2009 03:07 AM
ulimit: max user processes: cannot modify limit: Operation not permitted farnaw4u Linux - Newbie 3 04-21-2008 06:32 AM
limit processes for each user jackripper2988 Slackware 1 03-17-2006 01:32 AM
How do I limit the amount of processes a user can run? houler Slackware 26 04-04-2005 08:02 PM
Limit the number of background processes per user... trendwhore Linux - Security 6 08-27-2004 01:09 PM


All times are GMT -5. The time now is 10:26 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration