Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Scaling and failover with Tornado

Received: by 10.224.183.69 with SMTP id cf5mr3477598qab.0.1323931336147;
        Wed, 14 Dec 2011 22:42:16 -0800 (PST)
X-BeenThere: python-tornado@googlegroups.com
Received: by 10.224.185.14 with SMTP id cm14ls8019179qab.7.gmail; Wed, 14 Dec
 2011 22:42:14 -0800 (PST)
Received: by 10.224.180.2 with SMTP id bs2mr3458236qab.1.1323931333985;
        Wed, 14 Dec 2011 22:42:13 -0800 (PST)
Received: by 10.224.180.2 with SMTP id bs2mr3458235qab.1.1323931333974;
        Wed, 14 Dec 2011 22:42:13 -0800 (PST)
Return-Path: <nhy...@googlemail.com>
Received: from mail-qw0-f64.google.com (mail-qw0-f64.google.com [209.85.216.64])
        by gmr-mx.google.com with ESMTPS id ev41si4667156qcb.3.2011.12.14.22.42.13
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 14 Dec 2011 22:42:13 -0800 (PST)
Received-SPF: pass (google.com: domain of nhy...@googlemail.com designates 209.85.216.64 as permitted sender) client-ip=209.85.216.64;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of nhy...@googlemail.com designates 209.85.216.64 as permitted sender) smtp.mail=nhy...@googlemail.com
Received: by qam2 with SMTP id 2so1714547qam.29
        for <python-tornado@googlegroups.com>; Wed, 14 Dec 2011 22:42:13 -0800 (PST)
MIME-Version: 1.0
Received: by 10.224.196.7 with SMTP id ee7mr421726qab.11.1323931333907; Wed,
 14 Dec 2011 22:42:13 -0800 (PST)
Received: by o1g2000vbe.googlegroups.com with HTTP; Wed, 14 Dec 2011 22:42:13
 -0800 (PST)
Date: Wed, 14 Dec 2011 22:42:13 -0800 (PST)
In-Reply-To: <41c70546-0914-4ab3-b2eb-60a291b10798@n6g2000vbg.googlegroups.com>
References: <0e9a9f2e-3e8b-448a-9238-0ed11364b287@i8g2000vbh.googlegroups.com>
 <CAP4kiWpkWKkVie-wh8mF-fUmndqBZ3e0dt7offR3E2kUqyXk=A@mail.gmail.com>
 <f255f838-10d9-4aec-998c-98b6cfa60c2d@q11g2000vbq.googlegroups.com>
 <CABJfL5jNtd3_d9f6c8omg7RTwHhX+Z1Jk70gh4ZMqQXs9XeQPw@mail.gmail.com>
 <CAFkYKJ6+wEcyYaBDAUrk4iDbC2EZVf8A8uUkpTgFX51s7zADmA@mail.gmail.com>
 <ddee1c75-4937-4485-b392-d0d6bb08d4e0@i6g2000vbe.googlegroups.com> <41c70546-0914-4ab3-b2eb-60a291b10798@n6g2000vbg.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.7 (KHTML,
 like Gecko) Chrome/16.0.912.59 Safari/535.7,gzip(gfe)
Message-ID: <9443efc5-22ff-431d-9db9-910248d22...@o1g2000vbe.googlegroups.com>
Subject: Re: Scaling and failover with Tornado
From: wataka <nhy...@googlemail.com>
To: Tornado Web Server <python-tornado@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Ok, since I had no replies to the code I posted above, I would like to
ask the forum how other users start their multiple tornado backends.
Maybe using the multiprocessing module is a bad idea?

On Dec 11, 4:12=A0pm, wataka <nhy...@googlemail.com> wrote:
> Thanks for the replies.
>
> So its best to keep on doing things the way I have been doing things,
> namely starting up a number of tornado backend processes on different
> ports.Like I mentioned above, I start the backends manually and allow
> Cherokee to handle the balancing and restarting if necessary, this
> works well sometimes. Could I automate the starting of the backends
> this way?
>
> import os
> import sys
> import tornado.ioloop
> import tornado.web
>
> from multiprocessing import Process
>
> class MainHandler(tornado.web.RequestHandler):
> =A0 =A0 def get(self):
> =A0 =A0 =A0 =A0 self.write("Hello, world")
>
> application =3D tornado.web.Application([
> =A0 =A0 (r"/", MainHandler),
> ])
>
> def start_server():
> =A0 =A0 =A0 =A0 tornado.ioloop.IOLoop.instance().start()
>
> def run_backends(number_of_ports, number_of_backends):
>
> =A0 =A0 for index in number_of_backends-1:
> =A0 =A0 =A0 =A0 app =3D application.listen('localhost', ports[index])
>
> =A0 =A0 =A0 =A0 Process(target=3Dstart_server, args=3D(app,)).start()
>
> if __name__ =3D=3D "__main__":
> =A0 =A0 NUMBER_OF_BACKENDS =3D 4
> =A0 =A0 PORTS =3D [800, 8001, 8002, 8003]
> =A0 =A0 run_backends(PORTS, NUMBER_OF_BACKENDS)