Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Memory limits by container #201

Merged
merged 2 commits into from
Dec 16, 2021
Merged

Set Memory limits by container #201

merged 2 commits into from
Dec 16, 2021

Conversation

DonRichards
Copy link
Member

@DonRichards DonRichards commented Dec 14, 2021

In the event of a memory leak this should prevent the server from taking over the host and crashing. It also should improve the host environment during build time, improving the stability and expanding the functionality of this build.

I have recently have seen blazegraph and cantaloupe complete consume all my RAM during the build process ultimately crashing docker and other apps. This may be due to something I was doing within the containers but it brought the idea to my attention that a memory leak could cripple a host machine if there is no limits set.

Running docker stats should output this. The focus is on MEM USAGE / LIMIT and MEM %.

CONTAINER ID   NAME                   CPU %     MEM USAGE / LIMIT   MEM %     NET I/O           BLOCK I/O         PIDS
a17f66002bfb   isle-dc_fits_1         0.90%     1.51GiB / 5GiB      30.19%    17kB / 0B         11.7MB / 15.4MB   50
c32664f04b09   isle-dc_activemq_1     0.64%     228.9MiB / 2GiB     11.17%    1.11MB / 1.07MB   3.49MB / 24.4MB   70
cbb19ba8435f   isle-dc_mariadb_1      2.20%     172.1MiB / 1GiB     16.81%    69.7MB / 804MB    9.72MB / 226MB    37
fa149fe62de3   isle-dc_houdini_1      0.55%     15.96MiB / 1GiB     1.56%     16.9kB / 0B       12.3kB / 13.9MB   17
ea787d3cf937   isle-dc_solr_1         0.55%     217.8MiB / 8GiB     2.66%     297kB / 23.8kB    76.8MB / 15.7MB   45
eaa3a58f1f38   isle-dc_hypercube_1    0.59%     15.98MiB / 512MiB   3.12%     16.1kB / 0B       36.9kB / 13.8MB   17
6fe92b3432ab   isle-dc_recast_1       0.56%     16.04MiB / 1GiB     1.57%     15.5kB / 0B       270kB / 13.9MB    17
777517051fbe   isle-dc_homarus_1      0.64%     16.01MiB / 1GiB     1.56%     15.5kB / 0B       123kB / 13.8MB    17
8b3ddc4d8dfa   isle-dc_alpaca_1       1.15%     357.8MiB / 2GiB     17.47%    3.19MB / 2.4MB    9.85MB / 16.7MB   104
994f27f972a5   isle-dc_watchtower_1   2.48%     10.61MiB / 2GiB     0.52%     14.9kB / 0B       18.2MB / 0B       13
5d2daeb8738f   isle-dc_cantaloupe_1   1.32%     732MiB / 5GiB       14.30%    14.4kB / 0B       6.81MB / 17.5MB   54
d082989faf8f   isle-dc_blazegraph_1   0.77%     1.202GiB / 5GiB     24.04%    984kB / 199kB     19.4MB / 494MB    71
20a73f7bc5d5   isle-dc_crayfits_1     0.56%     16.24MiB / 1GiB     1.59%     14.2kB / 0B       36.9kB / 13.8MB   17
8f97c66603e7   isle-dc_milliner_1     4.73%     28.03MiB / 1GiB     2.74%     6.22MB / 2.89MB   8.56MB / 13.9MB   18
35b0146533e1   isle-dc_matomo_1       0.60%     19.37MiB / 1GiB     1.89%     54.1kB / 129kB    147kB / 158MB     17
cb76f0b47c96   traefik                1.25%     19.19MiB / 8GiB     0.23%     6.95MB / 9.66MB   35.3MB / 0B       14
e9bdb01aca57   isle-dc_drupal_1       3.79%     103.3MiB / 5GiB     2.02%     814MB / 76.2MB    88.6MB / 75.7MB   18
4bd3035f6821   isle-dc_fcrepo_1       25.69%    850.7MiB / 5GiB     16.61%    5.07MB / 7.07MB   16.4MB / 20.9MB   77

What changed

Within the sample.env file is a variable for each one of these containers using the naming convention NAME_MEMORY_LIMIT.
Within each of the containers that a value can be set, a memory limit variable is added with a fallback value reflecting the software vendor's minimal requirements. This "fallback" value is for existing installations that don't already have the NAME_MEMORY_LIMIT variables within their .env file. This anticipates that possibility and doesn't prevent the build process from succeeding.

