mod_rewrite and rewritemap efficiency

mod_rewrite and rewritemap efficiency

Post by lhfag.. » Thu, 17 Aug 2000 04:00:00



        Hi,
        I've developed a system in which all pages are dynamically
generated by a rewrite map program. This program verifies if the
requested page exists and, if it doesn't, writes the page, and always
remap the request to itself (don't change the request).
        I made this way because all pages have a part semi-dynamic
(dynamic, but are changed very seldom) and a part completely dynamic
(depends on user), so I use the rewrite map to generate a SSI that
includes the dynamic part, and when the semi-dynamic page changes, I
just delete it.
        My question is if this rewrite map is efficient, because after
restarting apache I noted that there is only one process of the map for
all apache's childs.
        Thanks.
        []s
        Luis

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

mod_rewrite and rewritemap efficiency

Post by Joshua Sliv » Thu, 17 Aug 2000 04:00:00



>         Hi,
>         I've developed a system in which all pages are dynamically
> generated by a rewrite map program. This program verifies if the
> requested page exists and, if it doesn't, writes the page, and always
> remap the request to itself (don't change the request).
>         I made this way because all pages have a part semi-dynamic
> (dynamic, but are changed very seldom) and a part completely dynamic
> (depends on user), so I use the rewrite map to generate a SSI that
> includes the dynamic part, and when the semi-dynamic page changes, I
> just delete it.
>         My question is if this rewrite map is efficient, because after
> restarting apache I noted that there is only one process of the map for
> all apache's childs.

Yes, the "program" type rewritemap is limited to processing one
request at a time (which is why it requires a RewriteLock), and
unlike the dbm and text rewritemap's, it cannot cache lookups.
whether this is a problem for you can only be determined
by testing your system under load.

However, you might find that you can get the same effect without
the rewritemap by just rewriting based on the %{REMOTE_USER}.
You don't give nearly enough details about your system to tell
whether this is possible.

--
Joshua Slive

http://finance.commerce.ubc.ca/~slive/

 
 
 

mod_rewrite and rewritemap efficiency

Post by lhfag.. » Thu, 17 Aug 2000 04:00:00




Quote:> Yes, the "program" type rewritemap is limited to processing one
> request at a time (which is why it requires a RewriteLock), and
> unlike the dbm and text rewritemap's, it cannot cache lookups.
> whether this is a problem for you can only be determined
> by testing your system under load.

        Caching won't be a problem, since I use a RewriteCond to verify if the
file exists, avoiding unnecessary rewrites based on the map. Efficiency
will probably be a problem, I made the system this way instead of
generating all pages dynamically to increase performance and stop server
crashes :-).
        One idea I had was to make more rewritemaps, using the same program
(symbolic links), and make a text map to remap randomly to one of the
processes... Any suggestions?
        Thanks,
        []s
        Luis

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

mod_rewrite and rewritemap efficiency

Post by Joshua Sliv » Thu, 17 Aug 2000 04:00:00



>    Caching won't be a problem, since I use a RewriteCond to verify if the
> file exists, avoiding unnecessary rewrites based on the map. Efficiency
> will probably be a problem, I made the system this way instead of
> generating all pages dynamically to increase performance and stop server
> crashes :-).
>    One idea I had was to make more rewritemaps, using the same program
> (symbolic links), and make a text map to remap randomly to one of the
> processes... Any suggestions?

Uggh.  It really sounds like you want to overcomplicate your life.
I am relatively confident that there are simpler ways of handling
your problem, but since you don't really specify what your problem is,
I obviously can't give any details.  I would consider going to
a full scripting language like PHP which can be very fast compared
to CGI scripts and will be much more flexible that any jurry-rigged
RewriteMap setup.

--
Joshua Slive

http://finance.commerce.ubc.ca/~slive/

 
 
 

mod_rewrite and rewritemap efficiency

Post by lhfag.. » Thu, 17 Aug 2000 04:00:00




Quote:> Uggh.  It really sounds like you want to overcomplicate your life.
> I am relatively confident that there are simpler ways of handling
> your problem, but since you don't really specify what your problem is,
> I obviously can't give any details.  I would consider going to
> a full scripting language like PHP which can be very fast compared
> to CGI scripts and will be much more flexible that any jurry-rigged
> RewriteMap setup.

        Yes, this solution sounds ugly... I'll describe the problem better:
        I have a site with a lot of news and articles. News are inserted hourly
and articles twice a day and there is about 60.000 pageviews a day. In
the footer of all pages is displayed the result of a search for related
articles and news... The database (that's being used by other sites too)
takes some time to make all the queries necessary to generate the pages,
and each page will be viewed a lot of times. In another site like this
one I made a system that generated static pages from a database if the
page does not exists, using a 404 handler. The solution I used in the
other site would do good, but every time an article is inserted, I'd
have to delete all the pages because of the search in the bottom of the
page. While there are hundreds of different pages, there are about 30
different footers, so I'd like all the pages to be .shtmls that includes
the footers, so when I insert a page, I have to delete only the footers.
        I've used PHP a lot and I like it, but I've already crashed this server
because semi-static pages where re-generated every request...
        When I said "depends on user", I should have said "changes every time",
sorry if I confused you :-).
        Thanks,
        []s

