6

Bjoern不应该比Gunicorn更快吗?

简单应用程序.py

from flask import Flask, request, jsonify

app = Flask(__name__)


@app.route('/suggest/', methods=['POST'])
def hello():
    content = request.get_json()
    return jsonify(**content), 200

app_server.py

import bjoern
import os
import signal
from simple_app import app

host = '0.0.0.0'
port = 5000
NUM_WORKERS = 2
worker_pids = []


bjoern.listen(app, host, port)
for _ in xrange(NUM_WORKERS):
    pid = os.fork()
    if pid > 0:
        # in master
        worker_pids.append(pid)
    elif pid == 0:
        # in worker
        try:
            bjoern.run()
        except KeyboardInterrupt:
            pass
        exit()

try:
    for _ in xrange(NUM_WORKERS):
        os.wait()
except KeyboardInterrupt:
    for pid in worker_pids:
        os.kill(pid, signal.SIGINT)

将 Bjoern 服务器运行为:

python app_server.py

将 Gunicorn 运行为:

gunicorn -w 2 --bind 0.0.0.0:5000 simple_app:app --timeout 90

主要数据:

Gunicorn:请求 7.53 毫秒最高 10 秒平均值

Bjoern:请求 100 万 24秒最高 10 秒均值

独角兽:: Gunicorn 请求持续时间

独角兽统计

比约恩::

比约恩请求持续时间

比约恩数据

节点的配置都是ec2实例:(使用一个核心运行app_server,另一个运行tsung)

Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-115-virtual x86_64)

vCPU 数量:2

4

1 回答 1

8

试瓶+bjoern,真的很快。还有瓶子 + gunicorn + meinheld 工人

瓶子比烧瓶快

瓶子:http ://bottlepy.org/docs/dev/

meinheld:https ://github.com/mopemope/meinheld

每秒请求数:

瓶子-py3 408,379

烧瓶-py3 124,800

信息:https www techempower.com/benchmarks/#section=data-r13&hw=ph&test=plaintext

于 2017-01-09T09:07:06.313 回答