-
Notifications
You must be signed in to change notification settings - Fork 78
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
[WIP] [HyperV2012R2+] Refactor for performance #225
base: master
Are you sure you want to change the base?
Conversation
Update HyperV2012R2 project
refactor VirtualMachineHelper optimizate GetVirtualMachine
Optimizate CreateVM (part1) Rewrite GetVirtualMachines to Mi (WMIv2) x6 faster that on powershell Move GetJob from wmi to Mi
@FuseCP-MTiggelaar @FuseCP-TRobinson @IvanSchulz Unfortunately, I don’t have the ability to test Remote Hyper-V at the moment, so I’d really appreciate your help in deciding whether to continue replacing old WMI methods with the modern MI/CIM or revert to using the old WMI. For testing, you can simply install/reinstall a test VM server or check memory/hdd VM usage, or just check if "VirtualMachine Thumbnail Image" works (some MI methods are already being used in these areas). P.S. When building the source code, make sure to switch to the |
Hi, I tried to test it today but I have no experience with remote HV. There are no errors, when I connect to the remote server via FQDN. But when I create the VM I get the following errors in Audit Log:
I get the error with both old and new source code, so it's not due to the PR. Do you have an idea? |
@IvanSchulz Thank you very much for trying. But converting a 40GB disk in just 6 seconds doesn't seem very realistic. If you’re getting the same error in version 1.5.1 (without compiling the code from GitHub), then the issue is related to the Remote HyperV setting. Did you test it without recompiling the code as well? (Meaning only using the files from the 1.5.1 installer.) Unfortunately, I’m not familiar with the error "The RPC server is unavailable.", so I can’t suggest anything beyond what I can find online. If Remote HyperV works with the files installed from the 1.5.1 installer, then you can ignore the text below. :) Do you have DCom configured? https://help.ivanti.com/ht/help/en_US/IDAC/vNow/setup/setup-DCOM.htm |
With original 1.5.1 version I got the same error. The only difference is that the original version shows the wrong number of CPU cores. |
Yeah, the original 1.5.1 had a bug with cores, which was fixed here: So if you're still getting that error, that's a good sign that my PR might work. :) The problem is probably in the settings. As far as I know, DCOM requires the firewall to be set up correctly and both servers to be in the same domain, along with some of the settings I mentioned earlier. If both servers are already in the same domain, you can try disabling the firewall for testing. Probably this can help too - https://learn.microsoft.com/en-us/windows-server/security/rpc-interface-restrict (or this maybe too https://softwarekeep.com/blogs/troubleshooting/fix-the-rpc-server-is-unavailable-error-in-windows ) I’d really appreciate it if you could figure it out. If not, no worries - I’ll just have to request a second test dedicated server to simulate Remote-HyperV. I was just hoping that if someone already has experience with this and has tested Remote Hyper-V, it would save me a lot of time. :) |
Description
This PR is related to issue #224 and aims to optimize Hyper-V performance on high-load nodes. On average, performance will improve by about 2x, and in some cases, up to 6x. On nodes with fewer than 100 servers, there may be no noticeable changes, except for a more responsive control panel when working with VMs.
1. A modern tool, MI/CIM, has been added:
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmi_v2/windows-management-infrastructure
Unlike WMI, MI/CIM supports not only DCom but also the modern DSMan:
https://support.quest.com/kb/4311903/comparison-between-dcom-wmi-and-winrm-technologies
By default, MI uses DCom for Remote Hyper-V. This can be changed in the Provider Settings.

2. Multi-command support for PowerShell has been added, allowing multiple commands to run without switching to script mode.
Example PowerShell:
C#
3. Some methods have been partially optimized.
For example, retrieving all virtual machines (tested with 400 VMs):
Pure Powershell:
WMIv2 imitation (around x20 times faster):
Retrieving data for a single server (testing on a high-load node):
WMIv2 (around x2 time faster)
IMPORTANT: When testing, you must start a new PowerShell session each time (open a new PowerShell ISE). Otherwise, after the first run, data will be cached in the current session. Since SolidCP creates a new session for each request, it cannot use cached PowerShell queries. As seen in the results, the first run is so slow in PowerShell that it negates its advantages.
These data simply show how poorly PowerShell performs in some cases. However, I don’t plan to replace everything with WMI because, as always, Microsoft can’t decide which tool should replace another. As a result, PowerShell sometimes has access to data that WMI doesn’t - and vice versa. 🙂
In this PR, I only plan to replace/rewrite the most problematic areas.