On Tue, Jul 31, 2012 at 12:32:31PM +0200, Marco Sehrer [
ninjaconcept.com] wrote:
> Hi Group,
Hello Marco,
> we have a lot of LocalParticipants which need to connect Postgres (via ActiveRecord).
> Trying to run them multithreaded leads to too many postgres connections quite fast:
>
> postgres.log:
> FATAL: sorry, too many clients already
>
> Finally we run all Participants connecting to postgres via:
>
> def do_not_thread
> true
> end
Well done, limiting the participants to use the same thread as the worker
should limit them to use the one connection bound to the thread (IIRC that's
how activerecord does its connection management).
Thanks for sharing the tip!
> regardless of multithreaded or not I encountered the following warning:
>
> postgres.log
> LOG: unexpected EOF on client connection
Sorry, I don't know what your participant looks like, how db-intensive it is.
I'd google for that error message, maybe pitching in "activerecord".
> btw. our Postgres (version 9.1) max_connections is set to 100.
> the scenario happens regardless of the number of ruote-workers (1-5)
Well, Ruby runtimes won't share connections...
By scenario, do you mean the scenario with #do_not_thread set to false that
triggers the "FAIL: too many clients already" or the scenario where
#do_not_thread is set to true and triggers "LOG: unexpected EOF"?
I am sorry, I have trouble understanding the variant articulation in your
report.
Best regards,
--
John Mettraux -
http://lambda.io/jmettraux