i using sidekiq rails3. sidekiq runs 25 threads default. increase multi-thread limit, have done changing sidekiq.yml.
so, relation between pool value in database.yml , sidekiq multi-thread. maximun value of mysql pool. depends on server memory?
sidekiq.yml
:verbose: true :concurrency: 50 :pool: 50 :queues: - [queue_primary, 7] - [default, 5] - [queue_secondary, 3] database.yml
production: adapter: mysql2 encoding: utf8 reconnect: false database: db_name pool: 50 username: root password: root socket: /var/run/mysqld/mysqld.sock
each sidekiq job executes in 1 of 50 threads configuration. inside job, time activerecord model needs access database, uses database connection pool of available connections shared activerecord models in process. connection pool lets thread take connection or blocks until free connection available.
if have less connections available in activerecord database connection pool running sidekiq jobs/threads, jobs blocked waiting connection , possibly timeout (after ~ 5 seconds) , fail.
this why it's important have many available database connections threads in sidekiq worker process.
unicorn single-threaded, multi-process server - shouldn't need more 1 connection each unicorn back-end worker process.
however, database can handle many connections (depending on os, hardware, , configuration limits) need make sure distributing database connections needed , not exceeding maximum.
for example, if database limited 1000 connections, run 20 sidekiq processes 50 threads each , nothing else.
Comments
Post a Comment