gpt4 book ai didi

python - Bjoern v/s Gunicorn POST 请求

转载 作者:太空狗 更新时间:2023-10-30 02:27:18 26 4
gpt4 key购买 nike

Bjoern 不是应该比 Gunicorn 更快吗??

simple_app.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

应用服务器.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 秒平均值

unicorn :: Gunicorn Request Duration

Gunicorn Stats

比约恩::

Bjoern Request Duration

Bjoern Stats

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

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

vCPU 数量:2

最佳答案

试水瓶+bjoern,真快。还有 bottle + gunicorn + meinheld worker

瓶子比 flask 快

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

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

每秒请求数:

bottle-py3 408,379

flask -py3 124,800

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

关于python - Bjoern v/s Gunicorn POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41531707/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com