homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

How to use less server memory?

5+ Year Member

Msg#: 4375937 posted 2:22 pm on Oct 18, 2011 (gmt 0)

I've been advised by my hosting company that my site is almost hitting the max amount ram (1gb).

My site is self-built so there is probably potential for optimization here, but where should I start looking - any common mistakes? Any way I can find out what is using so much?

Any advice greatly appreciated!



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4375937 posted 4:01 pm on Oct 18, 2011 (gmt 0)

If this is a Linux box, using the
top command from the shell will tell you which processes are hogging your memory (press the < or > on your keyboard until the list is sorted by %MEM). First and foremost, look carefully for processes you don't need, and disable those. Then monitor the process list for a while to see if there are any processes that take up a disproportionate amount of memory. Also check your cron tab for any jobs that are non-essential.

If you tell us a bit more about the server and website environment, we might be able to look into this in more detail.


WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4375937 posted 4:28 pm on Oct 18, 2011 (gmt 0)

Are you doing this, or something like it?

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?variable=$1

What is happening here is it searches the entire file system twice and is extremely resource intensive. See post #4274745 in this thread [webmasterworld.com] for one efficient way to fix this. It's a pretty good place to start. :-)

The "cliff notes" of the solution is stupidly simple. Nearly all of your files - images, css, javascript - will have a dot. Your page requests probably won't (or shouldn't, or may be restricted to .html or whatever.) So if it doesn't have a dot, do the rewrite.

RewriteRule ^([^.]+)$ /index.php?variable=$1 [L,QSA]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved