Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove dead code; reduce FiberPool size

Change-Id: Ib537481dbcba7d14a148b391eb9b7445cfd6f8f2
  • Loading branch information...
commit c933aa364c042b421c0ef81a18cd206914e8a2f0 1 parent 813a3e4
@pietern pietern authored
View
8 cloud_controller/Gemfile
@@ -22,14 +22,6 @@ group :production do
# Get blocking postgres working for now, try nonblocking drivers when we have more time
# gem 'postgres-pr', '0.6.3'
# gem 'em_postgresql', '0.3.0'
-
- gem 'mysql2', '>= 0.2.6', :require => nil
- # mysql2 includes an EventMachine driver (mysql2/em), don't use em-mysqlplus.
- # To enable, set the :database_env :adapter to 'em_mysql2' in config/cloud_controller.yml
- #
- # Requires a Ruby with Fibers (1.9, rbx, etc), thin (or similar EM-driven appserver), and
- # rack-fiber_pool middleware. Additionally there is a patch applied via plugin if this
- # adapter is selected.
end
# EventMachine and async support
View
2  cloud_controller/Gemfile.lock
@@ -130,7 +130,6 @@ GEM
treetop (~> 1.4.8)
mime-types (1.18)
mocha (0.9.12)
- mysql2 (0.2.7)
nats (0.4.22)
daemons (>= 1.1.4)
eventmachine (>= 0.12.10)
@@ -211,7 +210,6 @@ DEPENDENCIES
em-redis (~> 0.3.0)
eventmachine!
mocha
- mysql2 (>= 0.2.6)
nats
nokogiri (~> 1.4.4)
pg
View
1  cloud_controller/app/subscriptions/dea_advertise_channel.rb
@@ -1,4 +1,3 @@
-
EM.next_tick do
NATS.subscribe('dea.advertise') do |msg|
View
3  cloud_controller/app/subscriptions/health_manager_channel.rb
@@ -1,4 +1,3 @@
-
EM.next_tick do
# Create a command channel for the Health Manager to call us on
@@ -13,8 +12,6 @@
NATS.subscribe('cloudcontrollers.hm.requests', :queue => :cc) do |msg|
begin
payload = Yajl::Parser.parse(msg, :symbolize_keys => true)
- # Notice the lack of a .resume call. The pool handles dispatching
- # the supplied block for us.
CloudController::UTILITY_FIBER_POOL.spawn do
App.process_health_manager_message(payload)
end
View
2  cloud_controller/config/application.rb
@@ -43,7 +43,7 @@ class Application < Rails::Application
unless Rails.env.test?
# Install FiberPool early in the chain. `rake middleware` to see the order.
- config.middleware.insert_before Rails::Rack::Logger, Rack::FiberPool, :size => 512
+ config.middleware.insert_before Rails::Rack::Logger, Rack::FiberPool, :size => 32
end
end
end
View
10 cloud_controller/config/boot.rb
@@ -26,12 +26,10 @@
# parts of the Rails bootstrap process. This file is also loaded
# by bin/cloudcontroller and by the HealthManager.
module CloudController
- # All fibers that are not associated with a Rack request MUST be spawned from
- # this pool if they plan on hitting the DB. It is registered with the
- # connection pool used with the em_mysql2 adapter and will ensure that
- # connections used by fibers spawned from this pool will be correctly
- # returned to the ActiveRecord connection pool.
- UTILITY_FIBER_POOL = FiberPool.new(500)
+ # All fibers not associated with request MUST be spawned from this pool if
+ # they hit the DB. This keeps the maximum number of concurrent fibers in
+ # check, and makes sure the number of database connections doesn't blow up.
+ UTILITY_FIBER_POOL = FiberPool.new(32)
class << self
def environment
View
27 cloud_controller/vendor/plugins/mysql_fiber_patch/active_record_fiber_patches.rb
@@ -1,27 +0,0 @@
-# These patches are required to make our version of ActiveRecord (included w/ rails3)
-# compatible with em_mysql2
-#
-# NB: Only require this file if your adapter is em_mysql2!
-#
-#
-module ActiveRecord
- module ConnectionAdapters
- class ConnectionPool
-
- # This method is called when there are no connections available and one is requested.
- # The original method attempts to return reserved connections to the connection pool as follows:
- # 1. S1 = The connection ids of all reserved connections (where connection id is actually a thread id)
- # 2. S2 = The set of alive thread ids
- # 3. S3 = S1 - S2 = The set of connection ids that belong to inactive threads
- # 4. Return all connections with ids in S3 to the connection pool
- # However, the em_mysql2 adapter remaps connection ids to fiber ids (as we typically have many fibers per thread).
- # This means that when the method is called S2 can *never* be a subset of S1 (since we are using fiber ids
- # instead of thread ids), and *all* connections will be returned to the pool.
- def clear_stale_cached_connections!
- # This calls out to the patched version introduced by em_mysql2, which checks with registered
- # fiber pools to determine which which connections belong to inactive fibers.
- remove_stale_cached_threads!(@reserved_connections) {|c_id, c| checkin c}
- end
- end
- end
-end
View
6 cloud_controller/vendor/plugins/mysql_fiber_patch/init.rb
@@ -1,6 +0,0 @@
-db_config = Rails.application.config.database_configuration[::Rails.env]
-if db_config['adapter'] == 'em_mysql2'
- require File.expand_path('../active_record_fiber_patches', __FILE__)
- ActiveRecord::ConnectionAdapters.register_fiber_pool(CloudController::UTILITY_FIBER_POOL)
-end
-
Please sign in to comment.
Something went wrong with that request. Please try again.