Re: [Catalyst] May be asynchronous communication between Catalyst applications
here is the script which start [info] Srvm powered by Catalyst 5.90019 2013/03/05-15:53:51 Starman::Server (type Net::Server::PreFork) starting! pid(4862) Resolved [*]:3000 to [0.0.0.0]:3000, IPv4 Binding to TCP port 3000 on host 0.0.0.0 with IPv4 Setting gid to "0 0 0 1 2 3 4 6 10" Starman: Accepting connections at http://*:3000/ On Tue, Mar 5, 2013 at 3:53 PM, linuxsupport wrote: > To make things simple, I created following methods using REST action class. > > Once, I call srv_setup it returns me "ok" quickly > after that If I can srv_status or srv_setup, it goes on wait until that > sleep 1000, finishes > > sub srv_setup :Local :ActionClass('REST') { >my ($self, $c) = @_; >$c->run_after_request( > sub { sleep 1000; } >); > } > > sub srv_setup_GET { >my ($self, $c) = @_; >$self->status_ok($c, entity => "ok"); > > } > > sub srv_status :Local :ActionClass('REST') { >my ($self, $c) = @_; > } > > sub srv_status_GET { >my ($self, $c) = @_; >$self->status_ok($c, entity => 'progress'); > > } > > On Tue, Mar 5, 2013 at 12:16 AM, Tomas Doran wrote: > >> >> On 4 Mar 2013, at 17:14, linuxsupport wrote: >> >> > Yes, I know that and tried with -f option, but result was same. >> >> No other ideas. Some code you haven't shown us doesn't work as you expect >> - we can't really do anything other than guess at this point :) >> >> Cheers >> t0m >> >> >> ___ >> List: Catalyst@lists.scsys.co.uk >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >> Searchable archive: >> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ >> Dev site: http://dev.catalyst.perl.org/ >> > > ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
To make things simple, I created following methods using REST action class. Once, I call srv_setup it returns me "ok" quickly after that If I can srv_status or srv_setup, it goes on wait until that sleep 1000, finishes sub srv_setup :Local :ActionClass('REST') { my ($self, $c) = @_; $c->run_after_request( sub { sleep 1000; } ); } sub srv_setup_GET { my ($self, $c) = @_; $self->status_ok($c, entity => "ok"); } sub srv_status :Local :ActionClass('REST') { my ($self, $c) = @_; } sub srv_status_GET { my ($self, $c) = @_; $self->status_ok($c, entity => 'progress'); } On Tue, Mar 5, 2013 at 12:16 AM, Tomas Doran wrote: > > On 4 Mar 2013, at 17:14, linuxsupport wrote: > > > Yes, I know that and tried with -f option, but result was same. > > No other ideas. Some code you haven't shown us doesn't work as you expect > - we can't really do anything other than guess at this point :) > > Cheers > t0m > > > ___ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
On 4 Mar 2013, at 17:14, linuxsupport wrote: > Yes, I know that and tried with -f option, but result was same. No other ideas. Some code you haven't shown us doesn't work as you expect - we can't really do anything other than guess at this point :) Cheers t0m ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
Yes, I know that and tried with -f option, but result was same. On Mon, Mar 4, 2013 at 9:35 PM, Larry Leszczynski wrote: > Hi - > > On Sun, Mar 3, 2013, at 08:44 PM, linuxsupport wrote: > > I tried Catalyst::Plugin::RunAfterRequest, when I send request to the > app, > > it returns fine but it does not accept any other request after that > until that > > sub routine finishes. > > By default the test server runs a single process, so that process will > complete the after-request work before accepting a new request to work > on. You need to allow it to fork to run multiple processes: > > myapp_server.pl -f > > > HTH, > Larry > > ___ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
Hi - On Sun, Mar 3, 2013, at 08:44 PM, linuxsupport wrote: > I tried Catalyst::Plugin::RunAfterRequest, when I send request to the app, > it returns fine but it does not accept any other request after that until that > sub routine finishes. By default the test server runs a single process, so that process will complete the after-request work before accepting a new request to work on. You need to allow it to fork to run multiple processes: myapp_server.pl -f HTH, Larry ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
Hi, I tried Catalyst::Plugin::RunAfterRequest, when I send request to the app, it returns fine but it does not accept any other request after that until that sub routine finishes. I created 2 methods, 1 for running other methods using run_after_request and second method to check status. Now, when I call first method it returns the result quickly but when I method to check status it keeps waiting until first method finishes, I tried to call other methods not related to run_after_request but all the requests go into wait. Any idea what is wrong? On Sun, Feb 24, 2013 at 9:46 PM, James R. Leu wrote: > I do not have any suggestions about the App1 to App2 hand off > but perhaps my technique for handling async/long running requests > will help. > > I solved my async requirements by using Catalyst::Plugin::Cache > and Catalyst::Plugin::RunAfterRequest. > > First off, I have my catalyst apps setup to run as FCGI with many > children (50-100) depending on the app. All the clients are implemented > in javascript and make periodic ajax requests. > > In my catalyst actions that need to be async: > - check if the request contains a job id > - if so check the cache for the status of the job id > - if the job is done, then return the results, and clear the cache > - else return a response telling the client to come back later > - otherwise create a new cache entry and immediately return a job id > to the client, and tell it to come back later > - after the response is sent, using RunAfterRequest I start the > long running action (in essence consuming this FCGI child > for the duration of the long running action) > - at the end of the RunAfterRequest action I update the cache > with the results > > You will need to choose a Catalyst::Plugin::Cache backend that > meets your need. > > On Sun, Feb 24, 2013 at 10:41:16AM +0530, linuxsupport wrote: > > any other idea on this? > > > > On Sat, Feb 23, 2013 at 12:31 PM, Francisco Obispo > wrote: > > > > > I would probably use a message queue. > > > > > > Have you looked into RabbitMQ ? > > > > > > App 1 would be the producer, and you would have a consumer, responsible > > > for performing the operation on App 2. > > > > > > > > > > > > > > > > > > On Feb 22, 2013, at 10:40 PM, linuxsupport > wrote: > > > > > > > Hi All, > > > > > > > > I need your help on the following scenario. > > > > > > > > I have 2 Catalyst apps, say App 1 and App 2 > > > > > > > > Now, User access the App 1 and request something, App 1 then connect > to > > > App 2 for the information but getting that information takes sometime > lets > > > say 15 minutes. > > > > > > > > What I want to implement is that, App 1 checks the status of request > > > which was sent to App 2 every 2 minutes and once completed it gets the > > > response. > > > > > > > > Checking the status every 2 minutes can be controlled from the > browser > > > using Ajax, client side code can send status request to App 1, App 1 > can > > > forward this request to App 2, but how App2 will maintain the state and > > > keep the job running even if App 1 gets disconnect from App 2. > > > > > > > > Is there something similar to Ajax for Catalyst to Catalyst > > > communication? > > > > > > > > I can create a table on App 2 and store the request, and run a cron > > > script to process the request and update table with result, App 1 can > then > > > pull the information from that table but looking for more elegant way > to do > > > it. > > > > > > > > Thanks > > > > > > > > ___ > > > > List: Catalyst@lists.scsys.co.uk > > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > > Searchable archive: > > > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > Francisco Obispo > > > Director of Applications and Services - ISC > > > email: fobi...@isc.org > > > Phone: +1 650 423 1374 || INOC-DBA *3557* NOC > > > PGP KeyID = B38DB1BE > > > > > > > > > ___ > > > List: Catalyst@lists.scsys.co.uk > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > Searchable archive: > > > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > -- > James R. Leu > j...@mindspring.com > > ___ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > > ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
On Sun, Feb 24, 2013 at 8:16 AM, James R. Leu wrote: > I do not have any suggestions about the App1 to App2 hand off > but perhaps my technique for handling async/long running requests > will help. > > I solved my async requirements by using Catalyst::Plugin::Cache > and Catalyst::Plugin::RunAfterRequest. > Long running requests have to run somewhere, of course, and often running in the Catalyst app is the easy solution and may work fine if you are not running a busy site or expecting many concurrent users -- ever. But, in general designing your web app in a way that you expect processes to block for a long time is very risky. You don't want to DoS your own site. It's all about the specifics, but long running processes are often resource intensive, and when they run long users start reloading which users more resources and just compounds the problem. Soon you have an unresponsive site. Maybe you can manage or limit the number of long running web processes in some way, but this is a problem that's already been solved. Francisco gave very good advice. Use a queue to decouple the web app from the long-running jobs. You then have control over your resources -- workers pull in work as they are free instead of stuffing work into web processes. Scaling is then trivial as it's just more workers. It may seem like more work up front to set up but will making things like this much easer -- and safer. -- Bill Moseley mose...@hank.org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
I do not have any suggestions about the App1 to App2 hand off but perhaps my technique for handling async/long running requests will help. I solved my async requirements by using Catalyst::Plugin::Cache and Catalyst::Plugin::RunAfterRequest. First off, I have my catalyst apps setup to run as FCGI with many children (50-100) depending on the app. All the clients are implemented in javascript and make periodic ajax requests. In my catalyst actions that need to be async: - check if the request contains a job id - if so check the cache for the status of the job id - if the job is done, then return the results, and clear the cache - else return a response telling the client to come back later - otherwise create a new cache entry and immediately return a job id to the client, and tell it to come back later - after the response is sent, using RunAfterRequest I start the long running action (in essence consuming this FCGI child for the duration of the long running action) - at the end of the RunAfterRequest action I update the cache with the results You will need to choose a Catalyst::Plugin::Cache backend that meets your need. On Sun, Feb 24, 2013 at 10:41:16AM +0530, linuxsupport wrote: > any other idea on this? > > On Sat, Feb 23, 2013 at 12:31 PM, Francisco Obispo wrote: > > > I would probably use a message queue. > > > > Have you looked into RabbitMQ ? > > > > App 1 would be the producer, and you would have a consumer, responsible > > for performing the operation on App 2. > > > > > > > > > > > > On Feb 22, 2013, at 10:40 PM, linuxsupport wrote: > > > > > Hi All, > > > > > > I need your help on the following scenario. > > > > > > I have 2 Catalyst apps, say App 1 and App 2 > > > > > > Now, User access the App 1 and request something, App 1 then connect to > > App 2 for the information but getting that information takes sometime lets > > say 15 minutes. > > > > > > What I want to implement is that, App 1 checks the status of request > > which was sent to App 2 every 2 minutes and once completed it gets the > > response. > > > > > > Checking the status every 2 minutes can be controlled from the browser > > using Ajax, client side code can send status request to App 1, App 1 can > > forward this request to App 2, but how App2 will maintain the state and > > keep the job running even if App 1 gets disconnect from App 2. > > > > > > Is there something similar to Ajax for Catalyst to Catalyst > > communication? > > > > > > I can create a table on App 2 and store the request, and run a cron > > script to process the request and update table with result, App 1 can then > > pull the information from that table but looking for more elegant way to do > > it. > > > > > > Thanks > > > > > > ___ > > > List: Catalyst@lists.scsys.co.uk > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > Searchable archive: > > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > > > Dev site: http://dev.catalyst.perl.org/ > > > > Francisco Obispo > > Director of Applications and Services - ISC > > email: fobi...@isc.org > > Phone: +1 650 423 1374 || INOC-DBA *3557* NOC > > PGP KeyID = B38DB1BE > > > > > > ___ > > List: Catalyst@lists.scsys.co.uk > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: > > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > > Dev site: http://dev.catalyst.perl.org/ > > -- James R. Leu j...@mindspring.com pgpnThXahrPOb.pgp Description: PGP signature ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
any other idea on this? On Sat, Feb 23, 2013 at 12:31 PM, Francisco Obispo wrote: > I would probably use a message queue. > > Have you looked into RabbitMQ ? > > App 1 would be the producer, and you would have a consumer, responsible > for performing the operation on App 2. > > > > > > On Feb 22, 2013, at 10:40 PM, linuxsupport wrote: > > > Hi All, > > > > I need your help on the following scenario. > > > > I have 2 Catalyst apps, say App 1 and App 2 > > > > Now, User access the App 1 and request something, App 1 then connect to > App 2 for the information but getting that information takes sometime lets > say 15 minutes. > > > > What I want to implement is that, App 1 checks the status of request > which was sent to App 2 every 2 minutes and once completed it gets the > response. > > > > Checking the status every 2 minutes can be controlled from the browser > using Ajax, client side code can send status request to App 1, App 1 can > forward this request to App 2, but how App2 will maintain the state and > keep the job running even if App 1 gets disconnect from App 2. > > > > Is there something similar to Ajax for Catalyst to Catalyst > communication? > > > > I can create a table on App 2 and store the request, and run a cron > script to process the request and update table with result, App 1 can then > pull the information from that table but looking for more elegant way to do > it. > > > > Thanks > > > > ___ > > List: Catalyst@lists.scsys.co.uk > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > > Dev site: http://dev.catalyst.perl.org/ > > Francisco Obispo > Director of Applications and Services - ISC > email: fobi...@isc.org > Phone: +1 650 423 1374 || INOC-DBA *3557* NOC > PGP KeyID = B38DB1BE > > > ___ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] May be asynchronous communication between Catalyst applications
I would probably use a message queue. Have you looked into RabbitMQ ? App 1 would be the producer, and you would have a consumer, responsible for performing the operation on App 2. On Feb 22, 2013, at 10:40 PM, linuxsupport wrote: > Hi All, > > I need your help on the following scenario. > > I have 2 Catalyst apps, say App 1 and App 2 > > Now, User access the App 1 and request something, App 1 then connect to App 2 > for the information but getting that information takes sometime lets say 15 > minutes. > > What I want to implement is that, App 1 checks the status of request which > was sent to App 2 every 2 minutes and once completed it gets the response. > > Checking the status every 2 minutes can be controlled from the browser using > Ajax, client side code can send status request to App 1, App 1 can forward > this request to App 2, but how App2 will maintain the state and keep the job > running even if App 1 gets disconnect from App 2. > > Is there something similar to Ajax for Catalyst to Catalyst communication? > > I can create a table on App 2 and store the request, and run a cron script to > process the request and update table with result, App 1 can then pull the > information from that table but looking for more elegant way to do it. > > Thanks > > ___ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ Francisco Obispo Director of Applications and Services - ISC email: fobi...@isc.org Phone: +1 650 423 1374 || INOC-DBA *3557* NOC PGP KeyID = B38DB1BE ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/