Slide 1

Slide 1 text

The Web That Was Aijaz Ansari @_aijaz_ The Promise and Decline of mod_perl 1 Monday, January 21, 13

Slide 2

Slide 2 text

About Me 2 Monday, January 21, 13

Slide 3

Slide 3 text

About Me 1991 2 Monday, January 21, 13

Slide 4

Slide 4 text

About Me 1991 1995 2 Monday, January 21, 13

Slide 5

Slide 5 text

About Me 1991 1995 1999 2 Monday, January 21, 13

Slide 6

Slide 6 text

About Me 1991 1995 1999 2005 2 Monday, January 21, 13

Slide 7

Slide 7 text

About Me 1991 1995 1999 2005 2013 2 Monday, January 21, 13

Slide 8

Slide 8 text

A Brief Timeline 3 Monday, January 21, 13

Slide 9

Slide 9 text

1987 4 Monday, January 21, 13

Slide 10

Slide 10 text

1987 Perl 1.0 4 Monday, January 21, 13

Slide 11

Slide 11 text

1991 Perl 4.0 5 Monday, January 21, 13

Slide 12

Slide 12 text

6 Monday, January 21, 13

Slide 13

Slide 13 text

7 Monday, January 21, 13

Slide 14

Slide 14 text

1991 Perl 4.0 8 Monday, January 21, 13

Slide 15

Slide 15 text

1995 Apache 9 Monday, January 21, 13

Slide 16

Slide 16 text

1995 Apache C API 9 Monday, January 21, 13

Slide 17

Slide 17 text

Request Phases 10 Monday, January 21, 13

Slide 18

Slide 18 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 11 Monday, January 21, 13

Slide 19

Slide 19 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 12 Monday, January 21, 13

Slide 20

Slide 20 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 13 Monday, January 21, 13

Slide 21

Slide 21 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 14 Monday, January 21, 13

Slide 22

Slide 22 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 15 Monday, January 21, 13

Slide 23

Slide 23 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 16 Monday, January 21, 13

Slide 24

Slide 24 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 17 Monday, January 21, 13

Slide 25

Slide 25 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 18 Monday, January 21, 13

Slide 26

Slide 26 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 19 Monday, January 21, 13

Slide 27

Slide 27 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 20 Monday, January 21, 13

Slide 28

Slide 28 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 21 Monday, January 21, 13

Slide 29

Slide 29 text

Request Phases • Post-read-request - e.g.: reloading changed modules • URI Translation - honor aliases • Map To Storage - where’s the file? • Header Parsing - e.g.: block certain browsers • Access Control - block by IP address, time of day • Authentication - who are you? • Authorization - what are you allowed to see • Mime-type - set response MIME type • Fixups - last-minute tweaks to env, etc. • RESPONSE - most of the work is done here • Logging - always happens • Cleanup - after client goes away - don’t keep it waiting 22 Monday, January 21, 13

Slide 30

Slide 30 text

Enter mod_perl Complete access to C API via Perl Long-running process 23 Monday, January 21, 13

Slide 31

Slide 31 text

How I Use It Writing a RESTful Service 24 Monday, January 21, 13

Slide 32

Slide 32 text

httpd.conf SetHandler perl-script PerlAuthenHandler SLA PerlResponseHandler SL AuthType Basic AuthName "Speak Friend And Enter" Require valid-user Order allow,deny Allow from all 25 Monday, January 21, 13

Slide 33

Slide 33 text

httpd.conf SetHandler perl-script PerlAuthenHandler SLA PerlResponseHandler SL AuthType Basic AuthName "Speak Friend And Enter" Require valid-user Order allow,deny Allow from all 26 Monday, January 21, 13

Slide 34

Slide 34 text

httpd.conf SetHandler perl-script PerlAuthenHandler SLA PerlResponseHandler SL AuthType Basic AuthName "Speak Friend And Enter" Require valid-user Order allow,deny Allow from all 27 Monday, January 21, 13

Slide 35

Slide 35 text

httpd.conf SetHandler perl-script PerlAuthenHandler SLA PerlResponseHandler SL AuthType Basic AuthName "Speak Friend And Enter" Require valid-user Order allow,deny Allow from all 28 Monday, January 21, 13

Slide 36

Slide 36 text

PerlAuthenHandler sub handler { my $r = shift; my ($status, $password) = $r->get_basic_auth_pw; return OK if authenticated($r, $dbh, $r->user, $password); return HTTP_UNAUTHORIZED; } 29 Monday, January 21, 13

Slide 37

Slide 37 text

PerlAuthenHandler sub handler { my $r = shift; my ($status, $password) = $r->get_basic_auth_pw; return OK if authenticated($r, $dbh, $r->user, $password); return HTTP_UNAUTHORIZED; } sub authenticated { my ($r, $dbh, $login, $p) = @_; my $result = &Database::getRow($r, $dbh, "select p=crypt(?, pass) as ok from slUser where email=?", $p, $login); if ($result && $result->{ok}) { return 1; } return 0; } 30 Monday, January 21, 13

Slide 38

Slide 38 text

PerlResponseHandler sub handler { my $r = shift; my $file = getFilePath; my $text = &Template::readFile ($r, $file); $r->print($text); } 31 Monday, January 21, 13

Slide 39

Slide 39 text

HTML Templates file1.html: -----------

Welcome

Goodbye

32 Monday, January 21, 13

Slide 40

Slide 40 text

Filter Module MyFilterModule.pm: ------------------ sub handle { my ($r) = @_; my $hash = {}; # process input $hash = { var1 => "Hello", var2 => "World", print => 1, list => [ { name => 'Foo' }, { name => 'Bar'} ] }; return $hash; } 1; 33 Monday, January 21, 13

Slide 41

Slide 41 text

HTML Templates file1.html: -----------

Welcome

Goodbye

34 Monday, January 21, 13

Slide 42

Slide 42 text

The Template File file2.html: ----------- $var1, $var2!
  • $name
TRUEFALSE { var1 => "Hello", var2 => "World", print => 1, list => [ { name => 'Foo' }, { name => 'Bar'} ] }; 35 Monday, January 21, 13

Slide 43

Slide 43 text

The Final Output

Welcome

Hello, World!
  • Foo
  • Bar
TRUE

Goodbye

36 Monday, January 21, 13

Slide 44

Slide 44 text

The Decline 37 Monday, January 21, 13

Slide 45

Slide 45 text

The Decline Installation is complex 37 Monday, January 21, 13

Slide 46

Slide 46 text

The Decline Libraries are stagnant Installation is complex 37 Monday, January 21, 13

Slide 47

Slide 47 text

The Decline Libraries are stagnant Perl talent is hard to find Installation is complex 37 Monday, January 21, 13

Slide 48

Slide 48 text

The Decline Libraries are stagnant Perl talent is hard to find The community is shrinking Installation is complex 37 Monday, January 21, 13

Slide 49

Slide 49 text

38 Monday, January 21, 13

Slide 50

Slide 50 text

Do I need to change the way I think? Does Ruby have these issues? 38 Monday, January 21, 13

Slide 51

Slide 51 text

http://TheJoyOfHack.com/ @_aijaz_ Thank