How to test

  • Before switching to this branch, run docker stats on isle-dc to see the normal operation.
  • All of the MEM USAGE / LIMIT should have a LIMIT that matches your host machine's RAM.
  • After switching to this pull request branch, run and either make up, docker-compose up -d or how ever you plan on testing this then run docker stats again and it should have limits that reflect the sample.env.
  • If you didn't build from scratch the LIMIT values should match those in the docker-compose.xxx.yml files. These are slightly different. The values in the YML files reflect the specified minimal requirements from the vendors. The sample.env values are slightly higher to improve build times (ideal configurations).

@DonRichards DonRichards requested a review from a team December 14, 2021 15:42
@DonRichards DonRichards changed the title Declare Memory limits by container Set Memory limits by container Dec 14, 2021
@DonRichards
Copy link
Member Author

DonRichards commented Dec 15, 2021

This is what the "LIMIT" looked like before I made these changes. My machine shows "15.35GiB" as the top limit for all containers.

CONTAINER ID   NAME                   CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O         PIDS
de4221a677e8   docker_homarus_1       0.28%     21.67MiB / 15.35GiB   0.14%     591kB / 23.9kB    267MB / 2.34GB    17
7f2d142f9369   docker_minio_1         0.05%     284.6MiB / 15.35GiB   1.81%     35.5MB / 36.7MB   7.42GB / 29.4GB   30
5f96fdae6cda   docker_mariadb_1       0.28%     192.3MiB / 15.35GiB   1.22%     84.5MB / 163MB    316MB / 2.85GB    12
a75868b0fd24   traefik                0.00%     15.88MiB / 15.35GiB   0.10%     74.5MB / 76.3MB   1.05GB / 32.8kB   15
62cff89aed93   docker_fits_1          0.39%     1.345GiB / 15.35GiB   8.76%     551kB / 0B        257MB / 2.43GB    50

@DonRichards DonRichards self-assigned this Dec 15, 2021
@seth-shaw-unlv
Copy link

Before:

CONTAINER ID   NAME                   CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O         PIDSeecb59878693   isle-dc_drupal_1       0.66%     16.15MiB / 3.844GiB   0.41%     1.66kB / 0B       2.64MB / 1.71MB   13
d8e1a25b6ba6   isle-dc_crayfits_1     0.57%     13.36MiB / 3.844GiB   0.34%     936B / 0B         311kB / 1.27MB    13
7b47237c027d   isle-dc_matomo_1       0.66%     13.85MiB / 3.844GiB   0.35%     9.3kB / 11.5kB    160kB / 1.41MB    13
57914ec7bff8   isle-dc_fcrepo_1       1.01%     375.3MiB / 3.844GiB   9.53%     18.8kB / 18.6kB   79.2MB / 1.36MB   68
cb380e87bd9b   isle-dc_blazegraph_1   0.82%     436.6MiB / 3.844GiB   11.09%    936B / 0B         38.4MB / 1.21MB   48
327b7322e9bb   isle-dc_watchtower_1   6.86%     11.08MiB / 3.844GiB   0.28%     936B / 0B         12MB / 0B         10
96d326e59084   traefik                0.00%     14.64MiB / 3.844GiB   0.37%     1.66kB / 0B       22.5MB / 0B       10
bd505403945d   isle-dc_cantaloupe_1   1.29%     470.3MiB / 3.844GiB   11.95%    936B / 0B         54.4MB / 2.57MB   45
b0150be85fa5   isle-dc_fits_1         0.81%     481.8MiB / 3.844GiB   12.24%    936B / 0B         18.4MB / 1.26MB   41
b5d8773abdf8   isle-dc_homarus_1      0.48%     13.2MiB / 3.844GiB    0.34%     936B / 0B         57.3kB / 1.28MB   13
0ee21a3d2ec9   isle-dc_milliner_1     0.59%     13.18MiB / 3.844GiB   0.33%     2.19kB / 0B       94.2kB / 1.3MB    13
38c7059933e6   isle-dc_houdini_1      0.53%     14.11MiB / 3.844GiB   0.36%     936B / 0B         4.24MB / 1.31MB   13
ca7fdcac943d   isle-dc_hypercube_1    0.61%     13.37MiB / 3.844GiB   0.34%     936B / 0B         336kB / 1.3MB     13
e8d2e67778b2   isle-dc_mariadb_1      1.18%     92.24MiB / 3.844GiB   2.34%     28.5kB / 25.2kB   22MB / 1.29MB     20
8ea3c10d4b81   isle-dc_activemq_1     0.71%     191MiB / 3.844GiB     4.85%     21kB / 14.4kB     34MB / 1.43MB     65
25226be82e78   isle-dc_solr_1         0.68%     198.3MiB / 3.844GiB   5.04%     936B / 0B         30.4MB / 1.34MB   42
98908dc00b47   isle-dc_recast_1       0.63%     13.27MiB / 3.844GiB   0.34%     936B / 0B         45.1kB / 1.29MB   13
25ba404bde52   isle-dc_alpaca_1       1.07%     338.9MiB / 3.844GiB   8.61%     13.9kB / 17.2kB   39.2MB / 1.69MB   100

