令人惊叹的bjoern

标签:wsgi, bjoern

  最近由于业务量的增加,我们的rpc服务器偶尔会出现请求处理过慢的情况.所以我用想到了那个老外对主流wsgi服务器进行测试中表现最好的bjoern.之前是没有用过,今天把它安装到生产环境,处理速度确定提高不少.

项目地址

   https://github.com/jonashaag/bjoern

安装

安装前确保系统上已安装了 libev

centos7 安装 libev

yum install libev-devel 

ubuntu安装安装 libev

sudo apt-get install libev-dev 

然后就可以用pip安装bjoern了

pip install Bjoern

用法

# Bind to TCP host/port pair:
bjoern.run(wsgi_application, host, port)

# TCP host/port pair, enabling SO_REUSEPORT if available.
bjoern.run(wsgi_application, host, port, reuse_port=True)

# Bind to Unix socket:
bjoern.run(wsgi_application, 'unix:/path/to/socket')

# Bind to abstract Unix socket: (Linux only)
bjoern.run(wsgi_application, 'unix:@socket_name')

Alternatively, the mainloop can be run separately:

bjoern.listen(wsgi_application, host, port)
bjoern.run()

You can also simply pass a Python socket(-like) object. Note that you are responsible for initializing and cleaning up the socket in that case.

bjoern.server_run(socket_object, wsgi_application)
bjoern.server_run(filedescriptor_as_integer, wsgi_application)

附录

老外的测试报告地址:https://blog.appdynamics.com/engineering/a-performance-analysis-of-python-wsgi-servers-part-2/

由于网络问题,访问有时很慢,所以把几个图放在下面:

Written on 2019-03-25
上篇: centos7上搭建lsyncd服务
下篇: manjaro上安装vmware遇到的问题及解决