Django lighttpd fastcgi 部署及小小的性能测试

分类-Web 琐事 十一月 23, 2009 10:24 957 Views 0 Comments
标签: Django Fastcgi Lighttpd

呃,弄的我要崩溃了,各种问题。。。不过最后还是弄出来了。。


安装 lighttpd

$ yum install lighttpd

$ yum install lighttpd-fastcgi

$ gvim /etc/lighttpd/lighttpd.conf

server.port = 80

server.bind = "127.0.0.1" 

# 此处不设置只设置端口的话,会提示端口已经占用,无法启用。

$HTTP["remoteip"] == "127.0.0.1" # 或者 $HTTP["host"] == 'localhost'

    server.document-root = "/home/waylybaye"
    fastcgi.server = (
        "/fastcgi.fcgi" => (
            "main" => (
                 "host" => "127.0.0.1",
                 "port" => 3033,
                # "socket" => "/home/waylybaye/fc/fc.sock",
                "check-local" => "disable"
            )
        ),
    )
    alias.url = (
        "/media" => "/home/waylybaye/fc/static"
    )

    url.rewrite-once = (
        "^(/.*)$" => "/fastcgi.fcgi$1",
    )
}


在项目目录下

$ python manage.py runfcgi method=threaded host=127.0.0.1 port=3033

$ serivce lighttpd start

然后访问 http://localhost/ 就OK 拉

 

性能测试

用ab 和  http_load 进行了一下测试

使用自带的服务器 python manage.py runserver 测试

峰值达到 160 requests/second

使用 lighttpd + fastcgi

可以达到 200 requests/second

SCGI 和 fastcgi 性能几乎一样

 

COMMENTS | 评论

自言自语  --  发表新文章 管理

Powered by pLite :)  由 Google AppEngine 强力驱动