dhartford
dhartford

Reputation: 1149

Docker - can you over-allocate ram (tomcat)?

Question from a newbie point-of-view: Can Docker be 'overallocated' Ram wise, and it is a good idea?

The usecase is multiple tomcats on a single server, where tomcat has a minimum (XMS) that handles 80% of the load needs, but then a maximum (XMX) to handle extra load.

10 tomcats, with average XMS at 256mb, and an XMX at 896, you would want to allocate docker's ram at the full 896+permgen(64m)+os needs (64mb) = 1024MB, even though it won't be used all the time?

https://docs.docker.com/reference/run/#runtime-constraints-on-cpu-and-memory

If the host supports swap memory, then the -m memory setting can be larger than physical RAM

Thanks for any feedback if people with experience can confirm (and/or have already done this!) would be appreciated!

-D

Upvotes: 4

Views: 1247

Answers (1)

Loic Dachary
Loic Dachary

Reputation: 1084

Docker can overcommit memory, as mentionned in the documentation. The problems you may face when doing so are no different from the ones you would have if running processes on the host instead of the container. As long as the resident memory footprint (RES / RSS) is smaller than the actual RAM on the host, you should be fine. The virtual memory footprint can be significantly larger but does not actually need to be allocated ( VIRT / VSZ ).

I tend to not configure swap at all because when it starts to be used, the machine effectively becomes so slow (if using spinners) that it is unlikely to recover. A contrario, without swap, memory allocation will fail and process die but the system does not need to be rebooted to be fixed.

Upvotes: 2

Related Questions