python - How to increase connection pool size for Twisted? -
I am using twisted 8.1.0 as a socket server engine. Reactor - Apol database server is MySQL 5.0.67. OS - Ubuntu Linux 8.10 32-bit
In the /etc/mysql/my.cnf
:
max_connections = 1000
< / Pre>In source code:
adbapi.ConnectionPool ("MySQLdb", ..., use_unicode = true, charset = 'utf8', cp_min = 3, cp_max = 700, Cp_noisy = false]
But in reality, I can only see 200 (or less) open connections (
show processist
) when applications are under heavy load This is not enough for my app: (As I have seen that this is the limit of thread pools. Any ideas?
As you suspect, this is probably a threading problem. Thread pool determines an upper limit for the number of threads in the thread, however, your process is likely to run from this limit Out of less memory, around 200 threads in your case, because each thread has its own stack, the total memory used by your process hits the system limit and no thread is created. can.
Before you run your program, you can check it by adjusting the stack size setting (I am using bash
), i.e.
$ Ulimit - A core file size (block, -C) 0 data sized size (kbytes, -d) Unlimited maximum good (-e) 0 file size (block, -f) Unlimited pending signals (-i) 32750 Maximum lock memory (kbytes, -l) 32 Maximum memory size (KB tes, -m) Unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX messaging (Bytes, -c) 819200 Maximum RT priority (-r) 0 stack size (kilobyte, -s) 10240 CPU time (seconds, -T) Unlimited maximum user processes (-U) 32750 virtual memory (kbts, -v) Unlimited file lock (-x) unlimited
You can see that the default stack size is 10240K on my machine and I have found that I can make around 300 threads with this setting. Adjusting the stack size to 1024K (using the ulimit -s 1024
) I can create about 3,000 threads.
You can get some information about the thread construction limits on the system by using this script:
this resolves your problem, it will depend on the memory requirements of the connectionflat
threads.
Comments
Post a Comment