Quantcast

Apache Reverse Proxy Memory Consumption Observations

(No Ratings Yet)
Loading ... Loading ...

If you're new here, you may want to subscribe to my RSS feed. So that you can read the latest updates about Web2.0 tools, Making Money Online, Tips in SEO, Ajax and many more. Thanks for visiting ProgramimiCOM!

Last week I spent some time stress-testing Apache 2.2.3 configured to work as a reverse proxy. I discovered (actually, re-discovered would be more accurate) two issues worth sharing.

  1. Memory consumption of an Apache process will steadily increase as the number of processed requests rises. This is very easy to see if you send thousands of requests per second, with each request going to the same process. This has to be either a memory leak or a memory fragmentation issue. To deal with this you need to recycle processes before they become too large (and cause the operating system to start swapping). The MaxRequestsPerChild directive is meant to help with this. By setting its value to something other than zero (which means “unlimited”) you are telling Apache to shut down every process that goes over the limit. No problems there. Except that it’s where the second problem comes in.

  2. The MaxRequestsPerChild directive does not work as the name suggests. Apache does not count requests - it counts *connections*. This creates a problem if you have persistent connections enabled in your configuration - you don’t know how many requests will come over a connection. It is probably safe to assume the number will not be large in most cases but you won’t know if someone will try to abuse this problem and force a large number of requests over a single connection (e.g. by using a specially programmed script). To be on the safe side you need to divide your ideal MaxRequestsPerChild value with the MaxKeepAliveRequests value. This will prevent the Apache processes from growing too large. But there’s a side effect - Apache will now recycle its worker processes more often. As your final step you need to make sure there are enough idle processes around (using MinSpareServers) to jump in as soon as an active process goes down. Yo need to have a few of these processes because there is a performance penalty associated with the creation of a new process and because Apache creates new processes at a rate of one every second.

Apache Security in Japanese!

(No Ratings Yet)
Loading ... Loading ...

Apache Security in Japanese cover page

My book was translated to Japanese and published by O’Reilly Japan! This is, apparently, old news, as they did it back in 2005, but I only found out about it from the three-montly royalties statement I received in April.

While we are on the subject of writing, I am starting to get the itch again. There are two or three topics I would like to explore further. Topics such as web application firewalls and ModSecurity, web application security, and application security patterns. On the other hand, I have a few compelling reasons against writing another book:

  • It takes a lot of time (time better spent building Thinking Stone into a stronger business).

  • It’s lonesome (but this can be dealth with by finding someone to co-author the book with me.
  • My hands and arms haven’t fully recovered from the first book. (This one is the most compelling reason of all - I barely managed to finish Apache Security in the first place. If you are using keyboard extensively make sure to read about RSI and always keep Workrave active.)

Apache Security One Year After

(No Ratings Yet)
Loading ... Loading ...

It’s been exactly one year since my book, Apache Security, was published. I was very glad to learn Amazon.com are now enabling book authors to talk to their audience. It is unfortunate this feature did not exist at the time - I would have loved the opportunity to point those looking at this page to the book’s web site - http://www.apachesecurity.net.

I have always believed publication is just a first step in the life of a book (a long step in my case, as I spent eight months writing), and that the best stuff comes only after a book has been in use for a year or two. Let’s face it, we (the authors) don’t know nearly as much as our collective readership does. Therefore I invite you, the reader, to send me your feedback and make the second edition of Apache Security much better!

Apache suEXEC Chroot Patch

(No Ratings Yet)
Loading ... Loading ...

I was recently involved with a project where we needed to configure an Apache server that was intended to run multiple web sites/applications. It’s a pretty common assignment. To ensure the setup is secure I decided to start by creating a separate user account for each application. This allowed me to correctly configure file permissions to allow Apache to serve the static files directly. To take care of the dynamic content, I configured suEXEC to execute each application’s scripts under its own account. (In case you are wondering, this particular server is fast enough to run the scripts as CGIs. But if process creation becomes a bottleneck we can always seamlessly switch to FastCGI to avoid the performance penalty. Nothing to worry about, then.)

SuEXEC is a great tool but I’d love it to be capable of jailing (via the chroot system call) the binaries it executes. However, this feature is not present in the stock version. Having been responsible for the internal chroot feature of ModSecurity, I think I have a pretty good idea of why this is the case: unless you know what you’re doing it’s pretty easy to break applications with chroot. And if that happens you are going to ask for help… from those that created the feature, right? Of course! As it turns out, chrooting is notoriously difficult to debug remotely and that’s why the developers would much rather not deal with it.

But, if do you know your way around feel free to use my suexec chroot patch, which I have just added to the Apache Tools project. But, please, don’t write to me if it’s not working as you are expecting :)

Apache Programming Book On The Way!

(No Ratings Yet)
Loading ... Loading ...

I have been involved with Apache programming for several years now. During this time I’ve been following the main Apache development list and the module programming one. This is how I got to meet Nick Kew, probably the most helpful person on these two lists. (Perhaps on other lists too, but I only follow these two.) Rumours that Nick is writing a book (spread by the author himself) have been circulating for many months now. I am happy to say this is now official; Nick’s book, Apache Programming (I am not sure if this is the official title or not) will be published by Prentice Hall in their Open Source Series. Nick has been kind to invite me to help him as a technical reviewer. This is great news for the Apache community! Apache is a fantastic web server but its growth is being slowed down by the lack of proper documentation for programmers. I only wish I had this book a couple of years back when I was starting with ModSecurity!

Apache 2.1.7 Beta Released

(No Ratings Yet)
Loading ... Loading ...

A new beta version of the Apache web server has been released. This release is important because it is a beta version in the 2.1.x development branch, meaning Apache is one step closer to an official 2.2 version. The most important changes are the refactoring of the authentication/authorisation backend, faster and better caching support, and the much improved mod_proxy with support for load balancing.

The PHP Chapter from Apache Security Available for Download

(No Ratings Yet)
Loading ... Loading ...

I have made the PHP chapter from Apache Security available for free download. When we made the decision to set the installation and configuration chaper free, several months ago, I did not realise this chapter only told one half of the story. Most people need to configure Apache *and* PHP. This is now fixed, and the two chapters together make a valuable resource. My long-term plans are to convert both chapters to DocBook, keem them up-to-date, and publish them as PDF and as HTML. But not yet–the content is still very fresh!

Public Life of Apache Security Begins

(No Ratings Yet)
Loading ... Loading ...

My book, Apache Security, is finally out, after a year and a half of hard labour. I began talking to the publisher in the summer of 2003, and began research shortly after. I began writing in March 2004 and finished in December 2004. O’Reilly had it in stock on March 1st 2005, but it only become widely available in late March.

The work itself was great fun. It is a great privilege to be able to explore the boundaries of your own knowledge in detail. I did have periods of despair, of course. But I was prepared for them from reading blog entries of other book writers. I knew how difficult it was going to be. The biggest challenge I had was deciding what to cover, and what to leave out. It was never going to be a book for absolute beginners (officially, it’s an “intermediate to advanced” type of book) but I didn’t want to write a book that would be understood only by a few people who are already Apache experts. On an another level, it was also not possible to look at the security of the Apache web server in isolation. A book that pretends to provide “everything you need to know to secure your Apache web server” must delve into topics such as networks security, host security, and web application security. As it turned out I had to deal with these questions every single day. It was a struggle to keep the book from growing too much. Initially, the book was supposed to be around 280 pages long. In the end, it grew to over 400 pages.

As my work progressed I began to think more and more about the process. The traditional book writing process restricts the author to his experience, the experience of his immediate peers, and the experience of the technical reviewers. While this may work in some, or even many cases, I came to believe that a piece of technical writing can achieve its best only through the collaboration process with the readers. Now that the book is out, this is exactly what I am looking forward to.

The first step, the book’s web site, is already completed. In the following months I plan to put more material from the book online, start adding fresh content, and generally try to engage the public by offering them the stuff they are interested in. The way I see it, my work has just began.

Apache Security Cover and Beta Chapter Available!

(No Ratings Yet)
Loading ... Loading ...

The Apache Security cover will feature a horse, I am happy to say. I knew all along my book was going to be an animal book but the identity of the animal was not known until fairly recently. Now that the animal is known and the tagline (”The Complete Guide to Securing Your Apache Web Server”) is sorted I decided to publish the cover for everyone to see. The official launch date is less than two weeks from now so I’ll save my “it was a difficult job” speech for then.

A beta chapter, Installation and configuration, is also available for download. A part of me wanted to advertise my knowledge by giving away one of the more exciting chapters. But since properly installing and configuring Apache is very important, in the end I decided to give away the less exciting but probably more useful chapter.

26 February 2008 - Apache MINA 2.0.0-M1 Now Available

(No Ratings Yet)
Loading ... Loading ...

The Apache MINA project is pleased to announce the release of MINA 2.0.0-M1.

Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract, event-driven, asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.

The latest release is now available here:

http://mina.apache.org/downloads.html

This release has too many changes and fixed to enumerate in their entirety. Some of the key improvements include:

  • Simplified and more consistent API
  • Ability to share I/O processor threads between multiple servers and/or
    clients
  • Improved support for streaming files
  • Improved String and JMX integration
  • Improved logging support
  • Framework for simplifying state machine creation and maintenance
  • Support for synchronous clients
  • OSGi integration

This is a milestone release and is not yet considered suitable forproduction use. The intent of this release is to showcase the new modified API and other improvements in MINA. We hope that developers will start to use this release and provide feedback.

—-

– The Apache MINA PMC (Project Managament Committee)

[ Category : Apache MINA ] PDFXML_RSS