[twisted] add an option to configure twisted's threadpool size
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 11 Jul 2011 12:39:05 +0200
changeset 7644 7a0914469618
parent 7643 f3e3892fc7e3
child 7645 cb2459aaa7d7
[twisted] add an option to configure twisted's threadpool size Twisted's threadpool size defaults to 10, which means we virtually try to serve up to 10 simulateneous requests but connection-pool size defaults to 4 on CW-server side. That means that under heavy load, chances are high that some HTTP queries end up with a 500 error code / connection-pool exhausted.
etwist/server.py
etwist/twconfig.py
--- a/etwist/server.py	Mon Jul 11 11:56:47 2011 +0200
+++ b/etwist/server.py	Mon Jul 11 12:39:05 2011 +0200
@@ -507,6 +507,7 @@
     # serve it via standard HTTP on port set in the configuration
     port = config['port'] or 8080
     interface = config['interface']
+    reactor.suggestThreadPoolSize(config['webserver-threadpool-size'])
     reactor.listenTCP(port, website, interface=interface)
     if not config.debugmode:
         if sys.platform == 'win32':
--- a/etwist/twconfig.py	Mon Jul 11 11:56:47 2011 +0200
+++ b/etwist/twconfig.py	Mon Jul 11 12:39:05 2011 +0200
@@ -90,6 +90,13 @@
           'help': 'run a pyro server',
           'group': 'main', 'level': 1,
           }),
+        ('webserver-threadpool-size',
+         {'type': 'int',
+          'default': 4,
+          'help': "size of twisted's reactor threadpool. It should probably be not too \
+much greater than connection-poolsize",
+          'group': 'web', 'level': 3,
+          }),
         ) + WebConfiguration.options)
 
     def server_file(self):