Choosing a Web Architecture for Perl Perrin Harkins We Also Walk Dogs
This used to be an easy decision <ul><li>Netscape, or Apache for you hippies
CGI, or NSAPI if you enjoy core dumps </li></ul>
Server-side development matured, and it stayed easy <ul><li>Apache became the standard web server
mod_perl became the way to run Perl
FastCGI was looking peaky </li><ul><li>Outside of Amazon's reality distortion field anyway </li></ul></ul>
Then two things happened <ul><li>Ruby came along </li><ul><li>Renewed interest in FastCGI
Thanks, Ruby! </li></ul><li>Non-blocking I/O became fashionable </li><ul><li>Memcached
Lighttpd
Nginx </li></ul></ul>
Now we have many choices <ul><li>Web servers </li><ul><li>Apache
Lighttpd
Nginx
Squid
Perlbal
Varnish </li></ul></ul><ul><li>Protocols </li><ul><li>FastCGI
HTTP
SCGI </li></ul></ul>
FastCGI <ul><li>Many implementations for different servers
Daemons are managed by the web server or an external process
Has hooks for auth, logging, and filtering, but not always implemented and rarely used </li></ul>
HTTP <ul><li>Reverse proxy forwards HTTP requests to apache/mod_perl backend </li></ul>
SCGI <ul><li>”Simple CGI”
Upcoming SlideShare
Loading in...5
×

Choosing a Web Architecture for Perl

7,754

Published on

This talk was presented at OSCON 2009 and YAPC::NA 2009. The choices discussed here are still relevant, although Plack has opened up some new options. For a more up-to-date take on this material I would recommend Tatsuhiko Miyagawa's most recent Plack/PSGI talks.

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

  • Be the first to like this

No Downloads
Views
Total Views
7,754
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Choosing a Web Architecture for Perl

  1. 1. Choosing a Web Architecture for Perl Perrin Harkins We Also Walk Dogs
  2. 2. This used to be an easy decision <ul><li>Netscape, or Apache for you hippies
  3. 3. CGI, or NSAPI if you enjoy core dumps </li></ul>
  4. 4. Server-side development matured, and it stayed easy <ul><li>Apache became the standard web server
  5. 5. mod_perl became the way to run Perl
  6. 6. FastCGI was looking peaky </li><ul><li>Outside of Amazon's reality distortion field anyway </li></ul></ul>
  7. 7. Then two things happened <ul><li>Ruby came along </li><ul><li>Renewed interest in FastCGI
  8. 8. Thanks, Ruby! </li></ul><li>Non-blocking I/O became fashionable </li><ul><li>Memcached
  9. 9. Lighttpd
  10. 10. Nginx </li></ul></ul>
  11. 11. Now we have many choices <ul><li>Web servers </li><ul><li>Apache
  12. 12. Lighttpd
  13. 13. Nginx
  14. 14. Squid
  15. 15. Perlbal
  16. 16. Varnish </li></ul></ul><ul><li>Protocols </li><ul><li>FastCGI
  17. 17. HTTP
  18. 18. SCGI </li></ul></ul>
  19. 19. FastCGI <ul><li>Many implementations for different servers
  20. 20. Daemons are managed by the web server or an external process
  21. 21. Has hooks for auth, logging, and filtering, but not always implemented and rarely used </li></ul>
  22. 22. HTTP <ul><li>Reverse proxy forwards HTTP requests to apache/mod_perl backend </li></ul>
  23. 23. SCGI <ul><li>”Simple CGI”
  24. 24. Stealing good ideas from Python
  25. 25. Simpler than FastCGI, so theoretically could be faster </li></ul>
  26. 26. The graveyard of alternative Perl daemons <ul><li>SpeedyCGI
  27. 27. PersistentPerl
  28. 28. Both replace the #! line and daemonize your program </li></ul>
  29. 29. Biases <ul><li>Long-time mod_perl contributor
  30. 30. Member of Apache Software Foundation </li></ul>Don't believe a word I say!
  31. 31. Apache 2.2 mod_proxy + mod_perl <ul><li>Frontend apache runs threaded worker MPM
  32. 32. Backend apache runs prefork MPM
  33. 33. All popular apache modules (mod_ssl, mod_rewrite, mod_security, mod_deflate, caching, auth) are available
  34. 34. mod_proxy_balancer provides load balancing </li></ul>
  35. 35. Apache 2.2 mod_fastcgi <ul><li>Frontend runs threaded worker MPM
  36. 36. As with mod_proxy, all popular apache modules are available
  37. 37. Three poorly-named configurations: </li><ul><li>”Static” starts a set number of procs at server startup
  38. 38. ”Dynamic” starts a new proc every time it gets a request up to a configured limit
  39. 39. ”Standalone” sends requests to daemon you start </li></ul></ul>
  40. 40. Apache 2.2 mod_fastcgi <ul><li>Can run separate versions of same package name in separate daemons </li><ul><li>True for mod_perl too if you run multiple backends, but less obvious </li></ul><li>Seamless restart for code upgrades in standalone mode </li><ul><li>Start a new set of procs on same socket and shut down the old ones
  41. 41. Could get close with two mod_perl backends, but not simple </li></ul></ul>
  42. 42. Lighttpd mod_fastcgi <ul><li>Non-blocking I/O server
  43. 43. Supports static and standalone FastCGI
  44. 44. Supports Authorizer role
  45. 45. Solid selection of modules with equivalents of most popular apache ones
  46. 46. Same restart advantages as FastCGI on Apache
  47. 47. Load balancing across FastCGI daemons </li></ul>
  48. 48. Lighttpd mod_scgi <ul><li>Same Lighttpd, different protocol
  49. 49. Sketchy docs </li></ul>
  50. 50. nginx FastCGI <ul><li>Another non-blocking I/O server
  51. 51. Supports standalone FastCGI only
  52. 52. Does not support Authorizer role
  53. 53. Good module selection
  54. 54. Same restart advantages </li></ul>
  55. 55. nginx proxy + mod_perl <ul><li>Load balancing </li></ul>
  56. 56. What about running naked mod_perl? <ul><li>Static requests
  57. 57. Buffering for slow clients
  58. 58. Keep-Alive </li></ul>
  59. 59. Benchmark methodology <ul><li>Very simple Catalyst app </li><ul><li>Sleeps for 0.1 seconds
  60. 60. Returns 35K of HTML (perl.com homepage) </li></ul><li>Brief run of ab (Apache Bench) with intended concurrency to warm up server
  61. 61. ab tests at concurrency of 10, 50, 150, 200 </li></ul>
  62. 62. General findings <ul><li>FastCGI static mode is difficult to use with apache/mod_fastcgi </li><ul><li>Trial and error to find magic number
  63. 63. Worked better with Lighttpd </li></ul><li>FastCGI standalone mode is unusable on Lighttpd </li><ul><li>Load balancing feature marks daemons as down if they're too busy to answer right away and rejects requests </li></ul><li>SCGI Perl implementations incomplete </li></ul>
  64. 64. Benchmark results
  65. 65. Not really apples to apples <ul><li>mod_perl does other things
  66. 66. Filters on non-perl content (PHP, etc.)
  67. 67. Customize server and request phases
  68. 68. Replace HTTP with your own protocol </li><ul><li>Apache 2 + mod_perl 2 is a server kit </li></ul></ul>
  69. 69. Thanks! And please help me add more servers...
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×