Here are some notes on how to use Webware to gain maximum performance:
use Webware with Apache!
use mod_webkit, rather than the slower adaptors
keep the processing that actually occurs in WebKit to a minimum by serving all static requests directly from Apache / Squid. Only serve dynamic content from WebKit.
follow the Apache tuning guidelines (http://httpd.apache.org/docs/misc/perf-tuning.html)
if you have a smp server(s), WebKit might scale better if you run one WebKit process per processor to overcome Python's global interpreter lock. This will require multiple ports and multiple mod_webkit entries in your httpd.conf file. You'll need extra RAM to do this.
Use absolute paths rather than doing relative path calculations instead of doing them in Python code. If you have site global directories for your stylesheets, images, etc., but you're using mod_rewrite to send all requests to WebKit do something like this:
<VirtualHost_ *> ServerName www.calrudd.com ServerAlias calrudd.com DocumentRoot "/var/www/www.calrudd.com/public_html" <Location /WK> WKServer localhost 8086 SetHandler webkit-handler </Location> RewriteEngine on RewriteRule .*/GlobalImages_/(.*)$ /GlobalImages_/$1 [L,PT] RewriteRule .*/spacer.gif$ /GlobalImages_/spacer.gif [L, PT] RewriteRule .*/GlobalStylesheets/(.*)$ /GlobalStylesheets/$1 [L, PT] RewriteRule .*/GlobalJavascript/(.*)$ /GlobalJavascript/$1 [L, PT] RewriteRule .*/ImageStore/(.*)$ /ImageStore/$1 [PT] </VirtualHost>
This much easier and way more efficient than calculating these relative paths in your Servlet code. It allows you to do this:
<img src="/GlobalImages_/xx.jpg" width="XX" height="XX" />
rather than this:
<img src="${pathToRoot_}GlobalImage_/xx.jpg" width="XX" height="XX" />
use aggressive caching wherever possible:
in your app code
in your db access
in your html generation
no query strings wherever possible
encourage client-side caching of static data; see ServingStaticFilesEfficiently.
design your db schema and queries well
design your application well
use apache-bench and Steve Purcell's HTTPSession.py to profile your site and identify hotspots.
you'll probably identify a small number of URIs that eat up most of your processing time. If you really need to (and I doubt you will), you can achieve significant performance gains by hardwiring each of them to a particular WebKit port / process and bypassing all the URI-to-servlet mapping that WebKit usually does. To do this, you'll either need to hack WebKit yourself or use the experimental refactoring of Webware that I've been working on (search for WebwareExpRefactoring on the Wiki). If you use WebwareExpRefactoring, these hard-wired servlets can be run in the same process as your normal servlets.
keep the Python performance tips in mind while developing (http://manatee.mojam.com/~skip/python/fastpython.html)
Some helpful strategies are * use shortcut namebinding like this:
def __init__(self): self._lock = lock = Lock() self._lock_acquire = lock.acquire self._lock_release = lock.release def doSomething(self): self._lock_acquire() ... self._lock_release()
always convert globals to locals by using default args:
... # do something with currTime()
-- TavisRudd - 30 Mar 2002