问题描述
我想在具有8个核心的AWS Linux服务器上使用上述3个非阻塞服务器中的任何一个.在任何文档中都不清楚SMP是在各自的helloworld的掩盖下还是在其他示例中实施的.
I'd like to use any one of the 3 mentioned non-blocking servers on an AWS Linux server with 8 cores. It's not clear in any of the documentation whether SMP is implemented under the covers in the respective helloworld or any other examples.
例如,此飓风helloworld没有提及内核或SMP或每个内核的线程.
For example, this cyclone helloworld mentions nothing about cores or SMP or threads per core.
import cyclone.web
class MainHandler(cyclone.web.RequestHandler):
def get(self):
self.write("Hello, world")
class Application(cyclone.web.Application):
def __init__(self):
cyclone.web.Application.__init__(self, [(r"/", MainHandler)],
xheaders=False)
或者这个扭曲的人:
from twisted.web import server, resource
from twisted.internet import reactor
class HelloResource(resource.Resource):
isLeaf = True
numberRequests = 0
def render_GET(self, request):
self.numberRequests += 1
request.setHeader("content-type", "text/plain")
return "I am request #" + str(self.numberRequests) + "\n"
reactor.listenTCP(8080, server.Site(HelloResource()))
reactor.run()
龙卷风...
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
实际上,很难确定它们是否是非阻塞的.
In fact, its difficult to determine whether those are non-blocking or not.
推荐答案
Tornado的HTTPServer使用bind(port)
和start(num_procs)
方法支持多进程模式. http://www.tornadoweb.org/en/stable/tcpserver.html#tornado.tcpserver.TCPServer.start
Tornado's HTTPServer supports a multi-process mode, using the bind(port)
and start(num_procs)
methods.
http://www.tornadoweb.org/en/stable/tcpserver.html#tornado.tcpserver.TCPServer.start
这篇关于开箱即用扭曲,旋风或龙卷风做SMP多核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!