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

SqlServerMemory: Auto memory on Azure VMs is off by an order of magnitude on large VMs #914

Closed
GArionMSFT opened this issue Nov 22, 2017 · 5 comments
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

Comments

@GArionMSFT
Copy link

GArionMSFT commented Nov 22, 2017

Details of the scenario you tried and the problem that is occurring:
Provision an Azure VM of type: Standard_E32_v3 VM (Windows) (with 256GB RAM) and have xSQLServerMemory automatically set max memory.
Expected would be that it sets SQL Server max memory to about 200+ GB RAM, actual result: it sets to about 27GB RAM.

The reason for that is that the script uses
((Get-CimInstance -ClassName Win32_PhysicalMemory).Capacity | Measure-Object -Sum).Sum
to get the total amount of RAM. On Azure, on that VM size that is around 30~ GB RAM.

A more correct way of getting the total amount of memory available would be:
(Get-Ciminstance Win32_OperatingSystem).TotalVisibleMemorySize
(to note - the result here is in KB, vs Bytes as with Win32_PhysicalMemory.Capacity)

The DSC configuration that is using the resource (as detailed as possible):

        xSQLServerMemory Set_SQLServerMaxMemory_ToAuto
        {
            Ensure = 'Present'
            DynamicAlloc = $true
            SQLInstanceName = $SQLInstanceName
        }

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Windows Server 2016, PS 5.0

What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
SQL Server 2016 SP1

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
xSqlServer 7.1 - but this reproes on all version after that as well

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub easy fix labels Nov 22, 2017
@johlju
Copy link
Member

johlju commented Nov 22, 2017

I have tested this on a physical and it looks okay to me.

PS > [Math]::Round((Get-Ciminstance Win32_OperatingSystem).TotalVisibleMemorySize / 1MB)
192

And on a VM with less memory.

PS > [Math]::Round((Get-Ciminstance Win32_OperatingSystem).TotalVisibleMemorySize / 1MB)
8

@johlju
Copy link
Member

johlju commented Nov 22, 2017

I label this one as 'good first issue'. If someone new to contributing wants to take something on, this is a good one.

@johlju johlju changed the title _xSQLServerMemory: Auto memory on Azure VMs is off by an order of magnitude on large VMs SqlServerMemory: Auto memory on Azure VMs is off by an order of magnitude on large VMs Dec 24, 2017
@johlju johlju removed the easy fix label Apr 29, 2018
@brwilkinson
Copy link

Looks like this class might be best here:

This looks to be reliable in Azure.

(gcim win32_computersystem).TotalPhysicalMemory

@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Jun 28, 2018
@SQLHorizons
Copy link
Contributor

Seen a similar type of issue on aws m5 EC2 machine type, where Win32_PhysicalMemory is returning 0 for capacity.

aws' feedback was to use the following:

((Get-CimInstance -ClassName win32_ComputerSystem).TotalPhysicalMemory | Measure-Object -Sum).Sum

@johlju
Copy link
Member

johlju commented Feb 22, 2019

This is about to be resolved in PR #1285. But since there have been reports that the change is better for VM's I thought I would verify that it works for physical servers as well. Since I don't have access to physical servers with a lot of memory I asked a friend.
His conclusion was that the change will work for physical as well. He did note that the suggested change will return another value than our previous way (before this change) of reporting memory, see screenshots. Our thought it that the suggested change in the PR #1285 returns the OS available memory, and will not be exactly the same amount as the actual physical memory due to some reserved memory. My conclusion is that this change will return a more correct number of available memory.

He tested on Windows Server 2012 R2 (HP Gen8 128GB) and Windows Server 2016 (HP Gen10 384GB).

Windows Server 2012 R2:
win2k12-gen8-128gb

Windows Server 2016 R2:
win2k16-gen10-384gb

johlju pushed a commit that referenced this issue Feb 22, 2019
#1285)

- Changes to SqlServerMemory
  - Updated Cim Class to Win32_ComputerSystem (instead of Win32_PhysicalMemory)
    because the correct memory size was not being detected correctly on Azure VMs (issue #914).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants