On Wed, Jan 13, 2016 at 4:49 AM, Sawyer X <xsawyerx@gmail.com> wrote:
Could you provide some sample code so I could play with it?
Also, how are you implementing the delayed server? What event loop are you using? Are you trying to do fully non-blocking asynchronous or are you just having a delayed response? There is a big difference.
The problem with delayed responses is that there are several options and in between them you need to understand how they work, what they do, event loop, the effect *on* your code, the effect *of* your code etc. That's why it's a pretty advanced feature that is usually unnecessary and the usage of it should probably be very well contained.
So, after writing basic test app, then retesting my own code, it appears the issue I was having is resolved. For the record, my test app is below, which I've tested with --workers 1 and --workers 3 and --workers 1 will block, whereas --workers 3 works with 3 children. The method I use is to go to http://servername:5001/ Then in another tab, go to http://servername:5001/PlainRoute while / is running. Now, for some reason, the whole thing works and it will just server up /PlainRoute even if / is still going on doing its stuff. It may be that in some of my routes, there is some code that blocks starman, I don't know, so I will keep an eye on this and if I find a situation I willgo from there. This is my test app and startup command: plackup -s Starman -p 5001 ./bin/app.psgi This is the basic code, connecting to MongoDB and doing some stuff: package TestApp; use Dancer2; use MongoDB; our $VERSION = '0.1'; sub connect_MongoDB_referral_db { my $database; my $client = MongoDB::MongoClient->new( host => 'mongodb://user:pass@localhost/ICSIntakeReferralsDev', auto_connect => 1, query_timeout => -1, ); $database = $client->get_database('ICSIntakeReferralsDev'); } return $database; } get '/PlainRoute' => sub { template 'index'; }; get '/' => sub { my %Data; for (1..100) { my $MongoDBConnection = connect_MongoDB_referral_db(); my $MongoReturnData = $MongoDBConnection->get_collection('Patients')->find; while ( my $MongoReturnObject = $MongoReturnData->next ) { my $IDObj = $MongoReturnObject->{'_id'}; my $IDString = $IDObj->to_string; print "ID string is $IDString\n"; $Data{$IDString}++; } } template 'index'; }; true; This is the pretty picture version: [image: Inline image 1] So, as mentioned, it appears that it is all working now but I'll keep monitoring closely. Thanks for all your help everyone. David On Fri, Jan 8, 2016 at 5:55 PM, Andrew Beverley <andy@andybev.com> wrote:
On Sat, 2016-01-09 at 00:09 +1030, David H wrote:
I'm not sure if there is a way (or if this even makes sense) to fork out each request so the dancer site isn't just sitting there waiting for the last thing to complete.
Really stupid question, but I assume you do have Starman configured for multiple processes accepting requests on the server-side? Otherwise you would of course see the behaviour you describe.
I tried using the Delayed responses (Async/Streaming) listed here:
I would expect that. Delayed is still single-threaded (?), it just allows responses to be sent part way through processing request (I think, I've not looked at it in detail).
I certainly would have thought that Starman or other multi-threaded server is the way to go.
I do have some resource-intensive processes in one of my apps (that produce data for the same webpage via a separate request), and I've never noticed a problem. I've never looked at it in detail though. I'm using fast-cgi in Apache.
Andy
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users