mssql-docker
mssql-docker copied to clipboard
Linux container memory usage
Comparing memory usage - linux/mssql express container is using around 500 Mb (no dbs), while windows version of mssql express is using around 100-150 Mb, when installed on Windows 10.
Why such a difference?
https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/server-memory-server-configuration-options?view=sql-server-ver15
Well, I've got ENV MSSQL_MEMORY_LIMIT_MB=100 in Dockerfile, which mssql happily ignores
@kklok Did you try -e MSSQL_MEMORYLIMIT_MB=100
in your docker run
command? I don't know anything about the internals for MS SQL Server in this regard. The link I shared indicates a setting you set on a running instance.
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 100;
GO
RECONFIGURE;
GO
The resource requirements for hardware suggest 4GB for non-express versions of SQL Server.
https://docs.microsoft.com/en-us/sql/sql-server/install/hardware-and-software-requirements-for-installing-sql-server?view=sql-server-ver15
I tried setting limits via Docker, but it keeps recycling the node, didn't dig too much into it myself.
Well, all my attempts to use MSSQL_MEMORY_LIMIT_MB=100 (or 200 or 300) are unsuccessful, linux mssql in Express mode container uses 500-600 Mb of memory as reported by 'docker stats'.
I tried setting max memory to 128 (or 200 or 300) via sp_configure - it does not affect docker container memory usage. With 128 Mb idle cpu usage goes up to 30-50% as per 'docker stats' (it is 6-7% for 200 and 300 Mb setting)
All my tests are with no additional databases and no server load
Due to the architecture of SQL Server on Linux (SQLPAL) it requires 2GB memory. Check out this link here for system requirements. [https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver15#system] This requirement applies to running SQL Server on Linux in a container as well.
Further, a SQL server on Linux process running will only see 80% (by default) of the memory available in the system. So you'll need to take that into account if setting a memory limit. On large memory systems 80% isn't a good value so you can change that by setting MSSQL_MEMORY_LIMIT_MB more on that here: [https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-environment-variables?view=sql-server-ver15] this is the attribute you.
2 Gb of ram for express edition is unsatisfying
However, this repo might not be the right place for the problem, will try to find a better place for it and will keep it open here meanwhile
Found more articles about memory settings on linux:
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf?view=sql-server-ver15#memorylimit
Still,
sudo /opt/mssql/bin/mssql-conf set memory.memorylimitmb 256
has no effect, it takes all the same memory.
Tried posting at Microsoft feedback site but got no response
Any news on this or is it best to accept that running an mssql linux container will take 2GB of memory whatever you do?
I've done the following:
latest SQL server image: mcr.microsoft.com/mssql/server:2019-latest set container memory with --meory 16g set environment variable -e MSSQL_MEMORY_LIMIT_MB=13631488 ran /opt/mssql/bin/mssql-conf set memory.memorylimitmb 13631488
Still I'm getting the same issue. After some time database just dies. Please provide a fix for this.
@kesavkolla I'm not sure, but in my understanding the env-variable is for megabytes, right? (at least the name suggests that. So, your setting would be 13'312GB - I think you wanted to set it to 13'312. (And I guess it is just a typo, and the container option should read --memory 16g - instead of meory.)
There seems to be some confusion about this 2GB memory usage. There is no "fix" for this. It is not a defect, it works as designed. It is a limitation of MS SQL Server application's architecture on Linux, which they have documented clearly in their minimum system requirements. I don't see anything to indicate that MS is planning on changing this, so as unsatisfying as anyone may find this, your best best is most likely to accept it and then worry more about things that are within your ability to change, like increasing available memory or running a different DBMS.
@kklok @kesavkolla @FBryant87