I wrote a simple load tester to test my web app using AnyEvent::HTTP. For the most part it works fine, but if the site becomes non-responsive, eg. it holds open the request connections but doesn't return a response, the load tester goes into a busy wait using 100% cpu, until all the requests time out. I tried different AE loops, and disabled persistent connections, but nothing I tried resolves the issue. And since it's intermittent, I haven't been able to catch it with Devel::NYTProf either. I've included the basic skeleton of the script below. Any pointers to the cause would be much appreciated.
#!/usr/bin/env perl use strict; use warnings; use AnyEvent::Loop; # use the perl loop, not EV use AnyEvent::HTTP; use AnyEvent::Util 'guard'; use BSD::Resource; my $rps = 50; my $timeout = 30; my $duration = 300; my $delay = 60 / $rps / 60; setrlimit RLIMIT_OFILE, 2048, 2048; $AnyEvent::HTTP::MAX_PER_HOST = 1024; my $cv = AE::cv; my $timer = AE::timer 0, $delay, \&do_request; my $wait = AE::timer $duration, 0, sub { undef $timer }; my $halt = AE::timer $duration + $timeout, 0, sub { $cv->send }; $cv->recv; sub do_request { $cv->begin; http_request( GET => 'http://127.0.0.1/test', timeout => $timeout, # I also tried limiting the concurrent requests per connection + with # the following: # persistant => 0, sub { my $guard = guard { $cv->end }; # ... } ); }

In reply to What's causing the busy wait when using AnyEvent::HTTP by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.