Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
594c1133
Unverified
Commit
594c1133
authored
6 years ago
by
Sameer Al-Sakran
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #7582 from happy-camper/heroku-2x-dyno-config
Add memory constraints for a 2x dyno
parents
fdc37629
c1e8642d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/start
+22
-7
22 additions, 7 deletions
bin/start
with
22 additions
and
7 deletions
bin/start
+
22
−
7
View file @
594c1133
...
...
@@ -82,15 +82,30 @@ if [ ! -z "$RDS_HOSTNAME" ]; then
export
MB_DB_PORT
=
$RDS_PORT
fi
# Determine whether we're on Heroku on a free, hobby, or
1
x dyno
.
# Determine whether we're on Heroku on a free, hobby,
1x dyno
or
2
x dyno
#
# We set $HEROKU in the Procfile; we know we're on a baby dyno if the process limit is 256 per user.
# We set $HEROKU in the Procfile, so we know we're on Heroku when started from the
# Procfile.
#
# On a baby dyno we need to override the $JAVA_OPTS and give it a slightly lower memory limit because Heroku tends to think
# we can use more memory than we actually can. It defaults to giving us 300m but that still ends up going over the 512MB
# limit for the dyno. Set a few other additional options to minimize memory usage as well.
if
[
-n
"
$HEROKU
"
]
&&
[
`
ulimit
-u
`
=
256
]
;
then
JAVA_OPTS
=
"
$JAVA_OPTS
-Xmx248m"
# This seems to be the right amount that prevents the dyno from going over the quota
# We need to override the $JAVA_OPTS and give it a slightly lower memory limit
# because Heroku tends to think we can use more memory than we actually can.
if
[
-n
"
$HEROKU
"
]
;
then
echo
" -> Heroku detected"
if
[
`
ulimit
-u
`
=
256
]
;
then
# free, hobby or 1x dyno, it defaults to giving us 300m but that still ends
# up going over the 512MB limit for the dyno.
echo
" => 1x dyno"
JAVA_OPTS
=
"
$JAVA_OPTS
-Xmx248m"
# This seems to be the right amount that prevents the dyno from going over the quota
fi
if
[
`
ulimit
-u
`
=
512
]
;
then
# 2x dyno, it defaults to giving us 800m but that still ends
# up going over the 1024MB limit for the dyno.
echo
" => 2x dyno"
JAVA_OPTS
=
"
$JAVA_OPTS
-Xmx496m"
# This seems to be the right amount that prevents the dyno from going over the quota
fi
# Set a few other additional options to minimize memory usage as well.
JAVA_OPTS
=
"
$JAVA_OPTS
-XX:-UseGCOverheadLimit"
# Disable limit to amount of time spent in GC. Better slow than not working at all
JAVA_OPTS
=
"
$JAVA_OPTS
-XX:+UseConcMarkSweepGC"
# ConcMarkSweepGC seems to cause less OOM issues in my testing on low-mem Heroku envs
JAVA_OPTS
=
"
$JAVA_OPTS
-XX:+CMSClassUnloadingEnabled"
# Not 100% sure this does anything in Java 8 but if it does, we want to enable it
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment