ALFCYAPC::Asia 2013 Tokyo
前夜祭 LT-thon
Masahiro Nagano @kazeburo
Me
• 長野雅広 Masahiro Nagano
• @kazeburo
• PAUSE: KAZEBURO
• Operations Engineer, Site Reliability
• LINE Corp.
Development s...
ALFC =
Apache::LogFormat::Compiler
Convert
‘%h %l %u %t "%r" %>s %b’
to perl-code
my $code = <<EOF;
sub {
my ($env,$res,$length,$reqtime,$time) = @_;
$time = time() if ! defined $time;
my @lt = localtime(...
and compile
my $log_line = eval $code;
$log_line->($env,$res);
SYNOPSIS
my $log_handler = Apache::LogFormat::Compiler->new(
'%h %l %u %t "%r" %>s %b'
);
warn $log_handler->log_line($env,$res);
use Plack::Builder;
use Time::HiRes qw/gettimeofday tv_interval/;
use Apache::LogFormat::Compiler;
my $log_handler = Apach...
OR
Plack::Middleware::AxsLog
yet another AccessLog Middleware
use Plack::Builder;
builder {
enable 'AxsLog',
combined => 1,
response_time => 1;
$app
};
OR
Plack::Middleware::AccessLog
Plack (1.0023~)
Benchmark
0
10000
20000
30000
40000
50000
60000
51262
8826
Plack-1.0022 Plack-1.0029
Req/Sec
A
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Upcoming SlideShare
Loading in...5
×

Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon

6,230

Published on

Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,230
On Slideshare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
4
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon

  1. 1. ALFCYAPC::Asia 2013 Tokyo 前夜祭 LT-thon Masahiro Nagano @kazeburo
  2. 2. Me • 長野雅広 Masahiro Nagano • @kazeburo • PAUSE: KAZEBURO • Operations Engineer, Site Reliability • LINE Corp. Development support on LINE Familly, livedoor
  3. 3. ALFC =
  4. 4. Apache::LogFormat::Compiler
  5. 5. Convert
  6. 6. ‘%h %l %u %t "%r" %>s %b’
  7. 7. to perl-code
  8. 8. my $code = <<EOF; sub { my ($env,$res,$length,$reqtime,$time) = @_; $time = time() if ! defined $time; my @lt = localtime($time);; my $t = sprintf '%02d/%s/%04d:%02d:%02d:%02d %s', $lt[3], $abbr[$lt[4]], $lt[5]+1900, $lt[2], $lt[1], $lt[0], $tz; q!! . ($env->{REMOTE_ADDR} || '-') . q! ! . '-' . q! ! . ($env->{REMOTE_USER} || '-') . q! ! . "[" . $t . "]" . q! "! . _safe($env->{REQUEST_METHOD}) . " " . _safe($env- >{REQUEST_URI}) . " " . $env->{SERVER_PROTOCOL} . q!" ! . $res->[0] . q! ! . (defined $length ? $length : '-') . q!! } EOF
  9. 9. and compile
  10. 10. my $log_line = eval $code; $log_line->($env,$res);
  11. 11. SYNOPSIS
  12. 12. my $log_handler = Apache::LogFormat::Compiler->new( '%h %l %u %t "%r" %>s %b' ); warn $log_handler->log_line($env,$res);
  13. 13. use Plack::Builder; use Time::HiRes qw/gettimeofday tv_interval/; use Apache::LogFormat::Compiler; my $log_handler = Apache::LogFormat::Compiler->new( '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i" %D' ); my $compile_log_app = builder { enable sub { my $app = shift; sub { my $env = shift; my $t0 = [gettimeofday]; my $res = $app->(); my $reqtime = int(tv_interval($t0) * 1_000_000); $env->{psgi.error}->print($log_handler->log_line( $env,$res,6,$reqtime, $t0->[0])); } }; $app };
  14. 14. OR
  15. 15. Plack::Middleware::AxsLog yet another AccessLog Middleware
  16. 16. use Plack::Builder; builder { enable 'AxsLog', combined => 1, response_time => 1; $app };
  17. 17. OR
  18. 18. Plack::Middleware::AccessLog Plack (1.0023~)
  19. 19. Benchmark
  20. 20. 0 10000 20000 30000 40000 50000 60000 51262 8826 Plack-1.0022 Plack-1.0029 Req/Sec
  21. 21. A
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×