Mongo in container: how to manage memory










0















We have an apache/mongo architecture, organized around Docker. So far everything was fine, but with the bases growing, we now face new challenges.
Right now, we have 3 projects in production, with a total of 6 containers (1 apache container and 1 mongo container per project).



The problem we face is that each mongo container think they have 21GB of memory, so they try to use 80% of it
So the solution for me was to restart one of the container with a memory limit given to the mongo process :



--wiredTigerCacheSizeGB 7


The problem with that solution is that the limit is fixed for each mongo container. If one base needs more memory, I would have to restart the container with another value.



So please I have some questions. I think these questions might interest others in general, since I didn't find anything about that precisely on the Internet :



1) Is there a global solution to balance memory between mongo container?
That is, automatically? (without manual supervision, where I've got to check the I/O on disks)
And also, without restarting the container?



2) Are Cache limitations really useful?
Since the OS limits the container anyway, should I remove the limit and disable the alarms I get? (Not doing that anyway)



3) Is it really useful to have one container per base?
Would it be more practical, under the aspect of memory, to have one big mongo container for all three bases?
What would be the pros and cons for both solutions?



One mongo container for all projects bases
Pros:
Easier to manage
Easier to balance memory



Cons:
Less secure



One mongo container per base:
Pros:
More secure
Easier to backup? (not really)



Cons:
Difficult to handle memory



4) We are having a more general debate about how memory should relate to disk with mongo.
Personally, I don't think it's a problem if the base on disk is bigger than its footprint in memory, ie it's OK to have parts of database on disk that are rarely touched and thus won't find themselves in memory.



My devs think that size on disk should be the size in memory. That is, if I have a 40GB databases, I should have 40GB of memory, which appear unrealistic to me.



What is your opinion on that?



Thank you everyone for their answers!










share|improve this question




























    0















    We have an apache/mongo architecture, organized around Docker. So far everything was fine, but with the bases growing, we now face new challenges.
    Right now, we have 3 projects in production, with a total of 6 containers (1 apache container and 1 mongo container per project).



    The problem we face is that each mongo container think they have 21GB of memory, so they try to use 80% of it
    So the solution for me was to restart one of the container with a memory limit given to the mongo process :



    --wiredTigerCacheSizeGB 7


    The problem with that solution is that the limit is fixed for each mongo container. If one base needs more memory, I would have to restart the container with another value.



    So please I have some questions. I think these questions might interest others in general, since I didn't find anything about that precisely on the Internet :



    1) Is there a global solution to balance memory between mongo container?
    That is, automatically? (without manual supervision, where I've got to check the I/O on disks)
    And also, without restarting the container?



    2) Are Cache limitations really useful?
    Since the OS limits the container anyway, should I remove the limit and disable the alarms I get? (Not doing that anyway)



    3) Is it really useful to have one container per base?
    Would it be more practical, under the aspect of memory, to have one big mongo container for all three bases?
    What would be the pros and cons for both solutions?



    One mongo container for all projects bases
    Pros:
    Easier to manage
    Easier to balance memory



    Cons:
    Less secure



    One mongo container per base:
    Pros:
    More secure
    Easier to backup? (not really)



    Cons:
    Difficult to handle memory



    4) We are having a more general debate about how memory should relate to disk with mongo.
    Personally, I don't think it's a problem if the base on disk is bigger than its footprint in memory, ie it's OK to have parts of database on disk that are rarely touched and thus won't find themselves in memory.



    My devs think that size on disk should be the size in memory. That is, if I have a 40GB databases, I should have 40GB of memory, which appear unrealistic to me.



    What is your opinion on that?



    Thank you everyone for their answers!










    share|improve this question


























      0












      0








      0








      We have an apache/mongo architecture, organized around Docker. So far everything was fine, but with the bases growing, we now face new challenges.
      Right now, we have 3 projects in production, with a total of 6 containers (1 apache container and 1 mongo container per project).



      The problem we face is that each mongo container think they have 21GB of memory, so they try to use 80% of it
      So the solution for me was to restart one of the container with a memory limit given to the mongo process :



      --wiredTigerCacheSizeGB 7


      The problem with that solution is that the limit is fixed for each mongo container. If one base needs more memory, I would have to restart the container with another value.



      So please I have some questions. I think these questions might interest others in general, since I didn't find anything about that precisely on the Internet :



      1) Is there a global solution to balance memory between mongo container?
      That is, automatically? (without manual supervision, where I've got to check the I/O on disks)
      And also, without restarting the container?



      2) Are Cache limitations really useful?
      Since the OS limits the container anyway, should I remove the limit and disable the alarms I get? (Not doing that anyway)



      3) Is it really useful to have one container per base?
      Would it be more practical, under the aspect of memory, to have one big mongo container for all three bases?
      What would be the pros and cons for both solutions?



      One mongo container for all projects bases
      Pros:
      Easier to manage
      Easier to balance memory



      Cons:
      Less secure



      One mongo container per base:
      Pros:
      More secure
      Easier to backup? (not really)



      Cons:
      Difficult to handle memory



      4) We are having a more general debate about how memory should relate to disk with mongo.
      Personally, I don't think it's a problem if the base on disk is bigger than its footprint in memory, ie it's OK to have parts of database on disk that are rarely touched and thus won't find themselves in memory.



      My devs think that size on disk should be the size in memory. That is, if I have a 40GB databases, I should have 40GB of memory, which appear unrealistic to me.



      What is your opinion on that?



      Thank you everyone for their answers!










      share|improve this question
















      We have an apache/mongo architecture, organized around Docker. So far everything was fine, but with the bases growing, we now face new challenges.
      Right now, we have 3 projects in production, with a total of 6 containers (1 apache container and 1 mongo container per project).



      The problem we face is that each mongo container think they have 21GB of memory, so they try to use 80% of it
      So the solution for me was to restart one of the container with a memory limit given to the mongo process :



      --wiredTigerCacheSizeGB 7


      The problem with that solution is that the limit is fixed for each mongo container. If one base needs more memory, I would have to restart the container with another value.



      So please I have some questions. I think these questions might interest others in general, since I didn't find anything about that precisely on the Internet :



      1) Is there a global solution to balance memory between mongo container?
      That is, automatically? (without manual supervision, where I've got to check the I/O on disks)
      And also, without restarting the container?



      2) Are Cache limitations really useful?
      Since the OS limits the container anyway, should I remove the limit and disable the alarms I get? (Not doing that anyway)



      3) Is it really useful to have one container per base?
      Would it be more practical, under the aspect of memory, to have one big mongo container for all three bases?
      What would be the pros and cons for both solutions?



      One mongo container for all projects bases
      Pros:
      Easier to manage
      Easier to balance memory



      Cons:
      Less secure



      One mongo container per base:
      Pros:
      More secure
      Easier to backup? (not really)



      Cons:
      Difficult to handle memory



      4) We are having a more general debate about how memory should relate to disk with mongo.
      Personally, I don't think it's a problem if the base on disk is bigger than its footprint in memory, ie it's OK to have parts of database on disk that are rarely touched and thus won't find themselves in memory.



      My devs think that size on disk should be the size in memory. That is, if I have a 40GB databases, I should have 40GB of memory, which appear unrealistic to me.



      What is your opinion on that?



      Thank you everyone for their answers!







      mongodb docker memory-management






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 14:59







      Bibelo

















      asked Nov 12 '18 at 14:53









      BibeloBibelo

      113




      113






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264684%2fmongo-in-container-how-to-manage-memory%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264684%2fmongo-in-container-how-to-manage-memory%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Syphilis

          Darth Vader #20