Slashdot Mirror


Practical mod_perl

honestpuck writes with the review below of O'Reilly's Practical mod_perl, which he describes as "a doorstop sized volume that provides more information on using mod_perl than you ever thought you needed." Read on for the rest of his review, and to see whether you actually do need to know what's in this book. Practical mod_perl author Stas Bekman & Eric Cholet pages 858 publisher O'Reilly rating 8 - Good book, some flaws reviewer Tony Williams ISBN 0596002270 summary Good overall guide for running and developing with mod_perl

The almost 900 pages are divided into five parts and a bunch of appendices. Part I, "mod_perl Administration" covers building, configuring and installing mod_perl, followed by some Apache details and an 80-page guide to coding with mod_perl in mind. Part II, 'mod_perl Performance' deals with ways of getting the best out of Apache and mod_perl, with a little about security. Part III deals with databases, including persistent connections and data sharing. Part IV is a great guide to debugging and troubleshooting. Part V is a brief look at Apache 2 and mod_perl 2.

The appendices are useful. The first is a short section of around a dozen small 'recipes' for performing various tasks using mod_perl. I found these a good base for more complex tasks, particularly when combined with examples from elsewhere in the book. The second is a list of Perl modules that extend Apache and mod_perl with a brief description of each. The third gives some strategies for providers wanting to host Apache with mod_perl. The fourth and fifth give good overviews of the Template Toolkit and AxKit, an XML application server built on mod_perl.

The book is readable, tending towards heavy writing and certainly dense, but I didn't feel this was a problem in a book meant for a fairly advanced audience. I think you'd want to be a fairly good Perl programmer and well versed in Apache before needing this volume and shouldn't expect to be spoon fed. I thought it well written.

In a book of this size you expect to find a lot of example code, and you won't be disappointed. The book is peppered with short Perl examples and example command lines and configurations, all well explained. The one shortcoming is that there aren't many examples of full-blown applications where you can see everything discussed and have it explained all in one place. I would have appreciated some more of this, the examples tend to be on the short side.

This book sits well in the marketplace. It provides more details on running, installing and configuring mod_perl and Apache than mod_perl Developer's Cookbook (and also delves more into the reasons for doing something one particular way and much more help on debugging), though the Developer's Cookbook becomes a good companion to this volume as it provides a lot more in the way of examples. For those that want to get deep into the high end of mod_perl there is Writing Apache Modules in Perl and C, which is at core a good book on high end mod_perl programming.

O'Reilly have their usual website with Table of Contents, an example chapter, and errata. The authors have their own website with some of the same information and all the code examples from the book as both individual files and one 40k tarball.

I would recommend this book to anyone who administers and writes for mod_perl, it fills the missing pieces in mod_perl Developers Cookbook and is a good companion volume to it.

You can purchase Practical mod_perl from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

