Wednesday, May 06, 2009

Lighttpd the Book

Following my post "Using mod_negotiation with Lighttpd" from April 23, 2009
I received a nice email from Packt Publishing who has published a new book about Lighttpd ("Lighttpd" written by Andre Bogus) asking me to review it.

I said - "ok, I will be glad to read your book."

And the story goes on...

Fortunately, I was nicely surprised that it deeply describes not only the Lighty 1.4.x, but the author has focused on 1.5.0, too. As some of you may know there are a lot of improvements in Lighttpd v.1.5.0, a lot of re-coded stuff, my beloved mod_uploadprogress was added again, etc., which is very essential in production servers.

Good. Now let's read on.

What's the first question come into your mind?
Maybe - Why Lighttpd? Huh?

Simple - cause it's fast, light, flexible and FREE. :)
Just look at the sample chapter of the book and you will see what I am talking about.

First few chapters are standard:
Introduction, Configuring & Compiling (I must say that it's very very well explained even for a beginner in UNIX systems), Virtual Hosts, CGI ...
oh wait - CGI? Isn't it slow?
Heh, yup CGI is a bit slow, but FastCGI is really fast! That's the key thing here - a whole chapter about FastCGI & SCGI support and how you should use it and configure in production environment.

Next is - "Optimizing Lighttpd".
Believe or not this is one of the most important things Andre (the author) has written about in his book.
How we can test our Lighttpd setup under stress with http_load (which I use, too) and how we can make some optimizations.
For example a simple mod_magnet caching script can deal easily with lots of load. And of course - mesuring system load is very handy here.

Are you Migrating from Apache?
Ok, then look at chapter 10 when you have a chance or here.

And now my favourite - "Using Lua with Lighttpd" (of course it means "using mod_magnet in Lighttpd").
This is one of the powers of Lighty where it leaves in the dust the good old Apache.
Lua is lightweight, embeddable language nevertheless it is very powerful. Combined with a lightweight and poweful webserver makes the unstoppable "killing" machine for huge amounts of web traffic.
Learn how to manipulate URLs, requested file names, caches, how to simulate Apache'с modules, etc.
This is a MUST READ topic!

And finally "Writing custom modules/plugins for the Lighttpd API" is for you C lovers.
Yes, that's right. A simple explanation how you can write a strong, stable module for Lighty in C.
It's pretty simple, although keep in mind this quote taken from the book:

"Do not write a module where a mod_magnetscript will do
A mod_magnetscript is usually smaller and much easier to write. The
higher level of abstraction leaves less chances of making mistakes. C,
unlike Lua, leaves the memory handling to the programmer. Also the
standard string-handling functions open security holes when used
improperly. Even if we are hell-bent on writing a module, it makes sense
to write a prototype mod_magnetscript first, presuming, of course, that
the function is possible to implement in Lua."

I cannot say anything else but Congratulations to Andre Bogus and Packt Publishing for this great book!

I recommend you to read it if you're going to deal with heavy load and big websites with lots of users. Also newbies can learn how to test their websites/web application and configure/compile a webserver by themselves.