Memory Limit

114 views
Skip to first unread message

Johan

unread,
Feb 2, 2021, 9:38:26 PM2/2/21
to RavenDB - 2nd generation document database
We have an embedded server (5.0.8) that is deployed as a container application.
We have noticed that either the embedded server or the main process sometimes get terminated by the linux memory manager (due to low memory or out of memory).

I can control the memory requirements of our main process, but can't control the memory limit of the database (or at least not that I know of).

There is a low memory limit configuration, but that wants to keep a certain amount of memory free. This doesn't set a memory limit in Raven itself and with an embedded server the main process will need to take memory too. 

Is there a way to set a memory limit for the embedded server?

Egor Shamanaev

unread,
Feb 3, 2021, 4:33:51 AM2/3/21
to rav...@googlegroups.com
Hi,

There is no configuration to limit the memory currently,

We have an issue ticket open for this (for windows), please see: https://issues.hibernatingrhinos.com/issue/RavenDB-15312 
and on windows, you can also limit the memory using PowerShell (Get-Process RavenDB.Server).MaxWorkingSet = 1024*1024*1024

Regarding the OOM, are you running encrypted DBs ?

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/0f4405e0-0f39-4b0a-8151-d0a2e3008d56n%40googlegroups.com.


--
Egor
Developer   /   Hibernating Rhinos LTD
Support:  sup...@ravendb.net
  

Johan

unread,
Feb 3, 2021, 11:20:01 AM2/3/21
to RavenDB - 2nd generation document database
We are running linux containers. This happens with non-encrypted databases.
For example the container has 8Gb of memory allocated (and the cloud provider doesn't provision swap for containers). The embedded database will use the low memory limit configuration (the default) to trigger low memory conditions when 10% of the memory is available. The database typically doesn't need more than 2Gb, but for some operations it may grow beyond that. Our own main process will take about 4Gb.  However I think the database doesn't see the 4Gb used by the main process and calculates that it still has 6Gb of available memory left. It therefore assumes it can function normally. When total memory usage (of the 2 processes) nears 8Gb then the Linux OOM manager will terminate one of them (sometimes the main process and sometimes the embedded server). We have tried to change the low memory limit configuration, but that doesn't help.

- Johan

Oren Eini (Ayende Rahien)

unread,
Feb 3, 2021, 5:26:29 PM2/3/21
to ravendb
Can you check /admin/debug/proc/meminfo on your instance?

In particular, what is the MemAvailable value that you see there under low memory conditions?



--
Oren Eini
CEO   /   Hibernating Rhinos LTD
Skype:  ayenderahien
Support:  sup...@ravendb.net
  

Johan

unread,
Feb 3, 2021, 9:21:56 PM2/3/21
to RavenDB - 2nd generation document database
There is no such file. The mem available in /proc/meminfo is 1078576 kB.
However I believe these numbers are not reliable inside a container as they may reflect the hosts memory. 
We run with k8s and specify resource limits and then memory information should be obtained from cgroups (as far as I know).

Oren Eini (Ayende Rahien)

unread,
Feb 3, 2021, 10:22:34 PM2/3/21
to ravendb
That isn't a file, sorry, it is an endpoint on RavenDB, like:

Also, this endpoint? /admin/debug/memory/stats


Johan

unread,
Feb 4, 2021, 11:29:38 AM2/4/21
to RavenDB - 2nd generation document database
The proc/meminfo:
MemTotal:        7865012 kB
MemFree:          241776 kB
MemAvailable:     751428 kB

The memory stats:
{"MemoryInformation":{"PhysicalMemory":"6.5 GBytes","WorkingSet":"624.75 MBytes","ManagedAllocations":"177 MBytes","UnmanagedAllocations":"8.83 MBytes","EncryptionBuffers":"0 Bytes","MemoryMapped":"8.45 GBytes","ScratchDirtyMemory":"0 Bytes","IsHighDirty":false,"DirtyMemory":"3.6 MBytes","AvailableMemory":"6.06 GBytes","AvailableMemoryForProcessing":"6.056 GBytes","HighMemLastOneMinute":"6.5 GBytes","LowMemLastOneMinute":"6.056 GBytes","HighMemLastFiveMinute":"6.5 GBytes","LowMemLastFiveMinute":"6.056 GBytes","HighMemSinceStartup":"6.5 GBytes","LowMemSinceStartup":"6.056 GBytes"}

Since this is happening in a production system, I don't know when there is such a low memory condition happening. All I am seeing that every now and then a process is terminated by the oom manager.


Johan

unread,
Feb 10, 2021, 11:38:31 AM2/10/21
to RavenDB - 2nd generation document database
Ideally I like to have a memory limit setting (for an embedded database) where I can specify the max amount of memory (or a percentage of total) the embedded database is allowed to use instead of assuming it can take all memory available in a container. On Linux you could normally achieve this by using cgroups, but this is inside a container which is already using cgroups for the specified memory restrictions on the container.

Oren Eini (Ayende Rahien)

unread,
Feb 14, 2021, 9:54:28 AM2/14/21
to ravendb
These are excellent numbers, which is strange given your experience.
The MemAvailable at ~700 MB is not ideal, but RavenDB itself is taking a total of 624.75 MBytes in terms of working set.
There really isn't much that we can do to reduce the memory usage from that level, I think. 
Is it possible that some the client application is querying RavenDB with big result set without using streaming? That would force us to use a lot of memory.


Johan

unread,
Feb 22, 2021, 11:15:11 AM2/22/21
to RavenDB - 2nd generation document database
We have seen a process being terminated now 6 times (over 3 machines) in the last month, so  it is hard to pin down or provide numbers when it is close to happening

Oren Eini (Ayende Rahien)

unread,
Feb 22, 2021, 3:02:37 PM2/22/21
to ravendb
Reply all
Reply to author
Forward
0 new messages