VUEM Effect

We decided to give to try to VUEM onto one of ours envs to estimate the applicable users optimization.

What do VUEM Memory optimization do ?

To keep it simple, after an defined process idle time, VUEM ask to the OS to unload used memory onto swap space.

We monitor users sessions WorkingSet and VirtualSize. VirtualSize is the total memory allocated to a process (RAM+Swap) and WorkingSet is the usable part (RAM). Monitoring is done with powershell and WMI on a dedicated Citrix Serveur, we send measured value into a RRD.

$sessions = get-xasession -BrowserName MyApp
#(... Some initialization here)
$sessions	| group ServerName |% {
	$servername = ($_.Name.split(':')[0])
	$user_sess = (	$_.group |% {
		$sessionid = $_.SessionId
		$data = gwmi win32_Process -computername $_.ServerName  -Filter "SessionId='$($_.SessionId)'" | 
			select NAme, ProcessID, PAgeFileUsage, @{N='WSKb';E={$_.WorkingSetSize/1Kb}},@{N='VSKB';E={$_.VirtualSize/1Kb}} | 
			measure-object -property PageFileUsage, WSKb, VSKB -sum 
		new-object Psobject -property @{"SessionID"=$sessionID;"PageFileUsage"= $($data |? {$_.property -eq "PageFileUsage"}).Sum;"WSKB"=$($data |? {$_.property -eq "WSKB"}).Sum;"VSKB"=$($data |? {$_.property -eq "VSKB"}).Sum}
	})
	if(test-path "$($ServerName)_session.csv" ){
		$session_DS = @(import-csv "$($ServerName)_sess.csv" -delim ',' |% { 
			if( ($user_sess |% { $_.SessionID}) -notcontains $_.session){
				$_.session = $null
			}
				$_
		})
	}else{
		$session_DS = @()
	}

	$user_sess = ($user_sess |% {  
		$rank = ($session_DS |? {$_.Session -eq $_.Sessionid }).rank
		if(-not($rank )){
			$rank = ($session_DS |? { -not ($_.Session) }).rank
			if(-not( $rank) ){
				$rank = ($session_DS | measure-object -Max Rank).Maximum + 1
				if(-not($rank)){$rank=1 }
				$session_DS +=(new-object PSObject -property @{"Rank"=$rank;"Session"=$_.SessionId} )
			}else{
				$session_DS[$rank-1]=new-object PSObject -property @{"Rank"=$rank;"Session"=$_.SessionId} 
			}
		}
		$_ | add-member -type noteproperty -name Rank -Value $rank -passthru
	} )| sort Rank 
	$value = @($user_sess|% { "$($_.PageFileUsage/1kb):$($_.WSKB/1kb):$($_.VSKB/1kb)"})
	if($value.count -ne 25){
		1..(25-$value.count) |% {
			$value+=("U:U:U")
		}
	}
	$session | select Rank, @{N="Session";E={$_.SessionId}} | export-csv "$($ServerName)_sess.csv" -delim ','
	$filter = "$($ServerName)_session*"	
	Update-RRD -rrd $($rrdsources |? { $_.File -like "$filter"}) -values $value
}	

As planned, VUEM did not have any effect on Virtualsize, by cons, WorkignSet was regulary emptied
NoVUEM_session_VirtualSizeVUEM_session_VirtualSize

Sessions VirtualSize are gloablly the same on both servers.
NoVUEM_session_WorkingSetVUEM_session_WorkingSet

Lesser WorkingSet size on the server with VUEM, the effect is more evident if we stack them.
NoVUEM_Stacked_WorkingSetVUEM_Stacked_WorkingSet

And what about my servers ?

The first consequence is an improvement of your servers abilities to host users. is making a preemptive swapping, active processes can have more available resources. In our test, we can improve hosting ability by more than 40%.
graph_rdp_session

During the choosen day, the user load for server with VUEM was 40% higher.

Here’s some server metrics _ RAM 12Gb, Swap 6Gb :
graph_memusage

graph_swap_usage

graph_xaload

graph_CPU_Load

The server with VUEM filled his swap earlier and more rapidly, that allowed it to have more RAM available for active users, we were able to stack 40% more users with no “slowdown remarks” by users. The VUEM Effects?

Leave a Reply

Your email address will not be published.