throttling
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Perlbal > throttling




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    throttling  
Max Michaels


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-26-05 10:45 PM

Hellos,

We are considering a switch to perlbal for a front-end
proxy/load-balancer but i have a question first. Is there a throttling
mechanism built-in to Perlbal or a plug-in. I would like to be able to
say that a single IP can only request n documents per second or minute
or whatever. I've got perlbal running in a test environment and so far,
everything looks great.

-max







[ Post a follow-up to this message ]



    Re: throttling  
Mark Smith


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-26-05 10:45 PM

Perlbal has no support for this at the moment, but you could add it in as a
plugin using a combination of the start_proxy_request/start_http_request
hooks (either/or depending on what you want to delay) and then the timer
callback functionality.

I imagine it could be something like:

 Perlbal::register_hook('start_proxy_requ
est', sub {
my Perlbal::ClientProxy $self = shift;
my $hd = $self->{req_headers};
return undef unless $self && $hd;

# rate limit by ip
my $ip = $self->peer_ip_string;
if (my $delay_for = ip_too_fast($ip)) {
Perlbal::Socket->register_callback($delay_for, sub {
$self->handle_request;
});
return 1;
}

return 0;
});

The idea being that you usurp handling of the request, and if you want to
throttle the request, you register a callback (your mythical ip_too_fast
sub would check that the IP is okay or not), and then after that amount of
time, the request is restarted.

One problem with this overly simple example is that requests can be waited
multiple times, which might be undesired behavior.  A better system is to
keep track of what requests you've throttled and handle that case.

Of course, it might be useful to put this functionality into the core...
then we can just have a throttle hook, and call it to see if we should
throttle and if so for how long, and then have Perlbal handle everything
else.

-jr

On Fri, Aug 26, 2005, Max Michaels wrote:
> Hellos,
>
> We are considering a switch to perlbal for a front-end
> proxy/load-balancer but i have a question first. Is there a throttling
> mechanism built-in to Perlbal or a plug-in. I would like to be able to
> say that a single IP can only request n documents per second or minute
> or whatever. I've got perlbal running in a test environment and so far,
> everything looks great.
>
> -max
>


--
Junior (aka Mark Smith)
junior@danga.com

Software Engineer
Six Apart / Danga Interactive






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:19 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register