Inspired by Justin Lilly, I spent some time
looking at various ways of running python web applications with an eye
to performance. Nicholas Piël has done some great
work testing and
documenting many of
them. Gevent looks like a great option as does CherryPy, but uWSGI
caught my eye because it provides an nginx module and I’m already
running lots of nginx. Since its fairly new, my stock nginx from the
Ubuntu Karmic repository doesn’t come with uWSGI, but compiling it in is
trivial.
So I’ve added uwsgi and nginx + uwsgi to my launchpad
ppa for anyone out
there who’d like to give it a spin on Karmic. My initial impressions are
very positive. If you want to try it out, you can add my ppa to your apt
sources and simply run:
sudo apt-get install nginx uwsgi
Continue reading »
The nginx build in the official
ubuntu package repository is somewhat out-of-date, so I built my own
package from source using
0.7.59. I’m
going to provide it here in case anyone else would like it. One of the
new features I like is the
try_files
directive. Here’s an example of what I’m doing using 0.6.35, the full
post is here
http://lithostech.com/lighten-apaches-load-nginx:
location / {
root /var/www/fresnobeehive.com;
proxy_set_header X-Forwarded-For $remote_addr;
if (-f $document_root/beehive$uri) {
rewrite (.*) /beehive$1 break;
}
if (-f $request_filename) {
break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $document_root/beehive$uri/index.html) {
rewrite (.*) /beehive$1/index.html break;
}
if (!-f $request_filename) {
proxy_pass http://fresnobeehive.com:8080;
break;
}
}
Continue reading »
Since we’ve been on
slicehost, I’ve been forced to play the role of
system administrator since we don’t have a real one. One problem I’ve
run into is the long string of legacy applications that I have to
support. Some of them I wrote, and some of them I inherited. For many
reasons, they’re often organized and run in sub-optimal ways.
Separating your static and dynamic content is a good habit to get into
when you’re building scalable web applications. Static content is highly
portable because it can live without context. You can serve it from
anywhere and nobody knows the difference. When your site starts to get
huge traffic, you can easily offload your static content to a
CDN if you host
it in an easy-to-separate way using an URL like static.domain.com or
domain.com/static.
Continue reading »