Faster way to serve up simple requests?

Jamie Burns fantasticjamieburns at hotmail.com
Mon Jul 11 12:56:45 PDT 2005


Yes, there are certainly benefits to memcached and what I am saying below in
this email is not without appreciating some of them.

But...

It must be remembered though that a common configuration of passing all
requests through some kind of "application server" (ie.
Apache+PHP+memcached) just to serve what is essentially static content is
such a waste in my opinion. The reduced overhead of not needing Apache+PHP
can be dramatic. Both of these take up valuable CPU and memory (how many
Apache processes do you have running? with each one taking up how many
megabytes of memory?). A modern filesystem cache may make better use of the
CPU and memory resources.

My FreeBSD box hardly ever touches its hard disk as it has an excellent
filesystem cache. Static content such as html and images can be served at
*blistering* speeds through a tiny webserver like mathopd or thttpd with
minimal load on the box (lets just say the NIC or TCP/IP stack will likely
be a bottleneck).

Content can be generated "behind the scenes" by an application server and
then distributed right into the filesystems of any number of "front line"
webservers in a redundant cluster. If you need to generate content on a
"cache miss" then this can be triggered for generation any number of ways -
a simple 302 redirect back to the web browser with the URL of the
"application server" should work. The web browser would then (and only then)
contact the "application server" to generate the content. Of course, the
rather under utilised "application server" could also clean up the
filesystems of the cluster too.

I very much doubt that a series of dynamically generated, yet essentially
static, 10kb pages could be served more quickly, whilst using less
resources, by using Apache+PHP+memcached over a configuration employing
mathopd or thttpd serving static content from a modern server filesystem
with the occasional request to generate fresh content.

Jamie.

"To a person with a hammer, all problems look like nails".

----- Original Message ----- 
From: "Sergio Salvatore" <sergiosalvatore at yahoo.com>
To: "Jamie Burns" <fantasticjamieburns at hotmail.com>; "Jeevan _"
<jeevan at gmail.com>; <memcached at lists.danga.com>
Sent: Monday, July 11, 2005 7:59 PM
Subject: Re: Faster way to serve up simple requests?


> Hey,
>
> Just a thought that memcached is simply a cache -- not
> really a database.  Although PHP + Apache can be
> expensive for a simple static serve up you need to
> have a way to generate the content in case of a cache
> miss (or the machine running memcached being
> inaccessable).
>
> Using a ramdisk type filesystem (like tmpfs) is
> certainly an option, but it's not very efficient in a
> clustered environment because the filesystem is not
> shared across web serving nodes.  This is where
> memcache is particularly good because everything is
> balanced and available to all machines in the cluster
> -- making the best use of available space.
>
> /sergio
>
> --- Jamie Burns <fantasticjamieburns at hotmail.com>
> wrote:
>
>> Could you not simply save the items as html pages
>> into a filesystem (RAM
>> based perhaps) to begin with from whichever process
>> creates/manages these
>> data objects?
>>
>> And then access them as:
>>
>>         /abc.html
>>         /xyz.html
>>         etc.
>>
>> If you cannot change the way the pages are
>> referenced (ie. you must use a
>> GET parameter instead of a page name) then use
>> Apache's URL rewrite so:
>>
>>     /fetchpage.html?page=abc
>>     /fetchpage.html?page=xyz
>>
>> Becomes:
>>
>>     /abc.html
>>     /xyz.html
>>
>> And then you don't even need to have the PHP engine
>> compiled into, or
>> invoked from Apache at all.
>>
>> I would imagine that would be many, many times
>> faster.
>>
>> Jamie.
>>
>> ----- Original Message ----- 
>> From: "Jeevan _" <jeevan at gmail.com>
>> To: <memcached at lists.danga.com>
>> Sent: Sunday, July 10, 2005 3:18 AM
>> Subject: Faster way to serve up simple requests?
>>
>>
>> I have an extremely simple page that basically takes
>> one value passed
>> as a get, fetches that key from memcached and serves
>> the result as a
>> page (the pages are less than 10KB each). There's
>> basically no
>> processing involved and it's a page that gets hit
>> numerous times per
>> second.
>>
>> Right now I'm using Apache + PHP + mcache (the PHP
>> extension) to do
>> this simple fetch-from-memcached-and-serve routine
>> but it seems
>> extremely wasteful to use apache and php for such a
>> small, simple
>> task.
>>
>> My question is: are there any smaller (less resource
>> consuming)
>> programs out there that can perform this task?
>>
>
>
>
>
> ____________________________________________________
> Sell on Yahoo! Auctions - no fees. Bid on great items.
> http://auctions.yahoo.com/
>


More information about the memcached mailing list