You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Perrin Harkins <pe...@elem.com> on 2005/08/31 05:55:31 UTC

Re: maintaining shared memory size

Badai Aqrandista wrote:
> My app is an online hotel booking system. That part is the part where it 
> searches availabilities through all combination of dates, number of 
> guests, rooms, packages, allotments, pricing structures, and more.

Okay, so it's slow because it does a lot of work.  How does it do this 
search?  Is it a bunch of SQL queries, or a request to a remote server 
of some other kind, or an internal calculation?  Is there some possible 
caching you can do?

> I must admit there is too much to handle in one mod_perl process. But I 
> don't know any better way to design and code it. In the future, I'll 
> probably move that search feature to a new process, so all the 
> combinations can be calculated in parallel.

I would probably use some sort of queue system here.  I would have the 
mod_perl process push requests onto a queue (probably in a database) and 
then have a separate daemon, maybe on a different machine, do the work 
and return the answer.  It would allow you to split the search into 
multiple pieces that happen in parallel, and handle them on multiple 
machines simultaneously.  It would also separate the web request, which 
is fast, from the slow search request.  That lets your server scale to 
handling many more clients at once, even though some of them are just 
waiting for their turn.

For a simpler version that just forks and does the search on the same 
machine, see this article by Randal:
http://www.stonehenge.com/merlyn/LinuxMag/col39.html

- Perrin

Re: maintaining shared memory size

Posted by Badai Aqrandista <ba...@hotmail.com>.
> > POE sounds good to start with, right?
>
>For a daemon to monitor a queue?  Probably not.  I'd just write a simple
>script that polls a database table and forks a new process to handle any
>jobs it finds.  Parallel::ForkManager is handy for this kind of thing.

Yes. POE looks overkill compare to Parallel::ForkManager.

Thanks.

---
Badai Aqrandista
Cheepy (?)

_________________________________________________________________
Low rate ANZ MasterCard. Apply now! 
http://clk.atdmt.com/MAU/go/msnnkanz0030000006mau/direct/01/  Must be over 
18 years.


Re: maintaining shared memory size

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-08-31 at 14:13 +1000, Badai Aqrandista wrote:
> Lots of SQL queries and calculation based on the query results. I've cached 
> most of the query results, but the calculation results can't be cached 
> because they depend on user inputs.

If this is serious number-crunching, it might be one of the few times
where using C really does make sense for that part.

> POE sounds good to start with, right?

For a daemon to monitor a queue?  Probably not.  I'd just write a simple
script that polls a database table and forks a new process to handle any
jobs it finds.  Parallel::ForkManager is handy for this kind of thing.

- Perrin


Re: maintaining shared memory size

Posted by Badai Aqrandista <ba...@hotmail.com>.
>
>Okay, so it's slow because it does a lot of work.  How does it do this 
>search?  Is it a bunch of SQL queries, or a request to a remote server of 
>some other kind, or an internal calculation?  Is there some possible 
>caching you can do?
Lots of SQL queries and calculation based on the query results. I've cached 
most of the query results, but the calculation results can't be cached 
because they depend on user inputs.

>I would probably use some sort of queue system here.  I would have the 
>mod_perl process push requests onto a queue (probably in a database) and 
>then have a separate daemon, maybe on a different machine, do the work and 
>return the answer.  It would allow you to split the search into multiple 
>pieces that happen in parallel, and handle them on multiple machines 
>simultaneously.  It would also separate the web request, which is fast, 
>from the slow search request.  That lets your server scale to handling many 
>more clients at once, even though some of them are just waiting for their 
>turn.
Good idea!!! Thanks... You've been a great help...
POE sounds good to start with, right?

---
Badai Aqrandista
Cheepy (?)

_________________________________________________________________
Dating? Try Lavalife – get 7 days FREE! Sign up NOW. 
http://www.lavalife.com/clickthru/clickthru.act?id=ninemsn&context=an99&a=20233&locale=en_AU&_t=33473