Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.04; 'php.': 0.07; 'run,': 0.07; 'subject:Question': 0.07; 'scripts': 0.09; 'python': 0.09; 'assumed': 0.09; 'received:mail- qc0-f174.google.com': 0.09; 'script,': 0.09; 'scripts,': 0.09; 'solution,': 0.09; 'cc:addr:python-list': 0.10; 'producing': 0.15; 'fine.': 0.16; 'gilles': 0.16; 'modules,': 0.16; 'oct': 0.16; 'otoh,': 0.16; 'rerunning': 0.16; 'tjg': 0.16; 'traffic,': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'tim': 0.18; '(or': 0.18; 'written': 0.20; 'not,': 0.21; 'amounts': 0.22; 'http': 0.22; "user's": 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; 'options': 0.27; "doesn't": 0.28; 'run': 0.28; 'hosting': 0.28; 'cgi': 0.29; 'directly,': 0.29; 'running.': 0.29; 'usable': 0.29; 'url:mailman': 0.29; 'case,': 0.29; "i'm": 0.29; 'usually': 0.30; 'stuff': 0.30; 'expect': 0.31; 'url:python': 0.32; 'file': 0.32; 'generally': 0.32; 'running': 0.32; 'url:listinfo': 0.32; 'choosing': 0.33; 'front': 0.33; 'likely': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'server': 0.35; 'faster': 0.35; 'process,': 0.35; 'protocol': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'anything': 0.36; 'should': 0.36; 'too': 0.36; 'possible': 0.37; 'does': 0.37; 'why': 0.37; 'rather': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'behind': 0.38; 'some': 0.38; 'nothing': 0.38; 'performance': 0.39; 'takes': 0.39; 'called': 0.39; 'little': 0.39; 'where': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'url:mail': 0.40; 'your': 0.60; 'capable': 0.63; 'limit': 0.65; 'experience.': 0.65; 'else.': 0.65; 'incoming': 0.69; 'expectations': 0.71; '(your': 0.84; 'shared,': 0.84; 'subject:long': 0.84; 'subject:running': 0.84; 'together,': 0.84; 'to:addr:mail': 0.91; 'average': 0.93; 'response,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=B8QPvO6hWW4Sb4RkQ4vuBL4yQcv06FiNPleGDVFev/A=; b=eb9sMUMgreHOLZRPtJwrzP8RdcuFQ5jOMfTsUrkw3+6m//C8hL0BwXJAq2fK8PIXGB e/ED78ieLITLaPBhlCmLlUN9SoDvkolzOJAjv/AglapQW8nnThVqJSr77AxEjg5x+yG7 cP7oEKwu7nfFdW58S+GBwY+pKnA8hKaE5Y4fLPyXr7oaqtRa/BVt43hjB2XiN/RKVnkr b2RKr/NBOOKiWpkpHsmaPww6bI+qnFJmWbQTMcew0Nh9moVaQ/NRi8416J9/cAvqFqki uIQbPtcGDG2DbSNsKzVs57IooupUhurluxtNhmBcM62m7IZ34H8GyZfAebBgqEB5A234 R3CQ== MIME-Version: 1.0 In-Reply-To: <50892A82.2070206@timgolden.me.uk> References: <50892A82.2070206@timgolden.me.uk> Date: Thu, 25 Oct 2012 08:53:11 -0400 Subject: Re: Question about long-running web scripts From: David Hutto To: Tim Golden Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351169594 news.xs4all.nl 6847 [2001:888:2000:d::a6]:41491 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32123 On Thu, Oct 25, 2012 at 8:03 AM, Tim Golden wrote: > On 25/10/2012 12:45, Gilles wrote: >> I'd like to check something about running Python web applications. >> >> Generally speaking, the reason scripts run faster when called >> through FastCGI or the mod_* modules, is because the interpreter is >> already up and running. But when running PHP scripts, this does >> nothing about fetching the file from disk, recompiling, rerunning it, >> and usually reconnecting to the database. >> I'd say that is the same as py, unless it's a cron job to limit script iterations >> OTOH, Python web scripts can be written as long-running scripts: In >> this case, what is the added-value of using FastCGI? Why can't the >> web server simply call the Python script directly, just like CGI? The server should call a the script, or script.sleep() There are also server options to setup when a script is run, other than a cron jo for php. > > (Your question is a little confused at the end. I'm choosing to > understand: why can't we just run Python one-shot, like CGI? The likely > alternative meaning is: why can't the incoming request be routed to an > already-running Python program -- which is not, of course, what CGI > generally does. Hence my confusion). > > The answer is: it can. CGI is a protocol rather than anything else. In > front of a CGI exchange is the browser (or some other web client). > Behind it is some program which is capable of producing a valid HTTP > response, including a Python program. > > It's perfectly possible to run a usable website against Python running > one-shot. You won't get terrific performance out of it, but for a > website which doesn't expect humungous amounts of traffic, it'll work fine. > > The amount of time it takes a half-decent, even shared, server to start > up a Python process, connect to a database, pull stuff together, and > send a response will likely not impact on an average user's experience. > As long as too many of them don't try to do that at the same time. > Exactly where the line is drawn will depend on your particular hosting > solution, your assumed traffic, and your users' expectations as to > responsiveness. > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com