Results 1 to 8 of 8
  1. #1

    Can .htaccess use high CPU usage?

    I need to know if hotlink protection in .htaccess can made high CPU usage?

    I had photoblog using wordpress, Hostgator shared hosting, had 15,000+ files, 1,300 visitors per day and 300,000+ page views per month.

    Below is my original .htaccess

    Code:
    order deny,allow
    allow from 60.52.20.216
    deny from all
    
    
    <IfModule mod_deflate.c>
        <IfModule mod_setenvif.c>
            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
            BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
        </IfModule>
        <IfModule mod_headers.c>
            Header append Vary User-Agent env=!dont-vary
        </IfModule>
        AddOutputFilterByType DEFLATE text/css application/x-javascript text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
    </IfModule>
    <FilesMatch "\.(css|js)$">
        FileETag None
        <IfModule mod_headers.c>
             Header set X-Powered-By "W3 Total Cache/0.9.1.3"
        </IfModule>
    </FilesMatch>
    <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$">
        FileETag None
        <IfModule mod_headers.c>
             Header set X-Powered-By "W3 Total Cache/0.9.1.3"
        </IfModule>
    </FilesMatch>
    <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
        FileETag None
        <IfModule mod_headers.c>
             Header set X-Powered-By "W3 Total Cache/0.9.1.3"
        </IfModule>
    </FilesMatch>
    # END W3TC Browser Cache
    
    # BEGIN W3TC Page Cache
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{HTTP_USER_AGENT} (2\.0\ mmp|240x320|alcatel|amoi|asus|au\-mic|audiovox|avantgo|benq|bird|blackberry|blazer|cdm|cellphone|danger|ddipocket|docomo|dopod|elaine/3\.0|ericsson|eudoraweb|fly|haier|hiptop|hp\.ipaq|htc|huawei|i\-mobile|iemobile|j\-phone|kddi|konka|kwc|kyocera/wx310k|lenovo|lg|lg/u990|lge\ vx|midp|midp\-2\.0|mmef20|mmp|mobilephone|mot\-v|motorola|netfront|newgen|newt|nintendo\ ds|nintendo\ wii|nitro|nokia|novarra|o2|openweb|opera\ mobi|opera\.mobi|palm|panasonic|pantech|pdxgw|pg|philips|phone|playstation\ portable|portalmmm|ppc|proxinet|psp|pt|qtek|sagem|samsung|sanyo|sch|sec|sendo|sgh|sharp|sharp\-tq\-gx10|sie|small|smartphone|softbank|sonyericsson|sph|symbian|symbian\ os|symbianos|toshiba|treo|ts21i\-10|up\.browser|up\.link|uts|vertu|vodafone|wap|willcome|windows\ ce|windows\.ce|winwap|xda|zte) [NC]
        RewriteRule .* - [E=W3TC_UA:_low]
        RewriteCond %{HTTP_USER_AGENT} (acer\ s100|android|archos5|blackberry9500|blackberry9530|blackberry9550|cupcake|docomo\ ht\-03a|dream|htc\ hero|htc\ magic|htc_dream|htc_magic|incognito|ipad|iphone|ipod|lg\-gw620|liquid\ build|maemo|mot\-mb200|mot\-mb300|nexus\ one|opera\ mini|samsung\-s8000|series60.*webkit|series60/5\.0|sonyericssone10|sonyericssonu20|sonyericssonx10|t\-mobile\ mytouch\ 3g|t\-mobile\ opal|tattoo|webmate|webos) [NC]
        RewriteRule .* - [E=W3TC_UA:_high]
        RewriteCond %{HTTPS} =on
        RewriteRule .* - [E=W3TC_SSL:_ssl]
        RewriteCond %{SERVER_PORT} =443
        RewriteRule .* - [E=W3TC_SSL:_ssl]
        RewriteCond %{HTTP:Accept-Encoding} gzip
        RewriteRule .* - [E=W3TC_ENC:.gzip]
        RewriteCond %{REQUEST_METHOD} !=POST
        RewriteCond %{QUERY_STRING} =""
        RewriteCond %{REQUEST_URI} \/$
        RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php) [NC,OR]
        RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
        RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in) [NC]
        RewriteCond "/home/xenoriz/public_html/wp-content/w3tc/pgcache/$1/_index%{ENV:W3TC_UA}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" -f
        RewriteRule (.*) "/wp-content/w3tc/pgcache/$1/_index%{ENV:W3TC_UA}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]
    </IfModule>
    # END W3TC Page Cache
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPressRewriteCond %{HTTP_REFERER} !^$
    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>
    Then below it i added 52 lines of hotlink protection, my site and all google reader link.

    First time, hostgator blocked my site because of high cpu usage, no ticket, i remove the hotlink protection and ask live chat to unblock my site, done in 3 minutes. Everything back to normal.

    Because I though there are something wrong with my codes, day later i use cpanel function for hotlink protection. Amazingly the code that cpanel generate are exactly same. I tried it again.

    - NOW, my site blocked again with TICKET. The ticket send at Mar 06, 4:28 AM. - The admin told me that i got to many visitor, to many number of request, and advice me to change to VPS.

    - I replied it after 8 minutes : I told them just unblocked my site, I will disable the hotlink protection and I'm sure it will back to normal.

    ......

    - No reply in 4 hours - i ask live chat and he said will be fixed asap.

    .....

    - Admin reply after 2 hours at 10:34 AM , I sleep at the time (Asia time) - this what he said

    Code:
    This wasn't caused by hotlinking protection; please ensure you do not use any relative links, like h**p://server/image.jpg on your site, just absolute links like /path/to/images. I have enabled access for your IP, please ensure you resolve this matter and let us know once you have done so.
    The problem now, how can i change all the link? I already made 500+ post, there are some post that use relative link like " This is Hwang Mi Hee at SAS 2011 part 2, for part 1 please click here" . It been like this for 4 months, why until now suddenly this link cause high cpu usage?

    Are the problem really because of the relative link? or because of .htaccess?

    Not much help from hostgator, today i talk to 2 live chat first seem really want to help me, tried to get the admin to look at my ticket, once he said there are admin will look at the problem in any minute, i just so happy. BUT after 2 hours.. nothing happen, I talk to 2nd person, tell him about what the 1st person said, and guess what? he said there are no admin today until tomorrow morning!!!!!!!! I think i just got owned.

    I already disable the hotlink protection, removed the code, I just want them to check it by unblocked my site, and see what happen.. that all. It's been 18 hours already since my site blocked.

    Please help, thank you. I need to be ready for tomorrow

  2. #2
    Join Date
    Aug 2009
    Location
    Montreal
    Posts
    1,606
    Did they mention how much cpu your account was using?
    CrocWeb :: Canadian Web Hosting
    Accelerate your website, maximum performance!
    www.crocweb.com :: Since 2009 (Montreal, Quebec)

  3. #3
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    10,482
    Hotlinking would only really affect the bandwidth aspects not the CPU
    l Dedigeeks (Twitter) Shared Reseller Cloud VPS Since 2010
    l Leading AU Hosting Provider Multiple locations - around the globe!
    l cPanel/WHM R1Soft Backups 24/7/365 Support 99.9% Uptime Guarantee
    l www.yourcompanynamehere.com Customer Service Rep. Superior Service Guarantee

  4. #4
    Quote Originally Posted by CrocWeb View Post
    Did they mention how much cpu your account was using?
    Nope, i just saw it from CPanel, sometime it going up to 40% , Oh well from the first ticket, he mention it not because of CPU usage but traffic. Honestly no spike in traffic for 2 days, but each time i activate the hotlink protection my running process gone to max 20-25/25, cpu usage max up to 35%, memory up to 8%-13%

  5. #5
    Join Date
    Feb 2011
    Posts
    38
    Using "http://www.domain.com/dir/file.ext" vs "/dir/file.ext" wont make any major difference for CPU usage; especially if its just a link like <a href="..."></a>

    That, and the admin doesn't even know the difference between relative and absolute linking.
    "dir/dir/file.ext" is relative. Without a / it goes from whatever directory its calling from.
    "/dir/dir/file.ext" is absolute. It goes from root
    "http://www.domain.com/dir/dir/file.ext" is a URL.


    Now, to be helpful... Htaccess can in certain cases cause problems. Everytime a file is loaded it will check it against the htaccess. If you need to block hotlinkers, then you can make a script that is required to call the images. If anyone tries to directly link to an image, you can use htaccess to rewrite to the scripted link.

  6. #6
    Join Date
    Apr 2009
    Location
    USA / UK
    Posts
    4,553
    Quote Originally Posted by Shamun View Post
    Now, to be helpful... Htaccess can in certain cases cause problems. Everytime a file is loaded it will check it against the htaccess. If you need to block hotlinkers, then you can make a script that is required to call the images. If anyone tries to directly link to an image, you can use htaccess to rewrite to the scripted link.
    Firing up a cgi/php/whatever program/script to serve up your images will use far more server resources than simple .htaccess ever would.

    And relative vs absolute links would make no difference at all. The only way links would affect performance is if you are doing a lot of redirections (301/302) or linking to inline elements that don't exist (lots of 404's in the background when a page loads).

    Either you misquoted their response out of context or that person has no idea what they are talking about.

    You should ask for a list of URL's that are causing the problem - might help you track down what they find objectionable.

    Or, if I were you, just move to a host that offers reasonable resources for a reasonable price instead of unlimited everything that you can't ever use like it appears hostgator and many other unlimited hosts do. Unlimited hosts are never a good idea in the long run.
    RAM Host -- Premium & Budget Linux Hosting From The USA & EU
    █ Featuring Powerful cPanel CloudLinux Shared Hosting
    █ & Cheap Premium Virtual Dedicated Servers
    Follow us on Twitter

  7. #7
    Join Date
    Mar 2003
    Location
    WebHostingTalk
    Posts
    16,963
    Moved > Hosting Security and Technology.
    Specially 4 You
    .
    JoneSolutions.Com ( Jones.Solutions ) is on the net 24/7 providing stable and reliable web hosting solutions and services since 2001

  8. #8
    Thanks all for the reply, my site back online, the admin gave me 3 advice, subdomain for images, self hosting cdn or cloudflare, took time for noob like me to learn them. Now i disable the hotlink protection, site back to normal, 0.2% CPU and 2 max process.

    I had to many static images, like "ramnet" said, I may need to upgrade from shared hosting.

Similar Threads

  1. Need help optimizing server, High load, high CPU usage
    By chasebug in forum Hosting Security and Technology
    Replies: 2
    Last Post: 10-17-2009, 08:38 AM
  2. High CPU usage
    By AustinS in forum Hosting Security and Technology
    Replies: 4
    Last Post: 10-08-2009, 04:19 AM
  3. CPU Usage way too high
    By smoked1 in forum Dedicated Server
    Replies: 2
    Last Post: 09-13-2007, 07:25 AM
  4. High CPU usage
    By Rafal_A in forum Hosting Security and Technology
    Replies: 1
    Last Post: 04-04-2006, 03:42 PM
  5. High Cpu Usage!!
    By lokodezine in forum Web Hosting Lounge
    Replies: 8
    Last Post: 11-07-2003, 10:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •