V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
n37r06u3
V2EX  ›  Python

求个 django+nginx+gunicorn 配置优化

  •  
  •   n37r06u3 · 2015-04-05 12:53:27 +08:00 · 2243 次点击
    这是一个创建于 3322 天前的主题,其中的信息可能已经有所发展或是发生改变。
    已有配置如下

    /edit


    siege 测试有fail

    Transactions: 9796 hits
    Availability: 97.96 %
    Elapsed time: 52.50 secs
    Data transferred: 1.22 MB
    Response time: 0.80 secs
    Transaction rate: 186.59 trans/sec
    Throughput: 0.02 MB/sec
    Concurrency: 148.41
    Successful transactions: 9796
    Failed transactions: 204
    Longest transaction: 19.64
    Shortest transaction: 0.03

    FILE: /usr/local/var/siege.log
    You can disable this annoying message by editing
    the .siegerc file in your home directory; change
    the directive 'show-logfile' to false.
    $ siege -c 1000 -r 10 -u http://xxx.com/
    2 条回复    2015-04-05 17:55:10 +08:00
    msg7086
        1
    msg7086  
       2015-04-05 16:47:14 +08:00
    每秒186次不少了吧,实际运行的时候会有这个级别的并发量吗。
    另外建议先看一下是哪边拒绝了请求吧。目测是gunicorn的问题?
    ryd994
        2
    ryd994  
       2015-04-05 17:55:10 +08:00
    workers = multiprocessing.cpu_count()*2
    worker_processes 48;
    这两条不合适吧。nginx的worker process只要cpu数量就足够了,考虑后端的话甚至更少然后作cpu affinity
    tcp_tw_recycle tcp_tw_reuse 慎用
    Longest transaction 19秒,估计是后面顶不住了
    fail的话看看error log吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1324 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:01 · PVG 02:01 · LAX 11:01 · JFK 14:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.