homepage Welcome to WebmasterWorld Guest from 54.196.194.204
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
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?
Karma




msg:4375939
 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!

 

robzilla




msg:4375998
 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.

rocknbil




msg:4376011
 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