CGI Timeout errors with Snap! C++

When creating a dynamic website, the time it takes to create a page requires a proper (large enough) timeout or Apache will generate a 500 error even before the system has a chance to reply one byte.

Snap!, like many other content manager systems (CMS), will generate the entire page before sending anything back to the client. There are several reasons for doing this:

  1. The system is generating HTML which we want to compress before sending it to clients;
  2. The system likes to define the Content-Size header because it allows browsers to show clients how much of the data it already downloaded;
  3. The system may change its mind at a time that's too late to do so (i.e. reply with an error when you already sent some HTML is not possible.)

The result may be a very long wait by Apache to get an answer. This is especially true of very complicated pages (content wise.)

However, where you are most likely going to get a hit is Cassandra. If Cassandra falls asleep (does not get used for long enough and the system goes as far as swapping out part of Cassandra's code or the java interpreter) then the restart may take quite a long time (relatively to the normal behavior which is close to instantaneous replies.)

For that reason properly setting up the Timeout parameter in your Apache setup may end up being important. By default the Timeout is 300 which is 5 minutes and much more than enough (frankly if Cassandra doesn't wake up with 10 to 20 seconds, you probably have another problem!) I have been using 15 which is too short when Cassandra falls asleep. A good number is probably between 60 to 120. You will have to test with your own setup for the right value. To see how long it takes for Cassandra to wake up, do not access your server for 24h or so, then do one timed request. See how long it takes and multiply that by 4 or 5 and you should have your answer (although do not use less than 15.)

It is possible to setup the maximum to a very large number such as 12,000 although it is recommended that you never really go beyond 300.

IMPORTANT NOTE:

Things that really take a long time (such as scanner uploaded files for viruses) are run by the Snap! backend processes. These are not affected by the Apache Timeout parameter and are in general not timed at all.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly