Sunday, 12 February 2012

Memory/CPU Optimization in Citrix

Citrix Presentation Server 4.0 introduced two resource optimization features that help increase scalability by as much as 25% and ensure a smoother user experience. These two features, memory optimization and CPU optimization, are distinct and function in unique ways. Memory and CPU optimization are not enabled by default.

Memory Optimization

When an application starts, the operating system maps application DLLs to the base memory address space. The default base memory address of applications is 0x10000000. Memory optimization works by redirecting the base memory address of applications to an alternate location. When multiple applications start and try to write to this base memory address and find it already in use, they must be relocated elsewhere. In doing so, the module code must be modified and produces a performance hit on application initialization time.With memory optimization invoked, the base memory addresses of installed applications are rebased at a predefined interval. This means that the base memory address is altered, and as such, the applications are relocated to another address automatically during initialization. The end result is that applications load faster because intermediate redirection.


During the predefined memory rebasing interval, a safe memory base address is calculated and designated. Thus, the 0x10000000 address is altered. The memory rebasing interval is set within the server farm properties, and should be scheduled during times of minimal use. Options are: startup, daily, weekly, or monthly. By default, the files listed in the HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\SFO\ProcessExclusionList registry key are excluded from rebasing. Additional applications can be excluded from memory rebasing by being added to the exclusion list within farm properties memory optimization. Once added in the GUI, they will also be added to this registry key. The repair.sfo file includes the files that have been rebased, and the timestamp of the rebased DLLs will be modified to reflect the approximate time of the rebasing interval.

Some applications cannot be rebased. These include applications with digitally signed components, DLLs protected by Windows Rights Management, and any executable that programmatically checks the DLL after it has been loaded. However, even if an application is not included on the exclusion list, it simply means that rebasing will be attempted but will not be successful. Since rebasing should be scheduled during a time of minimal server use, the resource impact of the attempted rebasing should not be noticeable.

Memory optimization is based on the Citrix Virtual Memory Optimization service. This Windows service scans loaded DLLs every 10 seconds to determine which DLLs have been relocated. By default, this service runs under the context of the local system account but can be modified within farm properties.

The graphic shown below shows that without memory optimization invoked, all applications attempt to write to the same base memory address space, whereas with memory optimization invoked, each application cleanly gets directed to a unique address space.

Without Memory Optimization Configured

 

 With Memory Optimization Configured

 

CPU Optimization
CPU optimization is based on Presentation Server reserving approximately 20% of the CPUs for automatic optimization. As a result, no single session controls the majority of CPU processing. However, CPU power can be borrowed from idle or inactive sessions but re-allocated when active again.

CPU optimization is based on two Windows services:

• Citrix CPU Utilization Mgmt/Resource Mgmt: Monitors users and processes, calculates load, and sets CPU priority.
• Citrix CPU Utilization Mgmt/ User-Session Sync: Ensures that user processes get associated with user to determine
load.

Impact to Architectural Designs

Invoking memory and CPU optimization is typically beneficial and should not have any noticeable negative impact. Memory optimization should be scheduled during a time of low or no usage. If an administrator is uncertain as to whether specific applications cannot take advantage of this feature, they should not be added to the exclusion list. Only those applications which have known issues based on the criteria described above should be placed on the exclusion list. Because CPU optimization uses approximately 20% of the CPU processing power, older servers with limited CPU resources may not have sufficient CPU to support this feature.

Considerations

As part of the application testing process, memory and CPU optimization should be tested to ensure that there is no adverse impact to the environment.

The impact of memory and CPU optimization can be viewed in standard Access Suite Console reports. In addition, CPU utilization can be viewed within the new Citrix CPU Utilization Mgmt User object, which can be accessed via Resource Manager or Performance Monitor. This object includes the following counters: CPU entitlement, CPU reservations, CPU shares, CPU usage, and long-term CPU usage.

No comments:

Post a Comment

Next previous home