performance modifications

Sten Spans sten at
Sun Mar 13 23:47:46 PST 2005

On Sun, 13 Mar 2005 ray at wrote:

> Hi Erich,
>  I wrote a small test program in C that just printed a single <html>test</html>
> line and it was very slow when called as a cgi via apache.  Much slower than
> PHP.  Is there something that needs to be done in order for Apache to run C
> without having to shell out to the OS (?) or something.

The main overhead should be fork/exec, this can
be solved by running persistent cgi's through fastcgi,
cgisock, etc.

The main trick with tuning anything is to search for
the bottlenecks, switching an entire site to another language
solves nothing if the database server is the bottleneck.

There are however a few easy tricks to speed things up a bit:

1- Move static content to a lightweight webserver,
    Apache with mod_php uses quite a bit of memory,
    which is wasted on static content.
    run thttpd/lighthttpd/etc for

2- Database queries are another common bottleneck
    changing database layout, caching queries in sessions, etc
    usually helps quite a lot.

3- A simple brute-force solution is to cache generated content
    for short periods in squid/mod_proxy/etc or even cache it in
    the site code itself.

Good luck.

Sten Spans

"There is a crack in everything, that's how the light gets in."
Leonard Cohen - Anthem

More information about the freebsd-performance mailing list