How to increase the connection pool size for Twisted?

I am using Twisted 8.1.0 as the server core. The reactor is an epol. MySQL database server 5.0.67. OS - Ubuntu Linux 8.10 32-bit

in /etc/mysql/my.cnf:

max_connections        = 1000

in source code:

adbapi.ConnectionPool("MySQLdb", ..., use_unicode=True, charset='utf8', 
                      cp_min=3, cp_max=700, cp_noisy=False)

But in fact, I see only 200 (or less) open connections ( SHOW PROCESSLIST) when the application is running under heavy load. This is not enough for my application :(

As I can see, this is a limitation for the thread pool. Any ideas?

+3
source share
1 answer

, , , . cp_max , , , , 200 . , , , .

, ulimit ( bash) , ..

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
max nice                        (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 32750
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
max rt priority                 (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 32750
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

, 10240K , , 300 . 1024 ( ulimit -s 1024) 3000 .

, script:

from thread import start_new_thread
from time import sleep

def sleeper():
    try:
        while 1:
            sleep(10000)
    except:
        if running: raise

def test():
    global running
    n = 0
    running = True
    try:
        while 1:
            start_new_thread(sleeper, ())
            n += 1
    except Exception, e:
        running = False
        print 'Exception raised:', e
    print 'Biggest number of threads:', n

if __name__ == '__main__':
    test()

, ConnectionPool.

+8

Source: https://habr.com/ru/post/1713337/


All Articles