Gearbox freeze after client connection terminate earlier

22 views
Skip to first unread message

tr.er...@gmail.com

unread,
Apr 8, 2015, 4:53:42 PM4/8/15
to turbo...@googlegroups.com
Hi there,

  I am trying to use TG Gearbox for production site and encounter the following problem: when i am trying to open many pages at once and abruptly terminate connections my server will freeze and stop responding without coming back (manual restart of gearbox is needed). The same occur if i just let my web site run for a while.

  When such freezing happened attempt to retrieve index page from server machine itself with wget give me following output (see below) - so it looks like connection got accepted but no response process run (it will eventually terminate with timeout error). Also: the page that my wget script tries to retrieve is static page from public/ dir so it does not require DB access. Therefor i doubt that database issues is responsible for this problem.

  What will be the best way to debug this? I have tried to look at the logs but nothing unusual is logged just before the freezing occur. Is there is any config options that i should try to tweak?

  Also, am i wrong in my attempt of using gearbox for production site? Was it intended for debug/devel only? And therefor should i just try switching to Apache instead? Using Gearbox is quite convenient because i can see all the error messages printed so i would like to continue using it if possible.

  Thank you,

Ernie.

--2015-04-08 16:33:46--  http://127.0.0.1:8092/myfiles/test
Connecting to 127.0.0.1:8092... connected.
HTTP request sent, awaiting response... 

Alessandro Molina

unread,
Apr 12, 2015, 9:24:17 AM4/12/15
to TurboGears
Are you trying to use gearbox#wsgiref for production?

Using egg:gearbox#wsgiref in [server:main] is greatly discouraged, that is a development only single process, single thread HTTP/1.0 server. As you can guess if one for your clients leaves the connection open (or doesn't properly terminate it) you will end up with the single thread being blocked on waiting for that client and unable to satisfy other requests.

If you want to go with a simple plain python solution I suggest you try egg:waitress#main (provided by waitress package), otherwise if you need to totally avoid other packages at least enable the "wsgiref.threaded = true" options insid  [server:main] as documented by https://github.com/TurboGears/gearbox#gearbox-http-servers That will provide a multithreaded server forking a thread for each request. It's highly inefficient when compared to a thread pool based server, but will at least prevent a single client from blocking the entire webapp.

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Ernie Lee

unread,
Apr 13, 2015, 12:10:45 PM4/13/15
to turbo...@googlegroups.com
Thank you for info Alessandro! I was indeed tried to use gearbox. I will see if 'waitress' package and wsgiref.threaded option helps.

Related question: i was investigating Apache mod-wsgi as hosting solution and documentation suggests using at least two Apache daemon processes so one can continue to serve pages while other being restarted. However my application uses TG app_globals, will it work correctly when deployed with two processes using mod_wsgi? Or will i ends up with two processes, both having its own copies of app_globals objects? 

(if this will work correctly, i am curious how is this implemented?)

Thanks,

Ernie.

--
You received this message because you are subscribed to a topic in the Google Groups "TurboGears" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/turbogears/hjCaGfXJ6Qc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to turbogears+...@googlegroups.com.

Alessandro Molina

unread,
Apr 16, 2015, 6:27:16 PM4/16/15
to TurboGears
When using multiple processes, each process will have its own copy of tg.app_globals.
When using multiple threads instead, the threads will share the same tg.app_globals and you should avoid writing there after bootstrap.

Reply all
Reply to author
Forward
0 new messages