PS: I planned the system this way based on Vignette, that's being used
here to serve about 2.500.000 dynamic pages/day with a system much like
this (but I can't use it in this site).

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

mod_rewrite and rewritemap efficiency

Post by Joshua Sliv » Thu, 17 Aug 2000 04:00:00



>    Yes, this solution sounds ugly... I'll describe the problem better:
>    I have a site with a lot of news and articles. News are inserted hourly
> and articles twice a day and there is about 60.000 pageviews a day. In
> the footer of all pages is displayed the result of a search for related
> articles and news... The database (that's being used by other sites too)
> takes some time to make all the queries necessary to generate the pages,
> and each page will be viewed a lot of times. In another site like this
> one I made a system that generated static pages from a database if the
> page does not exists, using a 404 handler. The solution I used in the
> other site would do good, but every time an article is inserted, I'd
> have to delete all the pages because of the search in the bottom of the
> page. While there are hundreds of different pages, there are about 30
> different footers, so I'd like all the pages to be .shtmls that includes
> the footers, so when I insert a page, I have to delete only the footers.
>    I've used PHP a lot and I like it, but I've already crashed this server
> because semi-static pages where re-generated every request...
>    When I said "depends on user", I should have said "changes every time",
> sorry if I confused you :-).

Still uggh....

Solution 1: Well, I guess I still don't fully understand the problem.
What exactly changes on every request?  Why can't you just use
a CGI called by mod_rewrite (or ErrorDocument) to generate the documents
when required, and also write to disk an SSI document to use on future
requests?  Or alternatively, generate the document to disk as an SSI,
and then use a Location: header to make apache do a subrequest to grab it.

Solutions 2: Generate all the SSI documents using a seperate process
whenever you update content.  If you are confident that all the
documents are eventually going to be read, then you are just wasting
your browsers' time by waiting until they actually make a request
to generate the document.  Do it beforehand, and the responses will
be much quicker.

--
Joshua Slive

http://finance.commerce.ubc.ca/~slive/

 
 
 

mod_rewrite and rewritemap efficiency

Post by lhfag.. » Fri, 18 Aug 2000 04:00:00




Quote:> Still uggh....

> Solution 1: Well, I guess I still don't fully understand the problem.
> What exactly changes on every request?  Why can't you just use
> a CGI called by mod_rewrite (or ErrorDocument) to generate the
documents
> when required, and also write to disk an SSI document to use on future
> requests?  Or alternatively, generate the document to disk as an SSI,
> and then use a Location: header to make apache do a subrequest to grab
it.

        I think the first solution solves the problem, I'll try that one. I
just have to make the CGI emulate a SSI (getting the document on disk or
calling itself to generate it). Other thing it's good to remember (if I
use errordocument) is to send a Status: 200 header to make correct logs
(for anyone that liked this idea and wants to implement it :-) ).
        Generating the document to disk and using a Location: won't work, I've
already tested it. Sometimes (it happened always in ns and sometimes in
ie) the browser generates an error, because it thinks its an infinite
loop, since the Location: sends to the same location.
        The part that changes in every time is the search... not every request,
but very often.

Quote:> Solutions 2: Generate all the SSI documents using a seperate process
> whenever you update content.  If you are confident that all the
> documents are eventually going to be read, then you are just wasting
> your browsers' time by waiting until they actually make a request
> to generate the document.  Do it beforehand, and the responses will
> be much quicker.

        I could do this using a robot like htdig, this way I do not need to
change anything. But although all pages will be going to be read, some
of them will change before being read, and the most read pages must be
generated first, because the process of generating them will take some
time... I think it can be a good idea, but generating on request is
better.
        Thanks
        []s
        Luis

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. Help with mod_rewrite and rewritemap

My site has some filenames with 2 or more spaces.
Some search engines substitute them with some + but in this way their
request can't reach the pages.
I am trying to use mod_rewrite to change the request substituting the
filename with + with the filename with %20.
I am trying to use a rewrite map but I'm not able to make it work.
This is what I wrote in the httpd.conf:

RewriteEngine On
RewriteLog "/home/mhd/rewrite.log"
RewriteLogLevel 9
RewriteMap berno     txt:/home/mhd/map.txt
RewriteRule ^/home/mhd/prova/www.domain.it/htdocs/(.*)
/home/mhd/prova/www.domain.it/htdocs/${berno:$1|$1}

In the map I put only a trial substitution such as:
pippo+prova.html   pippo%20prova.html

The log gave me this report:

init rewrite engine with requested uri /default.ida
applying pattern '^/home/mhd/prova/www.domain.it/htdocs/(.*)' to uri
'/default.ida'
pass through /default.ida

What is my mistake ?

2. Very weird Netscape problem

3. mod_rewrite - ReWriteMap - Based on keywords

4. Alpha & UNIX

5. mod_rewrite: RewriteMap & HTTP_USER_AGENT

6. Compilation Error: variable has intializer but incomplete type

7. mod_rewrite RewriteMap lock error

8. ttsession workaround besides secure rpc?

9. mod_rewrite - ReWriteMap - Based on keywords

10. Matrox Mystique ands X.

11. rewriteMap in apache dies when mysql used..? help!

12. Help with RewriteMap, and Conditions

13. Apache RewriteMap