Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7907b6b9
Commit
7907b6b9
authored
Apr 17, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configure connection pools for ActionCable
Use ActionCable's worker pool size to determine connection pool size
parent
0d07b239
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
8 deletions
+41
-8
cable/config.ru
cable/config.ru
+2
-0
config/gitlab.yml.example
config/gitlab.yml.example
+5
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+6
-0
config/initializers/action_cable.rb
config/initializers/action_cable.rb
+1
-0
lib/gitlab/runtime.rb
lib/gitlab/runtime.rb
+14
-8
spec/lib/gitlab/runtime_spec.rb
spec/lib/gitlab/runtime_spec.rb
+13
-0
No files found.
cable/config.ru
View file @
7907b6b9
...
@@ -3,4 +3,6 @@
...
@@ -3,4 +3,6 @@
require
::
File
.
expand_path
(
'../../config/environment'
,
__FILE__
)
require
::
File
.
expand_path
(
'../../config/environment'
,
__FILE__
)
Rails
.
application
.
eager_load!
Rails
.
application
.
eager_load!
ACTION_CABLE_SERVER
=
true
run
ActionCable
.
server
run
ActionCable
.
server
config/gitlab.yml.example
View file @
7907b6b9
...
@@ -1065,6 +1065,11 @@ production: &base
...
@@ -1065,6 +1065,11 @@ production: &base
# host: localhost
# host: localhost
# port: 3808
# port: 3808
## ActionCable settings
action_cable:
# Number of threads used to process ActionCable connection callbacks and channel actions
# worker_pool_size: 4
## Monitoring
## Monitoring
# Built in monitoring settings
# Built in monitoring settings
monitoring:
monitoring:
...
...
config/initializers/1_settings.rb
View file @
7907b6b9
...
@@ -717,6 +717,12 @@ Settings.webpack.dev_server['enabled'] ||= false
...
@@ -717,6 +717,12 @@ Settings.webpack.dev_server['enabled'] ||= false
Settings
.
webpack
.
dev_server
[
'host'
]
||=
'localhost'
Settings
.
webpack
.
dev_server
[
'host'
]
||=
'localhost'
Settings
.
webpack
.
dev_server
[
'port'
]
||=
3808
Settings
.
webpack
.
dev_server
[
'port'
]
||=
3808
#
# ActionCable settings
#
Settings
[
'action_cable'
]
||=
Settingslogic
.
new
({})
Settings
.
action_cable
[
'worker_pool_size'
]
||=
4
#
#
# Monitoring settings
# Monitoring settings
#
#
...
...
config/initializers/actioncable.rb
→
config/initializers/action
_
cable.rb
View file @
7907b6b9
...
@@ -5,4 +5,5 @@ Rails.application.configure do
...
@@ -5,4 +5,5 @@ Rails.application.configure do
# we're running ActionCable as a standalone server
# we're running ActionCable as a standalone server
config
.
action_cable
.
mount_path
=
nil
config
.
action_cable
.
mount_path
=
nil
config
.
action_cable
.
url
=
Gitlab
::
Utils
.
append_path
(
Gitlab
.
config
.
gitlab
.
relative_url_root
,
'/-/cable'
)
config
.
action_cable
.
url
=
Gitlab
::
Utils
.
append_path
(
Gitlab
.
config
.
gitlab
.
relative_url_root
,
'/-/cable'
)
config
.
action_cable
.
worker_pool_size
=
Gitlab
.
config
.
action_cable
.
worker_pool_size
end
end
lib/gitlab/runtime.rb
View file @
7907b6b9
...
@@ -37,7 +37,7 @@ module Gitlab
...
@@ -37,7 +37,7 @@ module Gitlab
end
end
def
puma?
def
puma?
!!
defined?
(
::
Puma
)
!!
defined?
(
::
Puma
)
&&
!
defined?
(
ACTION_CABLE_SERVER
)
end
end
# For unicorn, we need to check for actual server instances to avoid false positives.
# For unicorn, we need to check for actual server instances to avoid false positives.
...
@@ -70,25 +70,31 @@ module Gitlab
...
@@ -70,25 +70,31 @@ module Gitlab
end
end
def
web_server?
def
web_server?
puma?
||
unicorn?
puma?
||
unicorn?
||
action_cable?
end
def
action_cable?
!!
defined?
(
ACTION_CABLE_SERVER
)
end
end
def
multi_threaded?
def
multi_threaded?
puma?
||
sidekiq?
puma?
||
sidekiq?
||
action_cable?
end
end
def
max_threads
def
max_threads
main_thread
=
1
main_thread
=
1
if
puma?
if
action_cable?
Puma
.
cli_config
.
options
[
:max_threads
]
+
main_thread
Gitlab
::
Application
.
config
.
action_cable
.
worker_pool_size
elsif
puma?
Puma
.
cli_config
.
options
[
:max_threads
]
elsif
sidekiq?
elsif
sidekiq?
# An extra thread for the poller in Sidekiq Cron:
# An extra thread for the poller in Sidekiq Cron:
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
Sidekiq
.
options
[
:concurrency
]
+
main_thread
+
1
Sidekiq
.
options
[
:concurrency
]
+
1
else
else
main_thread
0
end
end
+
main_thread
end
end
end
end
end
end
...
...
spec/lib/gitlab/runtime_spec.rb
View file @
7907b6b9
...
@@ -105,4 +105,17 @@ describe Gitlab::Runtime do
...
@@ -105,4 +105,17 @@ describe Gitlab::Runtime do
it_behaves_like
"valid runtime"
,
:rails_runner
,
1
it_behaves_like
"valid runtime"
,
:rails_runner
,
1
end
end
context
"action_cable"
do
before
do
stub_const
(
'ACTION_CABLE_SERVER'
,
true
)
stub_const
(
'::Puma'
,
Module
.
new
)
allow
(
Gitlab
::
Application
).
to
receive_message_chain
(
:config
,
:action_cable
,
:worker_pool_size
).
and_return
(
8
)
end
it
"reports its maximum concurrency based on ActionCable's worker pool size"
do
expect
(
subject
.
max_threads
).
to
eq
(
9
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment