推荐学习书目
› 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 · Apr 5, 2015 · 3005 views
    This topic created in 4190 days ago, the information mentioned may be changed or developed.
    已有配置如下

    /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 replies  •  2015-04-05 17:55:10 +08:00
    msg7086
        1
    msg7086  
       Apr 5, 2015
    每秒186次不少了吧,实际运行的时候会有这个级别的并发量吗。
    另外建议先看一下是哪边拒绝了请求吧。目测是gunicorn的问题?
    ryd994
        2
    ryd994  
       Apr 5, 2015
    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吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2742 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:11 · PVG 11:11 · LAX 20:11 · JFK 23:11
    ♥ Do have faith in what you're doing.