Tornado在OSX上失败,但在Ubuntu上工作

2024-10-04 01:28:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我们正在做龙卷风的性能测试。这是密码

import tornado.websocket
import tornado.ioloop
import tornado.web

class TestTornado(tornado.websocket.WebSocketHandler):
    def open(self):
        self.set_nodelay(True)
        pass

    def on_message(self, message):
        self.write_message(message)
        self.close()

    def on_close(self):
        pass

def main():
    applicationList = []
    applicationList.append((r"/ws", TestTornado))

    application = tornado.web.Application(applicationList)
    application.listen(8888)

    myIOLoopInstance = tornado.ioloop.IOLoop.instance()
    myIOLoopInstance.start()

if __name__ == "__main__":
    main()

我们正在用thor --amount 10000 --messages 100 ws://localhost:8888/ws进行测试

然而,在OSX中,它总是在7000个连接后或多或少地失败,但在Ubuntu上根本没有错误。注意,我说的是连接,而不是文件,所以这个问题与osx可以处理的最大打开文件数无关(它已经设置为1000000)。你知道吗

所以。。为什么会这样?在OSX上有什么配置我们可以更改以使其正常工作吗?你知道吗


Tags: importselfwebmessageclosewsmainon
1条回答
网友
1楼 · 发布于 2024-10-04 01:28:23

这是OSX本身的问题。这些参数应该会有帮助,但我们不再在OSX上测试,所以不确定。你知道吗

kern.ipc.maxsockbuf=4194304
kern.ipc.somaxconn=2048
kern.ipc.nmbclusters=2048
net.inet.tcp.rfc1323=1
net.inet.tcp.win_scale_factor=4
net.inet.tcp.sockthreshold=16
net.inet.tcp.sendspace=1042560
net.inet.tcp.recvspace=1042560
net.inet.tcp.mssdflt=1448
net.inet.tcp.v6mssdflt=1428
net.inet.tcp.msl=15000
net.inet.tcp.always_keepalive=0
net.inet.tcp.delayed_ack=3
net.inet.tcp.slowstart_flightsize=20
net.inet.tcp.local_slowstart_flightsize=20
net.inet.tcp.blackhole=2
net.inet.udp.blackhole=1
net.inet.icmp.icmplim=50

资料来源:https://rolande.wordpress.com/2010/12/30/performance-tuning-the-network-stack-on-mac-osx-10-6/

相关问题 更多 >