After:

CONTAINER ID   NAME                   CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O         PIDS
0c10989cc54b   isle-dc_fcrepo_1       5.89%     544.8MiB / 3.844GiB   13.84%    4.78MB / 6.12MB   36.5MB / 5.53MB   67
ae3da339aa82   isle-dc_drupal_1       5.41%     80.38MiB / 3.844GiB   2.04%     764MB / 59.1MB    134MB / 6.69MB    14
94584a7cb755   isle-dc_crayfits_1     0.57%     8.117MiB / 1GiB       0.79%     1.73kB / 0B       680kB / 6.14MB    13
c7cde1a0e13a   isle-dc_matomo_1       1.22%     13.37MiB / 1GiB       1.31%     39.1kB / 129kB    81.4MB / 6.19MB   13
4a254c889f16   isle-dc_blazegraph_1   1.85%     576.9MiB / 3.844GiB   14.66%    971kB / 198kB     256MB / 244MB     62
3a48d53dcbe9   isle-dc_solr_1         0.87%     208.1MiB / 3.844GiB   5.29%     128kB / 10.6kB    56.9MB / 6.41MB   44
986ce25bff3d   isle-dc_hypercube_1    0.54%     8.824MiB / 512MiB     1.72%     1.73kB / 0B       315kB / 6.15MB    13
d927ae7212ff   isle-dc_homarus_1      0.66%     8.105MiB / 1GiB       0.79%     1.73kB / 0B       532kB / 6.14MB    13
cca6829b49f3   isle-dc_cantaloupe_1   3.02%     503.8MiB / 3.844GiB   12.80%    1.73kB / 0B       60.2MB / 7.43MB   45
4f2d1f18d494   isle-dc_alpaca_1       1.59%     350MiB / 2GiB         17.09%    3.14MB / 2.34MB   43.2MB / 6.55MB   96
52b08e5a4d2f   isle-dc_milliner_1     5.42%     22.97MiB / 1GiB       2.24%     5.66MB / 2.67MB   10.9MB / 6.17MB   14
4729ba21cc1d   traefik                1.35%     16.78MiB / 3.844GiB   0.43%     5.69MB / 8.13MB   39.8MB / 0B       11
1999fe923228   isle-dc_fits_1         1.79%     490.7MiB / 3.844GiB   12.47%    1.73kB / 0B       27.5MB / 6.12MB   41
f3ca8853c5a9   isle-dc_recast_1       0.59%     8.406MiB / 1GiB       0.82%     2.06kB / 0B       1.91MB / 6.23MB   13
e6d9a765fb39   isle-dc_watchtower_1   10.35%    10.23MiB / 2GiB       0.50%     1.73kB / 0B       11.4MB / 0B       11
6d10995a9a56   isle-dc_houdini_1      1.07%     7.668MiB / 1GiB       0.75%     1.73kB / 0B       98.3kB / 6.19MB   13
a9c4efdee2a7   isle-dc_mariadb_1      2.67%     92.09MiB / 1GiB       8.99%     61.6MB / 766MB    19.2MB / 103MB    35
21a32821f30f   isle-dc_activemq_1     0.86%     175.6MiB / 2GiB       8.58%     1.09MB / 1.07MB   34.6MB / 9.97MB   65

Does that look right, @DonRichards?

@DonRichards
Copy link
Member Author

@seth-shaw-unlv Yes. The values are set above the available limit so they are falling back on the local system's maximum available RAM. All of the ones showing "3.844GiB" have values that have 3GiB to 8GiB values set. So yes, this is expected behavior.

Copy link

@seth-shaw-unlv seth-shaw-unlv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

@seth-shaw-unlv seth-shaw-unlv merged commit 73784ae into development Dec 16, 2021
@DonRichards DonRichards deleted the set_mem_limits branch December 16, 2021 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants