How to find current connection pool size on heroku

后端 未结 2 1368
不思量自难忘°
不思量自难忘° 2021-02-02 10:32

We have a rails 3.2(.11) app with many dynos running on the heroku bamboo stack, connecting to a MySQL RDS server. There seem to be some issues with our current database connect

2条回答
  •  醉话见心
    2021-02-02 11:31

    This information is available via an interface in Rails https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_handling.rb#L98-L106 it is in Rails 3+

    ActiveRecord::Base.connection_config
    # => {:adapter=>"postgresql", :encoding=>"utf8", :pool=>5, :host=>"localhost", :database=>"triage_development"}
    

    You can use this to get the current pool size without needing to eval or relying on the existence of an unexposed instance variable however in rails 3 it may return nil if it hasn't been explicitly set

    ActiveRecord::Base.connection_config[:pool]
    # => 5
    

提交回复
热议问题