05-18-07 06:11 PM
Are these additions okay? Is there a better way to accomplish these things?
Can it get into a perlbal release, so we don't have to maintain a private
branch?
Thanks!
Adam
On Fri, May 11, 2007 at 04:26:26PM -0700, Adam Jacob wrote:
> Attached is a patch that adds two new config options:
>
> 1. max_idle_time
>
> This sets the max_idle_time in the ClientHTTPBase class. We were running i
nto
> a situation where the default (30 seconds) wasn't quite long enough, causi
ng
> the ClientProxy to close the connections. It had a "FixMe:" above it anywa
y,
> asking for a config option... so here it is.
>
> I had some trouble seeing how to get the value of the configuration option
out
> of the Service object, due to the Perlbal::Socket's _do_cleanup method cal
ling
> the sub from the class, not an object.
>
> I worked around it by setting up an "our $MaxIdleTime = 30;" in
> ClientHTTPBase, which gets set to the configuration value when an object i
s
> instantiated.
>
> If you let me know a better way, I'll be happy to fix it up.
>
> 2. verify_backend_path
>
> One of our backend applications was unable to answer an OPTIONS request fo
r '*'. This variable allows the path of the OPTIONS request to be configura
ble. It defaults to the current value of '*'.
>
> Thanks for a great piece of software,
>
> Adam
>
> --
> HJK Solutions - We Launch Startups - http://www.hjksolutions.com
> Adam Jacob, Senior Partner
> T: (206) 508-4759 E: adam@hjksolutions.com
> Index: lib/Perlbal/ClientHTTPBase.pm
> ========================================
===========================
> --- lib/Perlbal/ClientHTTPBase.pm (revision 673)
> +++ lib/Perlbal/ClientHTTPBase.pm (working copy)
> @@ -62,6 +62,8 @@
> zip application/zip
> )};
>
> +our $MaxIdleTime = 30;
> +
> # ClientHTTPBase
> sub new {
> my ($class, $service, $sock, $selector_svc) = @_;
> @@ -76,7 +78,8 @@
> $self->{requests} = 0;
> $self->{scratch} = {};
> $self->{selector_svc} = $selector_svc;
> -
> + $MaxIdleTime = $self->{service}->{max_idle_time};
> +
> $self->state('reading_headers');
>
> bless $self, ref $class || $class;
> @@ -764,8 +767,9 @@
> return $self->send_response(500, $msg);
> }
>
> -# FIXME: let this be configurable?
> -sub max_idle_time { 30; }
> +sub max_idle_time {
> + $MaxIdleTime;
> +}
>
> sub event_err { my $self = shift; $self->close('error'); }
> sub event_hup { my $self = shift; $self->close('hup'); }
> Index: lib/Perlbal/BackendHTTP.pm
> ========================================
===========================
> --- lib/Perlbal/BackendHTTP.pm (revision 673)
> +++ lib/Perlbal/BackendHTTP.pm (working copy)
> @@ -343,7 +343,7 @@
> !$self->{has_attention} && !defined $NoVerify{$self
->{ipport}}) {
>
> # the backend should be able to answer this incredibly quickl
y.
> - $self->write("OPTIONS * HTTP/1.0\r\nConnection: keep-alive\r\
n\r\n");
> + $self->write("OPTIONS " . $self->{service}->{verify
_backend_path} . " HTTP/1.0\r\nConnection: keep-alive\r\n\r\n");
> $self->watch_read(1);
> $self->{waiting_options} = 1;
> $self->{content_length_remain} = undef;
> Index: lib/Perlbal/Service.pm
> ========================================
===========================
> --- lib/Perlbal/Service.pm (revision 673)
> +++ lib/Perlbal/Service.pm (working copy)
> @@ -40,6 +40,7 @@
> 'persist_client', # bool: persistent connections for clients
> 'persist_backend', # bool: persistent connections for backend
s
> 'verify_backend', # bool: get attention of backend before gi
ving it clients (using OPTIONS)
> + 'verify_backend_path', # Path for the OPTIONS check
> 'max_backend_uses', # max requests to send per kept-alive ba
ckend (default 0 = unlimited)
> 'connect_ahead', # scalar: number of spare backends
to connect to in advance all the time
> 'buffer_size', # int: specifies how much data a ClientProxy o
bject should buffer from a backend
> @@ -93,6 +94,7 @@
> 'enable_error_retries', # bool: whether we should retry requ
ests after errors
> 'error_retry_schedule', # string of comma-separated seconds
(full or partial) to delay between retries
> 'latency', # int: milliseconds of latency to ad
d to request
> + 'max_idle_time', # Time in seconds before timing out idl
e Proxy or Backend connections.
>
> # stats:
> '_stat_requests', # total requests to this service
> @@ -170,6 +172,12 @@
> check_type => "bool",
> check_role => "reverse_proxy",
> },
> +
> + 'verify_backend_path' => {
> + des => "What path the OPTIONS request sent by verify_backend shou
ld use. Default is '*'.",
> + default => '*',
> + check_role => "reverse_proxy",
> + },
>
> 'max_backend_uses' => {
> check_role => "reverse_proxy",
> @@ -464,6 +472,13 @@
> check_role => "selector",
> check_type => "int",
> },
> +
> + 'max_idle_time' => {
> + des => "Maximum time (in seconds) before expiring Client Proxy an
d Backend HTTP connections.",
> + default => 30,
> + check_type => "int",
> + check_role => "*"
> + },
>
> 'enable_ssl' => {
> des => "Enable SSL to the client.",
--
HJK Solutions - We Launch Startups - http://www.hjksolutions.com
Adam Jacob, Senior Partner
T: (206) 508-4759 E: adam@hjksolutions.com
[ Post a follow-up to this message ]
|