data_fabric icon indicating copy to clipboard operation
data_fabric copied to clipboard

Connection re-use

Open jason-o-matic opened this issue 13 years ago • 2 comments

We were running into connection limit issues with mysql when using multiple :shard_by values. We're sharding different models differently, but to the same set of shards, so we end up duplicating connections that are the same for all intents and purposes. I made a change that searches through shard_pools looking for an connection to the same DB before creating a new connection. This reduced our number of DB connections by half.

I also added a test for this. In order to ease my life when testing I setup everything with bundler, which I'm hoping you'll pull in as well.

Thanks, Jason

jason-o-matic avatar Feb 27 '12 21:02 jason-o-matic

This looks good. Can you extract the equivalent config finding logic into a separate method, #current_pool is getting kinda busy.

bpot avatar Mar 03 '12 02:03 bpot

I'm not actually working on the project I was using data_fabric for anymore. This pull request was actually sitting on the parent repo for many months before mperham noticed and recommended I send it over here, which didn't require any dev setup or work. Unfortunately it will probably be a while before I get a chance to work on it again.

jason-o-matic avatar Mar 05 '12 22:03 jason-o-matic