Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the pool setting in the ActiveRecord tests a mistake? #160

Open
kswope opened this issue Jun 10, 2013 · 3 comments
Open

Is the pool setting in the ActiveRecord tests a mistake? #160

kswope opened this issue Jun 10, 2013 · 3 comments

Comments

@kswope
Copy link

kswope commented Jun 10, 2013

In the activerecord spec

https://github.com/igrigorik/em-synchrony/blob/master/spec/activerecord_spec.rb

There is a pool of 10 specified.

def establish_connection
    ActiveRecord::Base.establish_connection(
      :adapter => 'em_mysql2',
      :database => 'widgets',
      :username => 'root',
      :pool => 10
    )

But in the docs it says "If you need to control the connection pool size, use rack/fiber_pool."

Is this

:pool => 10

actually doing anything?

I'm also getting the impression from the spec and docs that this pooling happens automagically but I have a feeling it isn't

Is this construct still the proper way to utilize a pool, outside of rails, even when using em-synchrony?

ActiveRecord::Base.connection_pool.with_connection do
  User.find(1)
end
@kswope
Copy link
Author

kswope commented Jun 12, 2013

After a lot of stress testing I've determined that

:pool => X,      
:adapter => 'em_mysql2',

seems to be all you need for mysql connection pooling and it performs perfectly. I tested it by wrapping the relevant code in a bogus http server and blasting it with the likes of ab, httperf, and weighttp. You can clearly see
the connection pool at work in the mysql processlist.

I think this might be only the case if you use em-syncrony's ActiveRecord's client and ActiveRecord calls only, no cheating by grabbing a database connection from ActiveRecord and running raw queries.

This statement in the docs completely threw me off, and I'm not sure why its there - "If you need to control the connection pool size, use rack/fiber_pool."

I put my code here in case anybody could use it
https://github.com/kswope/em-synchrony-ar-pool-stress

@igrigorik
Copy link
Owner

I think this might be only the case if you use em-syncrony's ActiveRecord's client and ActiveRecord calls only, no cheating by grabbing a database connection from ActiveRecord and running raw queries.

Correct.

Anything else to resolve on this one? Have you resolved #159?

@kswope
Copy link
Author

kswope commented Jun 14, 2013

I haven't resolved 159 yet. If nobody else is having this problem, and there's nothing obvious to the experts that I'm doing something wrong, then I'll take another crack at it, it must be something unique to my situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants