Tuesday, October 23, 2012

PowerCLI: ESXi Host Audit

I try to keep up with the VMware communities/message boards for PowerCLI related questions and saw one that I thought was interesting. Someone was interested in creating a script that could preform an audit of their ESXi hosts in inventory. He wanted the script to include the following:
  • Product Name
  • Version
  • Edition
  • Host Name
  • Number of Cores
  • Number of Physical Processors
So Mr. Buzzlightyear... if that is your real name, here it is, I know I am little late, but I think my script is a little easier to understand and use. In reality I turned the script actually into a function called: Get-VMHostAudit. Run this script, or add it to your PowershellCli profile and off you are to the races.

The script:


function Get-VMHostAudit
{
param([parameter(mandatory=$true)][string]$vCenter,
        [parameter(mandatory=$true)][string]$Username,
        [parameter(mandatory=$true)][string]$Password,
        [parameter(mandatory=$true)][ValidateSet("List","Table")]$Format)

Connect-VIServer -Server $vCenter -User $Username -Password $Password
$ServiceInstance = Get-View ServiceInstance
$LicenseManager = Get-View $ServiceInstance.Content.LicenseManager
$LicenseManagerAssign = Get-View $LicenseManager.LicenseAssignmentManager
$VMhosts=Get-VMHost
$VMhostsTotal=@()
Foreach($VMhost in $VMHosts)
    {
    $VMHostView=Get-VMHost -Name $VMHost.name | Get-View
    $VMhostID=$VMHostView.Config.Host.Value
    $VMHostLM=$LicenseManagerAssign.QueryAssignedLicenses($VMhostID) 
    $VMhostsTotal+=$VMHostView | Select Name,
        @{n='Product';e={$_.Config.Product.Name}},
        @{n='Version';e={$_.Config.Product.Version}},
        @{n='Sockets';e={$_.Hardware.CpuInfo.NumCpuPackages}},    
        @{n='CPUCores';e={$_.Hardware.CpuInfo.NumCpuCores}},
        @{n='LicenseVersion';e={$VMHostLM.AssignedLicense.Name | Select -Unique}},
        @{n='LicenseKey';e={$VMHostLM.AssignedLicense.LicenseKey | Select -Unique}}
    }
If ($Format -eq "List"){$VMhostsTotal | Fl}
If ($Format -eq "Table"){$VMhostsTotal | Ft -AutoSize}
Disconnect-VIServer -Server $vCenter -Confirm:$False -Force
} # End Function

How to run it:


Just run the script to load the function into your shell and then execute the function. Heres an example:

C:\Scripts\PowerCLI\VMHostAudit.ps1

Get-VMHostAudit -vCenter 192.168.0.1 -Username ITMonsterrrrrr -Password Cr@CkTh!s -Format Table

As I mentioned earlier, add the function to your profile also, then you will always have it when you want to run it. Here is my favorite resource for Powershell profiles. Here is an example of the output, you can choose from either listed form or table form, just hit tab after the format switch to cycle through your options.


Name           : 192.168.25.41
Product        : VMware ESXi
Version        : 5.0.0
Sockets        : 1
CPUCores       : 4
LicenseVersion : VMware vSphere 5 Enterprise Plus
LicenseKey     : 00000-00000-00000-00000-00000

Name           : 192.168.25.42
Product        : VMware ESXi
Version        : 5.0.0
Sockets        : 1
CPUCores       : 4
LicenseVersion : VMware vSphere 5 Enterprise Plus
LicenseKey     : 00000-00000-00000-00000-00000



Name          Product     Version Sockets CPUCores LicenseVersion                   LicenseKey                   
----          -------     ------- ------- -------- --------------                   ----------                   
192.168.25.41 VMware ESXi 5.0.0         1        4 VMware vSphere 5 Enterprise Plus 00000-00000-00000-00000-00000
192.168.25.42 VMware ESXi 5.0.0         1        4 VMware vSphere 5 Enterprise Plus 00000-00000-00000-00000-00000

How it works:


After reading the passed parameters of $vCenter, $Username, $Password and $Format, the script connects to vCenter. We grab a view of the vCenter instance its self, we then request a license manager view for the vCenter instance. After we have stored the license manager assignment view for the instance in the $LicenseManagerAssign variable we then grab all of the ESXi hosts for the instance in the $VMHost variable. Then we begin to cycle to through each host and do the following: We grab a view of the host, and assign its host ID to the $VMHostID variable which will be used in a second. We then query the License Manager for the assigned licenses for the ESXi host matching that $VMHostID. With that information stored in the $VMHostLM (licenses manager) variable, we then just compile all of the desired data. We pick up host name, product name, version, cpu cores, and sockets from the $VMhostView variable and add in the license and key by using calculated expressions to query the $VMHostLM variable. We actually add this data to the $VMHostsTotal array, which by doing this will allow all of the hosts to put their data into that array and presented at one time, instead of having a table for each host, we essentially create 1 table by adding each hosts data to that array. After it determines if you defined a list or table to be used, it spews the data and disconnects from vCenter! Thats all she wrote! You could easily add in functionality to export to a CSV or HTML, although with this information I dont see an HTML output being very handy, but I do see a lot of value for using CSV to archive this information. If you need help editing the code to add more functionality, just let me know!

Syntax View:



























I use Powershell and Powershell ISE 3.0.

Sunday, October 7, 2012

VCP5: Memory Reservations

Understanding entitlements ,and in this case memory reservations, is a key concept to pass the VCP5 exam, although this concept is easily grasped by most people, the exam presents questions regarding these subjects in ways that will have you thinking hard. Remember entitlements are not only configured in one location. Knowing these locations and the optional settings you could configure is need-to-know information. As some starting points, know what memory reservations, limits, and shares are and HOW THEY ARE DIFFERENT. Also, know where you can set memory entitlements. Below are a few screen shots to show you where you can set them:

All entitlements including disk and cpu can be set by right clicking any VM and navigating to the "Resources" tab:


















Take note of the check box in the top right corner, "Reserve all guest memory (All locked)". This can be a super helpful component if you have a VM that is key to day to day operations and should always be guaranteed all of its memory, this is where you would configure that setting. Essentially, selecting this option removes the amount of RAM assigned to the VM from the pool of resources available to all other VMs, just as other reservations do for a specified amount of memory.

This next screenshot is the "Resources" page when you select to edit the settings of a vApp. If you dont know much about vApps I suggest you go here and read up on them in the vSphere Documentation Center, but basically a vApp is a container for housing VMs that are components of maybe a single application, like for instance, a web server, a database and an application server could be in a vApp for ease of management because they are all related to a certain application. Within a vApp you can power on and off the VMs in the vApp in a particular order in one click and you can control the resources of a vApp.

















Here is a screen shot about memory entitlements in vSphere from the Documenation Center if you are looking for some quick reading.



SQL Saturday: #165 Lincoln

Had an awesome time at SQL Saturday #165 in Lincoln yesterday! Went down to Lincoln with a few co-workers and was able to see 3 co-workers from House of Brick Technologies present in different sessions. Great job David Pettengill, Andy Galbraith (@ DBA_ANDY) and David Klee (@kleegeek) on your presentations I enjoyed them all. This was my first SQL Saturday and it was a great experience, I love how the SQL Server community works together to help industry and technology progression.

A favorite presentation of mine yesterday was "SQL Server Internals: It's Whats for Dinner" by Christina Leo (@ChristinaLeo), it was very in depth presentation and very well pulled off. A theme of mine if you haven't read some of my other blog posts, is that I enjoy and appreciate simplicity, and her presentation was presented in a very simplistic easy to understand manner. When someone can explain a subject in such an easy to understand way, you know they know their stuff! She also used a pretty fun analogy comparing the internals of SQL Server to preparing and cooking a meal using a recipe...sounds nuts, but it was pretty awesome how she made it all relate. Great presentation Christina (who will probably never see my blog ;)).
Cant wait for SQL Saturday in Omaha April 6th!

Sunday, September 30, 2012

VCP5: Resources and Refrences for Study

The VCP5 exam is a well written and structured test. It was a surprisingly difficult exam, and I was caught off guard. Based on mock exams and practice exams I was taking, as one portion of my preparation, I should have blown the test right out of the water. I feel like nothing I had done had properly helped me prepare for the exam so because of that fact I felt a little mad when I had failed the test on try 1. So in an effort to provide a better reference and study companion for people interested in taking the VCP5 exam, I plan to write a large group of blog posts containing key topics and areas of focus that will aid in helping people understand what they are studying and why they should know the information presented to pass the exam.
I took the VMware 5.0 Fast Track course in Chicago about 6 months ago (if you dont know, attending a VMware certified course is a requirement for becoming certified). I must warn everyone, taking the classes will not provide you with 90% of the knowledge you need to pass the exam as my teacher so commonly mentioned. I consider the classes to give a person about 20% of what they need to know to pass the exam. If the exam asked questions like "How do I power on a VM", then sure, the class would give you sufficient knowledge to pass. But I will tell you, you wont find little baby questions like that on the exam :)
What you WILL find in the VCP exam is that topics are covered in a way that someone might say to them selves, "Well that was a twist on what I thought the question might be". For instance, someone might study how to set the Maximum Transmission Unit to allow for Jumbo Frames. They might know from start to finish how to set the MTU, on what object you can set the it, and that 9000 is the number to configure for Jumbo Frames. But when they sit down for the test it may ask what is the default MTU, and that person may have spent so much time focused on the Jumbo Frame MTU size that they totally spaced on the default size. This to me would be a perfect example of how VMware successfully "twists" the questions of the exam to determine if the examinee has a deeper understanding of the material.
The main purpose of this post is to provide a list of references that I found helpful in my study for taking the exam. Sooooo, BOOM!, here's a bulletted list containing those references:

  • My favorite reference for studying became the vSphere Documentation Center found here http://pubs.vmware.com/vsphere-50/index.jsp. A couple reasons why it was my favorite are that it is extensive and covers nearly ever topic, it is easy to understand, and most important is that it gives you steps to follow when troubleshooting common issues that a feature may have. The exam covers a lot of troubleshooting.
  • The VMware Knowledge base. Found here, http://kb.vmware.com, the VMware KB is such an awesome library. My method of study was to find a topic and then physically go through the steps in a lab I have availability to at work. When I would run into an error or couldn't quite get something, the KB was invaluable.
  • VMware vSphere Clustering Technical Deepdive by Duncan Epping and Frank Denneman was an awesome source for learning the internals of Clustering in vSphere.
  • The VCP5 Exam Blue Print Found here: http://communities.vmware.com/servlet/JiveServlet/previewBody/16726-102-7-23055/VCP510%20Exam%20Blueprint%20Guide%201.4.pdf. I used this to know what I NEEDED to know, and then I would go about doing it in the lab and documenting what I did using screen shots.
  • The Official VCP5 Certification Guide is a newly released book from VMware. If I had to summarize this book, I would say it is a more helpful version of the classes. I like how the author writes and enjoy his simplicity. The book comes with testing software which is nice, but very misleading because of how easy it is. The ebook version comes with even more testing software that is unfortunately misleadingly easy too.

I recommend having access to some degree of a vSphere lab, although I will not directly recommend using a production environment, if you only had access to that type of environment, create your self a read-only account so you can safely poke around and you wont have to be worried about accidentally hitting something you didnt want to! You do not necessarily need to be able to vMotion and enable FT, as long as you have done them before, but knowing where to find these features and know where to configure them coupled with the references above should be sufficient to be successful on the exam. Look for future posts where the title starts with VCP5, these will contain gold for studying. Good Luck!


Wednesday, September 26, 2012

VMware Certified Professional 5

It has been awhile since I composed a new blog post, there was a really good reason for it...I swear! I had been studying for quite awhile to take the VCP5 exam. If you have never attempted this test, be forewarned, it is extremely hard. I had studied super hard, I had even bought the new Official VCP5 Certification Guide published by VMware and blew through the book in a week, and felt very comfortable with my knowledge of the subjects found in it. The book comes with testing software and if you buy the "Special" edition eBook it comes with more advanced testing software than just the book comes with. I was blowing those mock exams, provided in the testing software, out of the water. I had been scoring 480 out of 500, and taking only 30 minutes to do it too. I thought I was set! I signed up and took the exam and I was metaphorically pants'd. My first attempt was a 275 out of 500, needing 300 to pass. I was surprised at the difficulty of the test, they truly want you to have a deep knowledge of the material and troubleshooting methods. I felt pretty frustrated because a lit if hard work had been done, but I knew I needed to change my preparation methods. The key for me was doing more hands on versus just reading more. I signed up for the next soonest exam date I could (you have to wait 7 days), and through a lot of hard work and help from my wife and co workers I passed the exam on 20th. I plan to share my studying techniques and, recommend in detail areas of study in my next few posts while it is fresh in my mind. Thanks to everyone who helped me get to this awesome milestone in my career, thanks to all of those co-workers at House of Brick Technologies who helped me out, answered questions when I had them, and was supportive of me taking on this exam, you know who you are! More to come on prepping for the exam! WOO HOO

Tuesday, September 4, 2012

Deep Dive: CPU Ready Time

In my last post we tackled the topic, "VMWare ESX/ESXi CPU Scheduler",with extreme prejudice, this week will be an extension of that post. Lets talk about CPU Ready Time, how bout' it? (if you said "No", Click Here...). To put it simply: CPU Ready time is your enemy, but, to give a more formal definition of what CPU Ready Time: CPU Ready Time is when a Virtual Machine exists in a state when it is ready for processor time but cannot be scheduled on the processor. The CPU is at a point when it is "Ready" for processor time. I mentioned in my last post that CPU Ready time can be a performance killer and over allocation of vCPUs is most likely at the heart of the problem. To throw some data and thoughts at you really quick, I love me a good bulleted list and I hope you do too:
  • When possible, keep like CPU allocated VMs on the same hosts or clusters. This will help reduce CPU Ready time to a safe amount. VMware suggests 5% CPU Ready time is within the safe limits for a VM to live with. We will discuss safe zones a little later in the post. Regardless of recommendations, everyone should establish their own safe and red zone numbers. Even ours don't coincide with VMware's recommendation.
  • An ESXi host will try its best to keep a VM's requests for processor time, running on the same physical cores for caching purposes. If the benefits of moving the VM's processors requests to new cores is more efficient than waiting for the CPU scheduling to allow for processor time (CPU Ready Time), the ESXi host will clear the processor cache and move the existing and new processor requests to different cores, this move takes time and the effects can be felt in performance but the host has determined this to be the better choice than to let it accumulate any more CPU Ready time.
  • Many times CPU over allocation occurs when P2V'ing a physical machine into your Virtual environment. Although your super serious amazing awesome database server needed 12 CPUs in the physical world, monitor overtime and determine how many of those you can knock out of the picture. Maybe it could be taken down to 8 or even 6 vCPUs. 
  • In many cases, I would bet that 60-75% of workloads can fit within the 1-2 vCPU range, and I would also put money on 75-90% of workloads needing no more than 4 vCPUs. As a side note: I was reading this article on Ars Technica and found some of the hypervisor host stats for Hyper-V compared against VMware, pretty crazy and honestly, unnecessary. By the time I need 320 CPU hosts (yay Hyper-V), I would have hoped I would have been smary enough and separated that load into multiple hosts and created maybe a new cluster for high availability instead. I don't doubt there are some massive companies with an insane virtual infrastructure that could benefit from that size of hosts, but most companies and workloads don't come close to that. END OF SIDE RANT.
  • I recommend keeping a close eye, however you go about doing that in your environment, on the CPU utilization and CPU Ready Time, and always look for opportunities to reduce vCPU assignment or create like allocated vCPU Virtual Machines.
  • If you have hosts or clusters that have a huge amount of resources that are barely getting used by the VMs in your environment, you may be able to get away with not caring to much about mixing like vCPU assigned VMs. The effects of CPU Ready time are being masked by the fact that there are a bunch of physical resources. Wait for your work load get up to a medium amount of usage and your performance will start to ache because of that hidden CPU Ready time. 
With my awesome bullet-ed (spell checker wanted a hyphen, lame!) list aside, lets take a look at what in the world was going on in the "cliff hanger" picture I left at the bottom of my last post. Here is it once more:








So what are we looking at here? This is obviously a vSphere performace chart, it is showing the CPU Usage and CPU Ready time for a production VMware View Connection Server. To make a long story as short as I can, I was looking at the currently assigned Memory for this machine when I noticed the VM had been assigned 4 vCPUS.











I thought to my self, "Why in the world does this VM need 4 vCPUs?" Turns out after reading some additional View documentation, 4 vCPUs is the default recommended setting. So anyways, I thought just for fun I would take a look at the CPU usage to see how much this baby was actually using  Here is what I initially saw once I enabled the CPU Ready chart metric:









This VM was getting CPU Ready times on the "Real-time" chart of 2,500 to 3,700 milliseconds consistently . Its one thing to get some bad CPU Ready time in a blip or moment, but this was consistent and "reliable" CPU Ready time. This VM's performance was basically getting destroyed. To put these numbers into perspective lets take a look at how to interpret these millisecond numbers. I recommend learning and understanding what good and bad millisecond values are for CPU Ready Time, since this is how the vSphere performance charts presents this metric. Many people want % values, which are not bad, but because vSphere charting goes off of millisecond, I find it more beneficial to read the millisecond value and know what they mean.

If you know anything about how VMware saves statistical data this wont be news to you. But when you look at any performance chart BUT the "Real-time" view or the "Refreshes every 20 seconds view", the numbers you see present you with what looks like "higher" numbers. This seems this way because the stats are rolled up and its actually an average of the statistics saved.

To further describe roll-up effect, here are some basics to work off of.
  • The "Real-time" performance chart is updated every 20 seconds. As a good base line, 120 - 175ms is acceptable for CPU Ready Time on the "Real-time" chart. 500 ms is our red zone. For those of you who want percentages here is the equation: 
    • <currentValueINMilliseconds>/<intervalINMilliseconds>*100
    • For example 170/20,000*100 which gives us a percentage of .8% CPU Ready time. 
    • Doing the math, so you dont have to, our red zone is about 2.5%.
  • The "Day" performance chart shows the rolled up statistics for a day in 5 minute intervals. So if our Real-time interval is 20 seconds and 500ms is the red zone, our 5 minute interval red zone would be 7500ms. 
    • (5*60/20)*500=7500.  OR to simplify. From here on out our red zone is 1500ms for every minute.
  • The "Week" performance chart shows the rolled up stats for a week in 30 minutes intervals. So 30*1500=45000 is the red zone for the week chart.
Although I could do the math, because I am wicked smart, I will let you all do the rest of the math for the Month and Year charts and for any custom charts you make. Make sure you check your stats intervals on your vCenter(s) as the defaults are not always used. Access the interval settings this from the "vCenters Settings" button on the home page inside of vCenter. Heres a screen shotters for assistance:



So let me finish the story from earlier about the View Connection Server I was monitoring. To sum things up really quickly, the "Real-Time" chart screen shot I shared earlier with 2,500 to 3,700ms means that for 16% of the time this VM was not able to do anything, it was just sitting there and waiting! When would numbers like that ever be acceptable?

INITIATE SCIENTIFIC STUDY BENCHMARKS

Advanced Scientific Study #1:
IT Manager: Why is this VM so dang slow?
IT Employee: Uhhhh, well it works 84% of the time...
Outcome: NOT ACCEPTABLE

Advanced Scientific Study #2:
PotentialCustomer: What kind of guarntee can we expect for up time if we decide to go with your facility?
PotentialDatacenterFacility: Uhhhh, we are up about 84% of the time around here...
Outcome: NOT ACCEPTABLE

Advanced Scientific Study #3:
Wife: How much do you love me?
Husband: Uhhhh, about 84%...
Outcome: DIVORCED

To finish up here (this post is SOOOO LONG) I asked for a downtime window from the customer, and went in and removed 2 vCPUs. The end result of removing those 2 vCPUs is what is shown in the initial screen shot highlighted by the "BOOM!". The CPU Ready time drops off and is almost non existent. One last picture, here is a screenshot showing the "Real-time" view with the CPU Ready metric active. This screenshot was taken about 30 minutes after I changed the vCPU assignment. Check out the dive CPU Ready time took, AWESOME.








I hope that this post has been a helpful tool in helping you understand CPU Ready time more fully. I hope the real world scenario described in the post helps tie it all together. Be a Monsterrrrrr at work, destroy CPU Ready time.

Thursday, August 30, 2012

Deep Dive: VMWare ESX/ESXi CPU Scheduler

Reviewing the concepts covered in Larry Loucks book "Critical VMware Mistakes you Should Avoid", we will first look at the CPU Scheduler. Larry's book does a great job of giving an overview of the CPU scheduler and core concepts of how it works, I hope this post builds on top of the core concepts and I hope this post feels more like a deep dive than a general overview, soak it up you nautical beast.

The VMware CPU scheduler is no hidden secret and many people including you reading this post probably know what it is and how it works. That aside I love learning about these kind of topics, and as I have said in previous posts, these topics to me are what make IT interesting. This first post will be a relatively high level over view of how ESX (referring to both ESX and ESXi) schedules CPU, in later posts we will dive a little deeper. Lets get to it!

Both the CPU Scheduler and Hypervisor (viewing them temporarily as separate entities) play a big part in CPU scheduling. The CPU scheduling is obviously done by the hypervisor, but and in lamens terms the CPU scheduler's role is to present and assign world (think VM) executions to the physical processors keeping within the constraints of acceptable performance for the VMs while prioritizing processor requests. While the CPU scheduler determines which world (think VM) to schedule, the hypervisor holds the task of presenting the physical CPUs to each VM( here is a duh moment when thinking about hypervisors but just to say it) as if they each own the physical CPUs. Lets figure out how the CPU scheduler does its job of prioritizing processor requests.

If you are any bit familiar with vSphere you most likely understand the concepts of shares, reservations and limits in regards to physical resources, these are the user-set configuration values for each VM within a vSphere Datacenter. For reviews sake, lets take a look at them very briefly:
  • Shares: Shares are simply used to prioritize resources for use by VMs when there is active resource contention. If you give a VM 1000 shares of CPU and another 500, when resource contention arises, the VM with 1000 shares will be granted access to twice as much CPU as the VM with 500 shares.
  • Reservations: This is a guaranteed amount of resources RESERVED for a particular VM. When a VM is powered on the reserved amount of resources are given to that VM and are "eliminated" from the pool of open resources that other VMs can use. A VM can(should)not power on if a the host it resides on does not have enough resources to meet the reservations of that VM. (DRS rocks)
  • Limits: A limit is as easy to explain as reservations, it is a limit on the amount of resources that a VM can use. I can never grasp this concept completely because personally if I wanted a VM to have a "limit" of 10 GB of RAM, I would only allocate it that much. Plus if you use limits and there are resources abundant, you could be potentially wasting available resources.
These configuration settings are known as entitlements and are what the CPU scheduler uses to determine priority when scheduling worlds (think VMs) to the physical processors. If you dont know where to edit these settings, just right click any VM and edit its settings within the vSphere client and go to the "Resources" tab. Peep the screen shot if you need a reference! BAM!


In basic terms the CPU scheduler looks at a world's entitlements compared to its used CPU resources, then the CPU scheduler affixes a numeric value to that request. The lower the number, the higher priority. If a world requests processor time and its entitlements are higher, its CPU usage is lower, and its assigned numeric value is lower than the requests for processor time from other worlds, it will be given priority. One of the core concepts is that when a world requests access to the physical CPUs, it needs access to as many cores as it has vCPUs. Although this method is becoming more "relaxed" the basic ideals apply. I highly recommend you go read my co-worker Jim Hannan's post about the CPU Co-Scheduler and its evolution from the strict Co-Scheduler in 2003 to the now [extremely] relaxed Co-Scheduler. Heres the link to his post:

