Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite .htaccess - very slow

Since moving to a new dedicated server

         

Alternative Future

12:22 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi to the forum,

Since moving to a new dedicated server from a shared host, new server details below:
Operating System** Linux: CentOS
RAM: 1500MB

There has been a significant decrease in performance when clicking on any of my links which are in a subdirectory i.e. domain.com/subdir1/customer_number.html (5 to 8 seconds) to when I use domain.com/execute/nav/navigate?cmd=getClient&customer_number=number it happens immediately less than a second.

My .htaccess contained in /www/subdir1 is
RewriteEngine on
RewriteRule ^(.*)$ /execute/nav/navigate?cmd=getClient&customer_number=$1 [L]

I was wondering if it might be best to move this rule to the root dir /www and if this would assist any? or are there any other suggestions that it might be worth my while looking at? Or should this be expected with the above server?

TIA,

-George

[edited by: Alternative_Future at 12:38 pm (utc) on May 11, 2008]

jdMorgan

2:21 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is nothing in that rule to stop internal recursion. Do things improve if you modify the rule like so:

RewriteCond $1 !^execute/nav/navigate
RewriteRule (.*) /execute/nav/navigate?cmd=getClient&customer_number=$1 [L]

Also, what is your directory structure? Where is "/navigate" in relation to /subdir1?

If you're on a dedicated server, you should have the option to enable rewrite logging. Examining those log files may be very helpful in debugging this problem.

Jim

Alternative Future

2:39 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jim,

Thanks so much for your assistance :)

I tried your suggest change but with no effect, not sure if that was taking slightly longer i.e. 1 second - currently I am using my wrist watch / system clock to do the time report is there a better tool out there that I should use?

My site uses Java & Struts and the path is from the struts-config.xml forwarding name path i.e.

web.xml
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
[..]

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/execute/*</url-pattern>
</servlet-mapping>
[..]

This part builds up the /execute/ part of the URL

struts-config.xml
<global-forwards>
<action path="/nav/navigate" type="com.shn.website.application.NavDispatchAction"
name="navFB" scope="request"
validate="false" parameter="cmd">
</action>

This part builds of the second part of the URL /execute/nav/navigate/

NavDispatchAction.java
public ActionForward getClient(ActionMapping mapping[..]

And this part builds up the remaining part of the URL after navigate? this method expects the parameter of customer_number

I will request for rewrite logging to be switched on from my hosts immediately. But in the meantime going by current time delays in the host getting back to me is there anything else I could start to look at?

Once again Jim and others your time is really appreciated.

-George

[edited by: Alternative_Future at 2:41 pm (utc) on May 11, 2008]

jdMorgan

3:25 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suspect internal recursion in this case, but while you're waiting, you might want to look at the interaction between client and server by using the "Live HTTP Headers" add-on to Firefox/Mozilla -- Look for signs of a redirection loop. I don't expect you'll see such external recursion, but you never know.

Unless you have more than 500 rewrite rules, you should never notice *any* perceptible delay due to mod_rewrite on a dedicated server -- at least not until you're getting several dozen client requests per second...

Jim

Alternative Future

3:26 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have now managed to get into my httpd.conf file and have the following:

Include "/usr/local/apache/conf/includes/pre_main_global.conf"
Include "/usr/local/apache/conf/includes/pre_main_2.conf"

LoadModule auth_passthrough_module modules/mod_auth_passthrough.so
LoadModule bwlimited_module modules/mod_bwlimited.so
LoadModule frontpage_module modules/mod_frontpage.so

Include "/usr/local/apache/conf/php.conf"
Include "/usr/local/apache/conf/modsec2.conf"

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
UseCanonicalName Off
AccessFileName .htaccess
DefaultType text/plain
HostnameLookups Off
ErrorLog logs/error_log
ServerTokens Full
AliasMatch ^/manual(?:/(?:de¦en¦es¦fr¦ja¦ko¦ru))?(/.*)?$ "/usr/local/apache/manual$1"

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
ForceLanguagePriority Prefer

The only thing relating to mod_rewrite in there i can find is AccessFileName .htaccess

Is this correctly setup?

Once again thanks,

-george

Alternative Future

3:45 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>Unless you have more than 500 rewrite rules, you should never notice *any* perceptible delay due to mod_rewrite on a dedicated server -- at least not until you're getting several dozen client requests per second...

No more than 500 rewrite rules in place and that’s totalling up all .htaccess files in place - I would assume you talk about one instance of the .htaccess for this anyway? At this moment there is no where near several dozen client requests. The response back from support was:
Also please note that shared server having powerful CPU and a lot of Memory

>>Look for signs of a redirection loop. I don't expect you'll see such external recursion, but you never know.

No doesnt look like it, just a request for each image in place and a request for my adsense. But nothing repeating itself.

Thx,

-george

jdMorgan

3:56 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This line has the potential to be recursive, depending on the DocumentRoot declaration, which you didn't show:

AliasMatch ^/manual(?:/(?:deŠenŠesŠfrŠjaŠkoŠru))?(/.*)?$ "/usr/local/apache/manual$1"

If DocumentRoot is /usr/local/apache/, then this directive could recurse.

Jim

Alternative Future

4:12 pm on May 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this the document root settings you are talking about?

<VirtualHost ip.ip.ip.ip:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /home/domain/public_html
ServerAdmin webmaster@domain.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/domain.com combined
CustomLog /usr/local/apache/domlogs/domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User domain # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup username username
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup username username
</IfModule>
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/

</VirtualHost>

Sorry first time I have used nano and didn't realise there was other pages lol

-Gs

Alternative Future

4:02 pm on May 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jim,

Thanks for your help, turned out to be the apache settings my host had set up was wrong.

-Gs