Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: What's causing the busy wait when using AnyEvent::HTTP

by basiliscos (Scribe)
on Apr 11, 2014 at 08:41 UTC ( #1081931=note: print w/ replies, xml ) Need Help??


in reply to What's causing the busy wait when using AnyEvent::HTTP

Hi,

If you plan to cancel http requests, don't call http_request in void context, as documentation says.

Also documentation recommends to set AnyEvent::HTTP::MAX_PER_HOST = 4, while you set it to 1024. I'm not sure, but I recommend you try to decrease that value.


Comment on Re: What's causing the busy wait when using AnyEvent::HTTP
Re^2: What's causing the busy wait when using AnyEvent::HTTP
by Anonymous Monk on Apr 11, 2014 at 11:30 UTC
    It sounds like you've never used AnyEvent::HTTP before and just scanned the docs to try to answer the question. When http_request is called in void context, it's still easy to cancel a request from within the callback. And you don't understand what load testing is if you suggest limiting concurrent requests to 4.

      Thank you for warm tone of your reply and flattering assumptions about my knowledge.

      Actually, I have written some kind of proxy, which uses AE::HTTP for backend querying. There I've met the limitation HTTP::MAX_PER_HOST = 4

      You request can't be cancelled inside callback, because it is invoked only after http call (successful or unsuccessful).

      I think, I do understand well what is load testing and how AE works. It works in single process CPU thread, that means, that it gets some performance boost only during I/O wait operations via processing or enqueueing other requests. So, might reach the limit of parallel requests much earlier, then you'll get 1000 simultaneously running http requests, due to limitations of the single core CPU. So, perl / AE scheduler might be just overloaded in doing http requests, processing results, and switching between contexts.

      It may be better to gradually rise the number of simultaneous http requests. According to that metrics: https://github.com/Mons/AnyEvent-HTTP-Server-II AE::HTTPD (written in similar manner as AE::HTTP), serves only about 560 rps (on single CPU core, as I understand). That explains well, that doing 1000 dummy requests, will load your CPU to 100%.

      I can advice you to use ab from apache-tools package for simple load testing, because it is written in C, and aimed for loading.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1081931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-18 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (101 votes), past polls