我正在构建一个应用协程功能的 Tornado Web 应用程序。为了测试应用程序的性能,我使用了 Siege。但是,使用 Siege 调用 URL 时出现了许多 503 错误。顺便说一句,我的应用程序在 Raspberry Pi 上运行。
我的应用程序片段:
import os
import tornado.web
import tornado.gen
import tornado.ioloop
import tornado.options
import tornado.httpclient
tornado.options.define("port", default=8888, help="message...", type=int)
url='http://..../'
class Async(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
client = tornado.httpclient.AsyncHTTPClient()
response = yield client.fetch(url)
self.write('%r' % response.body)
def main():
# Command line
tornado.options.parse_command_line()
app = tornado.web.Application(
[
(r'/async', Async)
],
debug=True,
autoreload=True
)
app.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
main()
和命令:
siege 192.168.1.x:8888/async -c 5 -r 5
和错误信息:
[E 150822 18:47:15 web:1908] 500 GET /async (192.168.1.3) 2045.97ms
[I 150822 18:47:15 web:1908] 200 GET /async (192.168.1.3) 3317.43ms
[E 150822 18:47:16 web:1496] Uncaught exception GET /async (192.168.1.3)
HTTPServerRequest(protocol='http', host='192.168.1.x:8888', method='GET', uri='/async', version='HTTP/1.1', remote_ip='192.168.1.3', headers={'Host': '192.168.1.9:8888', 'User-Agent': 'Mozilla/5.0 (apple-x86_64-darwin14.4.0) Siege/3.1.0', 'Connection': 'close', 'Accept': '*/*', 'Accept-Encoding': 'gzip'})
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/tornado/web.py", line 1415, in _execute
result = yield result
File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/usr/lib/python2.7/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 876, in run
yielded = self.gen.throw(*exc_info)
File "server.py", line 19, in get
response = yield client.fetch(url)
File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/usr/lib/python2.7/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
HTTPError: HTTP 503: Service Temporarily Unavailable
[E 150822 18:47:16 web:1908] 500 GET /async (192.168.1.x) 3645.07ms
那么,我是否省略了一些设置?
如果您能指出我的应用程序有什么问题,我将不胜感激。太感谢了。