> At 04:40 PM 4/4/2001 -0700, Jack Moffitt wrote:
> >One thing I can't seem to find is caching. It's mentioned in UserKit,
> >but I dont' quite understand why a generic caching framework would be
> We don't have a generic caching framework although we probably should. (I
> say probably only because I would want to know that the resulting framework
> would help in many situations and cause few, if any, headaches. Just like
> all our other frameworks. :-) We probably won't know that until we write
Maybe a good start would be to take a look at what's in UserKit and
discuss how such a framework would function. I have a good idea in my
head about the kinds of operations I need. I have hack to hack these
together in past projects, generally using squid on top of apache
running php, or some other ugly mess.
> >I would like something that I can set expiry times for, and from then on
> >the adaptor would serve static content (which apache is very very good
> >at) or the app server would return cached content. Also, I would like
> >to be able to expire something explicity from any other component.
> The adapter? I had never thought about the adapter caching responses. An
> interesting thought. (But not on my upcoming projects list.)
Well the idea stems from using WebKit for the dynamic portions, and
using Apache for the static ones. You can eliminate some overhead (the
adaptor getting data from WebKit) and probably gain a bit of speed by
caching on the apache side of the adapter. Since the requests are
passed to the adapter anyway, it seems like an easy place to put some
caching logic, as it's least likely to cause damage elsewhere. If you
could tell the adaptor about expiry times (easy to do with standard
Expires headers) and communicate to it directly to explicity expire a
url, then I think it could be quite useful.
> Can you provide a more detailed example? Like what the "somethings" are? I
> mean are you always just talking about the total HTTP response from top to
> I usually cache Python instances and strings, for example. Like I will
> cache HTML templates that I loaded from disk, into a dictionary mapping the
> name to the content.
> Servlets are cached for you. They "expire" if the modification date on disk
> changes, although we don't currently check ancestor classes.
> Sessions also expire and you can even get inactive ones pushed out earlier
> than the expiration timeout.
Servlet code, sessions and stuff are things that need to be doen anyway,
and most other frameworks do this.
What I'm talking about primary is caching the output of pages or
sub-pages. Let's use the example of a page to be a PSP page that grabs
a story out of a database and presents it. And a sub-page might be a
PSP page that renders just the story in an html fragment. So we're
talking about caching teh document content.
If that story rarely changes, it makes little sense to fetch it from
the database everytime. It only makes since to dynamically generate it
when something in it has changed. For a page, this could mean that hte
footer changed, or the nav menu changed. and for a sub-page it could
mean that someone fixed a spelling error.
So you could have the page have a long expiry, and when the page
changes, you can tell the cache layer to mark it as old.
Some data is better with expiry times, like realtime song information
about what's playing on an internet radio station, or the current number
of unread messages you have. But some is better to cache all the time,
unless some external event happens. In applications that have
content-management capability, you know when the cache is valid or not,
because changes to the data are made by the application.
> >I find the caching missing in most architectures, but it's quite
> >important if you ever plan to scale anything, since most back end
> >databases dont' scale nearly as well as static files :)
> I cache quite a bit in both Webware and my other non-public projects, but I
> have been doing it as I go along.
Have there been any 'Case Studies' done for Webware? It would be
interesting to see how other people are handling the caching problem,
and maybe start thinking of a framework in that context.
> Getting back to UserKit, the kind of caching that is designed there (but
> not yet implemented) is probably a good example of what a general caching
> framework should do anyway.
I'll check it out.
> >Also, what support is there for multi-homed installations? Can the
> >adaptor pick between multiple back end webkits? That way you could have
> >two apache frontends, each going to the two webkit app servers. So that
> >if any one box on either tier went down, the whole system would still
> >work, and if everything was functioning, load would get spread pretty
> So you mean multiple back ends for fault tolerance and not for different
> apps. I haven't tried it yet.
> In theory, you could run WebKit on two boxes and Apache on two boxes. You
> could use mod_webkit with Apache and specify the two hosts in apache.conf.
> Then you could use a load balancer to hit the two web servers. You would
> want to push your sessions to 1, disk (shared by the app servers) or 2, a
> database. You get 1 out of the box, you get 2 if you grab Terrel Shumway's
> SessionSQLStore contrib (which should get integrated some day).
Are you saying that one of the current adaptors has some load balancing
logic built in? Can I specify two app servers that are peers in the
httpd.conf and have it round-robin or something between them?
Having two apache+Webware boxes each with a shared disk for sessions is
a reasonable solution. But it would be great to have 10 apache boxes,
each able to load balance between 2 webware servers, since static vs
dynamic content is generally a high ratio. A recent project I worked on
(which was SUPER dynamic i thought) turned out to be 85% static content.
Putting the session store into the database seems like a bad idea.
Databases are slow, and session information must be accessed constantly.
I think most of the loadbalancing stuff is being built with session
mapping logic now, so that it will recognize which server a session
You can see good diagrams of these kinds of relationships at
It shows several methods for load balancing, and this has got to be the
only applciation server + adaptor that I know of that can do these sorts
> >Just out of curiosity, has anyone done even informal benchmarking of
> >webware vs other app servers? And if not, are there any Python vs.
> >other languages (like java, php, perl) tests out there? I'm mostly
> >curious what the performance differences are.
> I reported some benchmarks in the Intro to Python9 paper, but haven't done
> any comparisons. Jay Love stressed WebKit and Zope many months ago and
> managed to get much better performance from WebKit and also cause Zope to
Yes, these are both good examples, but both python vs python :) As a
relative newcomer to the python world, I'm more interested in where it
sits amoungst the other competitors in scripting languages and in other
web languages. The http://www.cauco.com has some benchmarks of their server
vs. other servers but it would be interesting even to see some python vs
X tests even outside the scope of Webware.