I'm building a Tornado web application applying the Coroutine feature. To test the performance of the app, I used the Siege. However, It occurred many 503 errors when using Siege to call the URL. By the way, my app was running on an Raspberry Pi.
The snippet of my app:
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()
And the command:
siege 192.168.1.x:8888/async -c 5 -r 5
And the error message:
[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
So, did I omit some settings?
I would be very appreciated if you can point out what's wrong with my app. Thank you so much.
I changed the url to http://www.google.com, and no 503 errors occurred. I also tested my app on mac, and it worked well. Therefore, I think those errors resulted from where I fetch data.
Anyway, thank you so much, SDilmac.