Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
306d2dee
Commit
306d2dee
authored
Oct 25, 2017
by
Jeremy Morrell
Committed by
Jeremy Morrell
Oct 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect when WEB_CONCURRENCY is way too high
parent
2403875f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
WEB_CONCURRENCY.sh
profile/WEB_CONCURRENCY.sh
+19
-0
run
test/run
+9
-0
No files found.
profile/WEB_CONCURRENCY.sh
View file @
306d2dee
...
...
@@ -4,6 +4,9 @@ calculate_concurrency() {
WEB_CONCURRENCY
=
${
WEB_CONCURRENCY
-
$((
MEMORY_AVAILABLE/WEB_MEMORY
))}
if
((
WEB_CONCURRENCY < 1
))
;
then
WEB_CONCURRENCY
=
1
elif
((
WEB_CONCURRENCY
>
100
))
;
then
# Ex: This will happen on Dokku on DO
WEB_CONCURRENCY
=
1
fi
echo
$WEB_CONCURRENCY
}
...
...
@@ -23,6 +26,22 @@ detect_memory() {
fi
}
warn_bad_web_concurrency
()
{
local
memory
=
${
MEMORY_AVAILABLE
-
$(
detect_memory 512
)}
# No webserver will have 10000GB of RAM
if
[
$memory
-gt
"10000000"
]
;
then
echo
"Could not determine a reasonable value for WEB_CONCCURENCY.
This is likely due to running the Heroku NodeJS buildpack on a non-Heroku
platform.
WEB_CONCURRENCY has been set to 1. Please review whether this value is
appropriate for your application."
fi
}
warn_bad_web_concurrency
export
MEMORY_AVAILABLE
=
${
MEMORY_AVAILABLE
-
$(
detect_memory 512
)}
export
WEB_MEMORY
=
${
WEB_MEMORY
-512
}
export
WEB_CONCURRENCY
=
$(
calculate_concurrency
)
...
...
test/run
View file @
306d2dee
...
...
@@ -386,6 +386,15 @@ testConcurrencyCustomLimit() {
assertCapturedSuccess
}
# When /sys/fs/cgroup/memory/memory.limit_in_bytes lies and gives a ridiculous value
# This happens on Dokku for example
testConcurrencyTooHigh
()
{
LOG_CONCURRENCY
=
true
MEMORY_AVAILABLE
=
10000000000 capture
$(
pwd
)
/profile/WEB_CONCURRENCY.sh
assertCaptured
"Could not determine a reasonable value for WEB_CONCCURENCY"
assertCaptured
"Recommending WEB_CONCURRENCY=1"
assertCapturedSuccess
}
testInvalidNode
()
{
compile
"invalid-node"
assertCaptured
"Resolving node version 0.11.333"
...
...
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