Wednesday, October 29, 2008

Static File Servers and Drupal

Any call to a Drupal site has two aspects associated with it:

The Dynamic HTML that gets created on access of the website + the static elements (like css, js and other images) that are embedded in it.

A request to the a website from a browser = Dynamic HTML call to the web server + one call each for every associated static element in the HTML to the same web server.

The amount of memory required to serve a Dynamic request is much more than that of the static file requests. More over in Apache the same memory will be utilized to serve static files as well. To avoid this we can place all static files in a separate Web server and configure the this server to handle static requests. This will greatly improve the performance and scalability of a Drupal website.

A Drupal site with lots of modules installed that handles a lot of data from the database can easily require 64M of memory per thread. This is a huge expenditure of memory compared to the 1-2M it takes to serve a static file. Since Apache recycles its worker threads, you end up in a situation where the same 64M monster that created the Drupal HTML is also used for serving a .jpg file. This is a huge waste of resources.


For a private server the needs are different. The static file become applicable for the images and css and js files associated with HTML but for the main application we need to use Private files. Private files makes the file handling process itself dynamic, where in we will require to use PHP to identify permissions and the location of the files. This is handled by a separate menu call back in Drupal. We can not use static files for this purpose.

In this case we are looking at three approaches:

1. To handle files to be placed in any physical directory (not in the root)within the same server

2. To handle files to be placed in any physical directory (not in the root) in a different server - here we are using the FTP protocol to access and place files in the file server. This is a custom code written by us.

3. To handle files to be placed in any physical directory (not in the root) in a different server - using Curl

Questions that arise - Which of these are scalable? Which is most secure?


  1. Arto Bendiken's Boost module is an excellent alternative. Development Seed had a nice post recently that explained in detail how the module helped their UN web site.


Search This Blog

Chennai Drupal Community - Community plumbing

Shyamala's Drupal SEO