http://www.houseofbrick.com/blog/vsphere-5-advantages-for-vbca-part-1.html?blogger=solutionsarchitects

To further illustrate how the CPU scheduler works and its fundamentals (although they are always being adjusted), lets take a visual looksie!:
Example1 (click for largification):


Basically what is shown here is an ESXi host with 2 CPU sockets each dual core. Currently the processor has 3 of 4 cores scheduled, which means that the only other VMs that could/will be scheduled will be either one of VM9, VM5, or VM6. Which VM will actually get the spot will be determined by the entitlements algorithm. Whichever VM has the lower numeric rating will take the last single core schedule. Both VM1 and VM3 are "disqualified" from getting  scheduled at the moment because they both have more vCPUs than cores are available. This is event is known as CPU Ready Time, which by definition means that the VM is ready and needs CPU, but there are not enough resources to accomidate the VM, so it waits....bad stuff happens if the CPU Ready time gets out of hand. My next blog post will be about CPU Ready and a real world example I just experienced at work this week. Lets take a look at another example.
Example 2 (click for largification):


In example 2 we can see that of the 4 cores of the system, only one is being accessed at the moment with 1 scheduled vCPU request. With a total of 3 cores available at the moment, VM9, VM5, VM3, and VM6 are all potential candidates for being scheduled. It will come down to entitlements once again. Lets assume that VM3 has been given more entitlements, one factor that alludes to this is that it has been assigned 2 vCPU instead of 1. So our buddy VM3 gets scheduled on 2 cores which leaves one last core for which ever of our single core VMs is entitled higher.

There are cases obviously where entitlements match and there is no real "winnner", I would refer you to the white paper mentioned at the bottom of this post for more details on that matter. SOOOO, we got all cores scheduled, good job ESX CPU Scheduler, one problem, our poor 4 vCPU, VM1, is still left out in the cold, cranking up his CPU Ready time. If CPU ready time gets to high, a VM could be potentially be waiting secondS (no I didnt fat finger the the "S", just emphasizing the point that theres multiple) for its CPU requests/needs to be met. Here is a design hint, keep VMs with like vCPU allocation on the same hosts, this will keep CPU Ready time lower. If you have a host with mostly 2 vCPU VMs, they will get scheduled quicker because 2 free cores will free up more often because other 2 vCPU VMs were just scheduled. Also, try to limit the vCPUs assigned to VMs to only the number they truely need, granted this is probably a "DUH" moment, people sometimes get a little vCPU, this is a classic case of how over allocation can hurt ya in the VMware wold. Check the VM performance in the vSphere client, my favorite at the moment is choose an advanced chart under performance and select the CPU usage by percentage and also view the CPU Ready time. CPU Ready time is safe at around 100ms to 150ms (real-time), the danger zone (welcome) for a real time graph would be 500ms. Look for my next post to get me details on this.

I am a firm believer that these concepts about the CPU Scheduler in ESX/ESXi should be known and understood to better grasp how to monitor and size your VMs, that being said, these concepts are changing and evolving with each vSphere release. Once again I will refer you to Jim Hannan's post that I linked up above, he discusses in detail the the evolution and current version of the CPU Scheduler. To make a point about the evolution of the CPU Scheduler, in both of the visual examples from up above, the relaxed Co-Scheduler will now allow some multi vCPU machines to be scheduled even if all cores are not available. Take a look at Jim's post DANGIT!

I leave you with this final screen shot, check it out, be stunned, pick your jaw up off the ground. Compare the safe and danger zones in millisecond I just shared with you for CPU Ready time, to what you see in this graph. I will talk about this is my next post. CPU Ready time for the win! (click for largification)


The link below is a white paper that I used as a companion while reading "Critical VMware Mistakes That You Should Avoid", its a REALLY good read. Many of the initial concepts found in the paper I mention in this post, but it goes way way ... way deeper than my post. You will notice its for vSphere 4.1, I feel like VMware is no longer writing these types of beneficial deep dives, so referencing the old docs is what you a lot of times have to result to.
http://www.vmware.com/files/pdf/techpaper/VMW_vSphere41_cpu_schedule_ESX.pdf