12 of 121 comments (clear)

  1. My $0.02 by Anonymous Coward · · Score: 0, Informative
    mod_perl embeds the popular programming language Perl in the Apache web server, giving rise to a fast and powerful web programming environment. Practical mod_perl is the definitive book on how to use, optimize, and troubleshoot mod_perl. New mod_perl users will learn how to quickly and easily get mod_perl compiled and installed. But the primary purpose of this book is to show you how to take full advantage of mod_perl: how to make a mod_perl-enabled Web site as fast, flexible, and easily-maintainable as possible. The authors draw from their own personal experience in the field, as well as the combined experience of the mod_perl community, to present a rich and complete picture of how to set up and maintain a successful mod_perl site.

    This book is also the first book to cover the "next generation" of mod_perl: mod_perl 2.0, a completely rewritten version of mod_perl designed for integration with Apache 2.0, which for the first time supports threads.

    The book covers the following topics, and more:

    Configuring mod_perl optimally for your web site

    Porting and optimizing programs for a mod_perl environment

    Performance tuning: getting the very fastest performance from your site

    Controlling and monitoring the server to circumvent crashes and clogs

    Integrating with databases efficiently and painlessly

    Debugging tips and tricks

    Maximizing security

    Written for Perl web developers and web administrators, Practical mod_perl is an extensive guide to the nuts and bolts of the powerful and popular combination of Apache and mod_perl. From writing and debugging scripts to keeping your server running without failures, the techniques in this book will help you squeeze every ounce of power out of your server. True to its title, this is the practical guide to mod_perl.

  2. general note: what is it by kisrael · · Score: 3, Informative

    For people who are wondering what mod_perl is exactly: it's a way of integrating perl into Apache's webserver. I think the main advantage is that you don't have the overhead of firing up perl for each cgi-type request. The main gotchas, for the developers point of view, involve a little perl enviornment staying alive, when a perl script starts, runs, and stops, it cleans up after itself, but when it 'stays alive' inside apache, you have to make sure it's not accumulating too much memory cruft, that you're closing handles, etc etc.

    This is what I know mostly by reputation, rather than direct experience, experts please feel free to correct me

    --
    SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    1. Re:general note: what is it by ajs · · Score: 5, Informative
      This is the common view of mod_perl, but it's also rather limited.

      A more general view of mod_perl is that it's the Perl interface to the apache API. This means a lot of things to a lot of different kinds of developers, since the Apache API is so rich. It can be used for any of the following things:

      • Writing one-shot programs that run "close to the server" (this is the primary, and rather limited use of mod_perl).
      • Handling error conditions (e.g. file not found or failed execution)
      • Writing your own page-generation caching system.
      • Writing a content management system (e.g. bricolage)
      • Redirecting requests. One example would be taking a request, examining the cookies, and redirecting based on "user".
      • Proxying. You might, for example, like to proxy part of a request to one back-end and another part to another back-end with a minimum of overhead. That's easy with mod_perl and doesn't require as much work as you might think.
      • SSL certificate integration with database of users.

      You can go on and on with this. The bottom line is that mod_perl isn't really an application builder's toolkit, so much as it's the toolkit-builder's toolkit.

      So many times, I've heard people try to compare mod_perl to full-fledged content management systems, and that's just not what mod_perl is. In fact, it's not even a templating system like PHP. It's just the Apache API mocked up into Perl. Granted, there's more than that. There are some utility features, but if you want templating, look at HTML::Mason. If you want content management, look at bricolage. These are systems build on top of mod_perl, and they will reduce (vastly) the number of wheels you need to re-invent.
  3. I'd like to draw your attention to by Sir+Haxalot · · Score: 1, Informative

    this, get it sorted please, mods.

    --
    I have over 70 freaks, do you?
  4. Stas is the man by jslag · · Score: 3, Informative

    Stas is also behind the excellent online mod_perl guide, without which I can't imagine being able to use mod_perl in any kind of production environment. He's a great counterexample for those who complain that nobody puts together proper docs for open source projects.

  5. For price comparisons.... by Anonymous Coward · · Score: 1, Informative

    ...why does anyone look at Amazon and one other store? You'd think there are two book stores online. Try looking here: For a full readout of BestBookBuys' listing on this book (specifically)

    There are three good urls for book shopping:

    BookPool, AddAll, BestBookBuys. Why not let bots do your shopping? And if you like the newer bots, check out Froogle.Google

  6. Re:Is there anything in there... by consumer · · Score: 4, Informative

    There are several things that can stop apache children from growing out of control, and yes, they are documented in the book. One thing that helps is the use of modules like Apache::SizeLimit and Apache::ResourceLimit. Another thing that helps is using a proxy server. You also need to set MaxClients correctly. Beyond that, writing code that doesn't suck goes a long way.

  7. Re:ModPerl vs Php? by consumer · · Score: 2, Informative

    mod_perl is used at many sites, including ticketmaster.com and citysearch.com. It has better performance than PHP. Amazon is using Perl with FastCGI, which is pretty much the same thing as mod_perl with a proxy server.

  8. Perl, and web security documentation by Anonymous Coward · · Score: 1, Informative
  9. Re:Is there anything in there... by KMitchell · · Score: 3, Informative

    Not having read this book yet (though I just ordered it), I don't know if there's anything in the book to help you, but there ARE some things you can do with just access to httpd.conf.

    Since mod_perl compiles the perl code and keeps it resident in your apache children, code that isn't designed for mod_perl can eat a ton of memory. It's often pretty straightforward to fix this kind of thing, often just by "preloading" some modules. Taking it at face value that you have ABSOLUTELY no control of what code is running on your server, what you need to do is have Apache limit how big Apache children can grow.

    Check out the mod_perl docs on child memory size http://perl.apache.org/docs/1.0/guide/performance. html#Preventing_Your_Processes_from_Growing

    Summarizing, play with MaxRequestsPerChild if you're "in a hurry" and check out Apache::SizeLimit or Apache::GTopLimit if you have the time/inclination to do something less heavy handed.

  10. Re:Is there anything in there... by ukpyr · · Score: 2, Informative

    Along these lines, if your preloading large modules (say CGI) in httpd.conf or whatever, then those modules will be shared reducing footprint, do this smartly and you should get a decent child size if you take away the shared portion.

    As to your other problems.... I would get new perl programmers (not that it sounds like that is up to you). The "problem" with mod_perl is that it gives you access to apache at a very low level and that power can be missused rather easily. use strict;

  11. Re:ModPerl vs Php? by Neil+Watson · · Score: 3, Informative

    Amazon also uses Mason. See here. Although, IIRC mod_perl is required for Mason.