【问题标题】:Occurred error 503 when testing my Tornado app implementing the Coroutine feature测试我的 Tornado 应用程序实现协程功能时出现错误 503
【发布时间】:2015-08-22 12:22:34
【问题描述】:

我正在构建一个应用协程功能的 Tornado Web 应用程序。为了测试应用程序的性能,我使用了 Siege。但是,使用 Siege 调用 URL 时出现了许多 503 错误。顺便说一句,我的应用在 Raspberry Pi 上运行。

我的应用程序的 sn-p:

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

那么,我是否省略了一些设置?

如果您能指出我的应用程序出了什么问题,我将不胜感激。 非常感谢。

【问题讨论】:

  • 我的看法,PI的性能问题。在开始服务之前。可以通过 SSH 连接来检查内存和 cpu 的状态。
  • 不过,我用Siege测试了同步Handler,执行没有错误。
  • 你的电源可能是usb out? HTTP 503: Service Temporarily Unavailable 所以没有错误,冻结的应用程序。当您收到错误时,请尝试 ssh。对于所有性能有效性。 @zeck
  • 在台式电脑上试用代码。检查资源,稍后提交给 PI。

标签: python asynchronous tornado siege


【解决方案1】:

我把url改成http://www.google.com,没有出现503错误。我还在mac上测试了我的应用程序,它运行良好。因此,我认为这些错误是由我获取数据的位置引起的。

无论如何,非常感谢你,SDilmac。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-05
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多