You might find this plugin nifty if you have multiple application servers processing requests. The Perlbal BackendHeaders plugin appends X-Backend headers with which backend served the request.

Update 06/26/09 Now on github perlbal-plugin-backendheaders


syris:~ victori$ curl -I http://fabulously40.com/questions
HTTP/1.1 200 OK
Server: nginx/0.7.52
Content-Type: text/html; charset=utf-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Language: en
X-Backend: 72.11.142.91:8880
X-Dilbert: If you have any trouble sounding condescending, find a Unix user to show you how it's done
Content-Length: 48046

[code lang=”perl”]
package Perlbal::Plugin::BackendHeaders;

use Perlbal;
use strict;
use warnings;

#
# Add $self->{service}->run_hook(‘modify_response_headers’, $self);
# To sub handle_response in BackendHTTP after Content-Length is set.
#
# LOAD BackendHeaders
# SET plugins = backendheaders

sub load {
my $class = shift;
return 1;
}

sub unload {
my $class = shift;
return 1;
}

# called when we’re being added to a service
sub register {
my ( $class, $svc ) = @_;

my $modify_response_headers_hook = sub {
my Perlbal::BackendHTTP $be = shift;
my Perlbal::HTTPHeaders $hds = $be->{res_headers};
my Perlbal::Service $svc = $be->{service};
return 0 unless defined $hds && defined $svc;

$hds->header( ‘X-Backend’, $be->{ipport} );

return 0;
};

$svc->register_hook( ‘BackendHeaders’, ‘modify_response_headers’,
$modify_response_headers_hook );
return 1;
}

# called when we’re no longer active on a service
sub unregister {
my ( $class, $svc ) = @_;
$svc->unregister_hooks(‘BackendHeaders’);
$svc->unregister_setters(‘BackendHeaders’);
return 1;
}

1;
[/code]