Looking at my Dynamic Memory demo – guest workload
Many people have been asking me about my setup for the dynamic memory demonstration that I did in a number of locations earlier this year. I have been telling myself that I would take the time to polish up my demo scripts and post them here – but I have been too busy lately – so instead you are going to get the unpolished scripts
The first part of the dynamic memory demonstration was to make sure that I had virtual machines that “looked right”. I did not want to have a bunch of idle virtual machines – as people would not be interested in seeing how much memory I could squeeze out of Windows when it was not doing anything. At the same time I did not want to use some of the higher end workload simulators – as many of these are server / client applications – and I needed something that would work on a laptop without a network connection.
My solution was what I ended up calling “VDI lite”
(Let me be crystal clear – I am in no way pretending that this is an accurate representation of a real user workload. This was not used in any testing or validation of dynamic memory – this is simply something I put together by myself to make my demo look good!).
The approach I took was to gather a bunch of common document files – I did this by doing a “file type” search on Microsoft.com. I have put these files up on my skydrive:
(had to do it in two files – due to the 50mb file size limit on sky drive)
These are all documents that you can find on Microsoft.com and most of them reference Hyper-V in one way or another. I then wrote this PowerShell script:
# Setup Arrays
$documentSourceArray = @()
$processArray = New-Object System.Collections.ArrayList
# Populate source array. Entries have three values - the document, the program to open it with, and the process name for closing the process
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\05-2008ClabbySixReasonsWhyMSwillovertakeVMW.PDF""","""C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe""", "AcroRd32")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\BTS09HyperV.pdf""","""C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe""", "AcroRd32")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Hyper-V_ProductOverview_v1_2.pdf""","""C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe""", "AcroRd32")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\LefthandHyper-VBrief.pdf""","""C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe""", "AcroRd32")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Top Ten Reasons for Hyper-V.pdf""","""C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe""", "AcroRd32")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\LiveMigrationWhitepaper_Final.docx""","""C:\Program Files\Microsoft Office\Office14\WINWORD.EXE""", "WINWORD")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows Server 2008 R2 Hyper-V RC Public FAQ.docx""","""C:\Program Files\Microsoft Office\Office14\WINWORD.EXE""", "WINWORD")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows_Server_2008_R2_Reviewers_Guide_RTM.docx""","""C:\Program Files\Microsoft Office\Office14\WINWORD.EXE""", "WINWORD")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows_Server_2008_R2_TDM_Whitepaper_RTM.docx""","""C:\Program Files\Microsoft Office\Office14\WINWORD.EXE""", "WINWORD")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\WS08_R2_VHD_Performance_WhitePaper_Final.docx""","""C:\Program Files\Microsoft Office\Office14\WINWORD.EXE""", "WINWORD")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Storage and Hyper-V - The Choices You Can Make and the Things You Need to Know.pptx""","""C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE""", "POWERPNT")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows Server 2008 R2 - Hyper-V Part 1.pptx""","""C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE""", "POWERPNT")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows Server 2008 R2 - Hyper-V Part 2.pptx""","""C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE""", "POWERPNT")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\WS08 R2 Hyper-V Overview_R2.pptx""","""C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE""", "POWERPNT")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\WS08 R2 Hyper-V Technical Overview_R2.pptx""","""C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE""", "POWERPNT")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Hyper-V RAM Calculator.xls""","""C:\Program Files\Microsoft Office\Office14\EXCEL.EXE""", "EXCEL")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Appendix_A_-_Test_Results_Spreadsheet.xlsx""","""C:\Program Files\Microsoft Office\Office14\EXCEL.EXE""", "EXCEL")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\DPM 2010 Storage Calculator for Hyper-V DRAFT.xlsx""","""C:\Program Files\Microsoft Office\Office14\EXCEL.EXE""", "EXCEL")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows Server 2008 Hyper-V Attack Surface Reference.xlsx""","""C:\Program Files\Microsoft Office\Office14\EXCEL.EXE""", "EXCEL")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\WinHEC08_Agenda.xlsx""","""C:\Program Files\Microsoft Office\Office14\EXCEL.EXE""", "EXCEL")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Microsoft Events TechEd USA.mht""","""C:\Program Files\Internet Explorer\iexplore.exe""", "iexplore")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Virtual PC Guy's WebLog - Site Home - MSDN Blogs.mht""","""C:\Program Files\Internet Explorer\iexplore.exe""", "iexplore")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows Server 2008 R2 Virtualization with Hyper-V.mht""","""C:\Program Files\Internet Explorer\iexplore.exe""", "iexplore")
$documentSourceArray += ,("""C:\Users\DM-VDI-Demo\Documents\Windows Virtual PC Home Page.mht""","""C:\Program Files\Internet Explorer\iexplore.exe""", "iexplore")
# Loop for all eternity
while (1 -eq 1)
{
# Generate random sleep time between 10 and 90 seconds
$sleepTime = Get-Random -min 10 -max 90
# Generate random boolean value
$test = [boolean](get-random -input 0,1)
# If the boolean is true - or no processes are running - start a new process
if ($test -or ($processArray.count -eq 0))
{
# Choose a random entry from the source array
$entry = $documentSourceArray[(Get-Random -min 0 -max ($documentSourceArray.length - 1))]
# Start the process
$p = [diagnostics.process]::start($entry[1], $entry[0])
# Add the process name to the process array - if it is not already there
if (!$processArray.contains($entry[2]))
{
[void]$processArray.add($entry[2])
}
# Display debug information
write-host "Opening program" $entry[2]
write-host "Opening file" $entry[0]
Write-host
write-host "Numer of open programs:" $processArray.count
write-host "Open programs:"
write-host $processArray
Write-host
}
# Otherwise close a program
else
{
# Choose a random program, or if there is only one choose it and set the sleep counter to 1 second
if ($processArray.count -gt 1) {$index = Get-Random -min 0 -max ($processArray.count - 1)}
else {$index = 0;$sleepTime = 1}
# Display debug information
write-host "Closing program" $processArray[$index]
Write-host
# Close the process. Key things - CloseMainWindow ensures that the process exists politely.
# All the looping makes sure that all instances are fully closed
$p = @(Get-Process -name $processArray[$index])
while ($p = @(Get-Process -name $processArray[$index] -ea 0)) {foreach ($q in $p) {[void]$q.CloseMainWindow()}; sleep 1}
# Remove the process from the array
$processArray.Remove($processArray[$index])
# Display debug information
write-host "Numer of remaining programs:" $processArray.count
write-host "Remaining programs:"
write-host $processArray
Write-host
}
# wait for a random amount of time
write-host "Waiting for" $sleepTime "seconds"
Write-host
sleep $sleepTime
}
Which does the following:
- Creates an array which contains the details of all the documents that I have (you will probably need to fix the path to use it on your computer)
- Waits a random period of time and then either:
- Opens a new document
- Closes a currently open program
Nothing too fancy – but it does cause memory to move around between virtual machines, and it does demonstrate that the virtual machines are actually doing something.
Cheers,
Ben