Upload
ukdpe
View
3.966
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Windows Server 2008 will be launched in Q1 2008. Come and learn what’s new in this release for developers. Agenda: Whether you are building Web applications or writing core server-based system services, Windows Server 2008 provides many new features that you can leverage to build more secure, flexible, and innovative applications. In this 2-session event we will go through the “Top 7 Ways to Light Up Your Apps on Windows Server 2008”. Demos will include IIS7, PowerShell, Transactional File System (TxF), restart/recovery APIs plus more. For more details and the original slidedeck visit http://www.microsoft.com/uk/msdn/events/new/Detail.aspx?id=136
Citation preview
for Developers
Daniel MothDeveloper and Platform GroupMicrosofthttp://www.danielmoth.com/Blog
AGENDA
Top 7 Ways To “Light Up” Your Apps on Windows Server 2008Part 1 emphasis on
IIS7, PowerShell
Part 2 emphasis onWER, Restart and Recovery APIs, TxF
1. Build More Flexible Web Apps
2. Design Highly-Manageable Apps
3. Develop Federation-Aware Apps
4. Build Connected Systems
The Top 7 Ways… Part 2
1. Build More Flexible Web Applications2. Design Highly-Manageable Applications3. Develop Federation-Aware Applications4. Build Connected Systems5. Build For Scalability6. Develop More Reliable Applications7. Virtualize
5. Build For Scalability
Native Threading Enhancementsin Windows Vista and Windows Server 2008
Thread Pools
One-Time Initialization
Slim Reader/Writer Lock
Condition Variables
Thread Ordering Service
Wait Chain Traversal
Thread Pool in Vista and Server 2008
Re-architected Thread PoolSimpler, more reliable, higher performanceDoes not use a timer threadSingle queueDedicated persistent threadClean-up groupsSingle worker thread type (both I/O and non-I/O)Multiple pools per processMore flexible API
Feature Original API Current API
Synch RegisterWaitForSingleObjectUnregisterWaitEx
CloseThreadpoolWaitCreateThreadpoolWaitSetThreadpoolWaitWaitForThreadpoolWaitCallbacks
Work QueueUserWorkItem
CloseThreadpoolWorkCreateThreadpoolWorkSubmitThreadpoolWorkTrySubmitThreadpoolCallbackWaitForThreadpoolWorkCallbacks
TimerCreateTimerQueueCreateTimerQueueTimerChangeTimerQueueTimerDeleteTimerQueueTimerDeleteTimerQueueEx
CloseThreadpoolTimerCreateThreadpoolTimerIsThreadpoolTimerSetSetThreadpoolTimerWaitForThreadpoolTimerCallbacks
I/O BindIoCompletionCallback
CancelThreadpoolIoCloseThreadpoolIoCreateThreadpoolIoStartThreadpoolIoWaitForThreadpoolIoCallbacks
Clean-up groupCloseThreadpoolCleanupGroupCloseThreadpoolCleanupGroupMembersCreateThreadpoolCleanupGroup
PoolCloseThreadpoolCreateThreadpoolSetThreadpoolThreadMaximumSetThreadpoolThreadMinimum
Callback environmentDestroyThreadpoolEnvironmentInitializeThreadpoolEnvironmentSetThreadpoolCallbackCleanupGroupSetThreadpoolCallbackLibrarySetThreadpoolCallbackPoolSetThreadpoolCallbackRunsLong
Callback CallbackMayRunLong
Callback clean upDisassociateCurrentThreadFromCallbackFreeLibraryWhenCallbackReturnsLeaveCriticalSectionWhenCallbackReturnsReleaseMutexWhenCallbackReturnsReleaseSemaphoreWhenCallbackReturnsSetEventWhenCallbackReturns
One-Time Initialization
Interlocked functions ensure that only one thread performs the initializationOne-time initialization is better
Optimized for speedAppropriate barriers are created on processor architectures that require themSupport for both locked and parallel initializationNo internal locking so the code can operate asynchronously or synchronously
One Time Init StepsBOOL WINAPI InitOnceBeginInitialize(
__inout LPINIT_ONCE lpInitOnce, __in DWORD dwFlags, __out PBOOL fPending, __out LPVOID* lpContext );BOOL WINAPI InitOnceExecuteOnce(
__inout PINIT_ONCE InitOnce, __in PINIT_ONCE_FN InitFn, __inout_opt PVOID Parameter, __out LPVOID* Context ); BOOL WINAPI InitOnceComplete(
__inout LPINIT_ONCE lpInitOnce, __in DWORD dwFlags, __in LPVOID lpContext );BOOL CALLBACK InitOnceCallback(
__inout PINIT_ONCE InitOnce, __inout_opt PVOID Parameter, __out_opt PVOID* Context );
Slim Reader/Writer LockSRW locks – new synchronization primitive
enable threads to access shared resourcesoptimized for speed take very little memorybuilt on top of windows kernel keyed events
Two modesShared mode
– grants shared read-only access to multiple reader threads
Exclusive mode– grants read/write access to one writer thread at a time
SRW Lock APIs
VOID WINAPI InitializeSRWLock( __out PSRWLOCK SRWLock );
VOID WINAPI AcquireSRWLockExclusive( __inout PSRWLOCK SRWLock );
VOID WINAPI ReleaseSRWLockExclusive( __inout PSRWLOCK SRWLock );
VOID WINAPI AcquireSRWLockShared( __inout PSRWLOCK SRWLock );
VOID WINAPI ReleaseSRWLockShared( __inout PSRWLOCK SRWLock );
Condition Variables
Used to synchronize a group of threads based on the result of some conditional testEnable threads to atomically release a lock and enter the sleeping stateBenefits
Much clearer and less error-proneCan be more efficient
– Tries to avoid trips to kernel mode (unlike WaitForSingleObject)
Condition Variable APIsVOID WINAPI InitializeConditionVariable(
__out PCONDITION_VARIABLE ConditionVariable );BOOL WINAPI SleepConditionVariableCS(
__inout PCONDITION_VARIABLE ConditionVariable, __inout PCRITICAL_SECTION CriticalSection, __in DWORD dwMilliseconds );
BOOL WINAPI SleepConditionVariableSRW( __inout PCONDITION_VARIABLE ConditionVariable, __inout PSRWLOCK SRWLock, __in DWORD dwMilliseconds, __in ULONG Flags );
VOID WINAPI WakeConditionVariable( __inout PCONDITION_VARIABLE ConditionVariable );
VOID WINAPI WakeAllConditionVariable( __inout PCONDITION_VARIABLE ConditionVariable );
Thread Ordering Service (TOS)
TOS controls the execution of client threadsEnsures that they run once and in order
5 APIs – AvRtXxxxThreadOrderingGroupparent thread calls Create to set up the TOSclient threads call Join to join the TOSall of them call Wait, run their code and Wait...client threads call Leave when they are doneparent thread calls Delete to end it all
TOS APIs - avrt.hBOOL WINAPI AvRtCreateThreadOrderingGroup( __out PHANDLE Context, __in PLARGE_INTEGER Period, __inout GUID* ThreadOrderingGuid, __in_opt PLARGE_INTEGER Timeout );
BOOL WINAPI AvRtJoinThreadOrderingGroup( __out PHANDLE Context, __in GUID* ThreadOrderingGuid, __in BOOL Before );
BOOL WINAPI AvRtWaitOnThreadOrderingGroup( __in HANDLE Context );
BOOL WINAPI AvRtLeaveThreadOrderingGroup( __in HANDLE Context );
BOOL WINAPI AvRtDeleteThreadOrderingGroup(
__in HANDLE Context );
Wait Chain Traversal (WCT)
Enables debuggers to diagnose application hangs and deadlocks
“Wait chain is an alternating sequence of threads and synchronization objects; each thread waits for the object that follows it, which is owned by the subsequent thread in the chain”
WCT supports the followingALPC, COM, Critical sections, Mutexes, SendMessage
WCT APIs in Wct.h
HWCT WINAPI OpenThreadWaitChainSession( __in DWORD Flags, __in_opt PWAITCHAINCALLBACK callback );
BOOL WINAPI GetThreadWaitChain( __in HWCT WctHandle, __in_opt DWORD_PTR Context, __in DWORD Flags, __in DWORD ThreadId, __inout LPDWORD NodeCount, __out PWAITCHAIN_NODE_INFO NodeInfoArray, __out LPBOOL IsCycle );
VOID WINAPI CloseThreadWaitChainSession( __in HWCT WctHandle );
VOID CALLBACK WaitChainCallback( HWCT WctHandle, DWORD_PTR Context, DWORD CallbackStatus, LPDWORD NodeCount, PWAITCHAIN_NODE_INFO NodeInfoArray, LPBOOL IsCycle );
typedef struct _WAITCHAIN_NODE_INFO { <SNIP>
Native Threading Enhancementsin Windows Vista and Windows Server 2008
Thread Pools
One-Time Initialization
Slim Reader/Writer Lock
Condition Variables
Thread Ordering Service
Wait Chain Traversal
MSDN Magazine: Oct07, Jun07, Jul07
6. Develop More Reliable Apps
Windows Error Reporting & winqual
New User ExperienceIn addition to crashes, hangs are also detectedPrivacy evaluation, Queuing and transportProblem Reports and SolutionsResponse management
New Public APIsAdding additional file and memory data to a report (inc. minidump & heap information)Create reports for custom events
WER, Restart, Recovery
Restart API
Register to be restarted after fatal problemsRegistration also used for Restart Manager
– Restarts process after patch installation
All applications should support restart– Especially if support document recovery
How it worksRegister command-line that should be called every execution
– HRESULT RegisterApplicationRestart (IN PCWSTR pwzCommandline, DWORD dwFlags)
After fatal event is reported, app is restarted– Fatal events block user tasks– Automatically restarting saves users from having to re-open the application
Recovery APIs
Attempt to recover data after a fatal eventUsers should not lose any work to an app bug
How it works1. App registers a “recovery callback” every execution
HRESULT RegisterApplicationRecoveryCallback (IN RECOVERY_ROUTINE RecoveryRoutine, IN PVOID pvParameter)
2. Recovery routine called after data collection– Application’s code attempts to recover user work
– Flush to disk, repair on next run of application– Repair data in memory, save to disk
– Need to call RecoveryInProgress() every 5 seconds to heartbeat– Call RecoveryFinished() to signal recovery is completed
Restart Manager Overview
With the Restart Manager technology installers canAutomatically shutdown only the applications and services holding a file to be updatedWhen available, leverage specific application functionality to restore the user to the state they were in before the restartWhen a reboot cannot be avoided, automatically re-launch apps after reboot
Restart Manager
Restart Manager, Call to Action
Installer software call the Restart Manager APIs
Applications and Services Restart Manager "aware”
Transactional NTFS
Windows Vista and Windows Server 2008
Does what it says on the tin
System.Transactions.dll + PInvoke
Transactional PlatformKernel Transaction Manager (KTM)
Makes transactions available as kernel objectsProvides transaction management services to system components such as TxFCan communicate with DTC to enable distributed transactions
Transactional NTFS (TxF)Integrates transactions directly into the NTFS file system
Transactional Registry (TxR)Integrates transactions directly into the Registry
Transactional NTFS (TxF)K
ern
el
KTMKTM
CLFSCLFSNTFSNTFS RegistryRegistry
KtmRmKtmRm KtmW32KtmW32DTCDTC
Nati
ve
Man
ag
ed System.TxSystem.Tx LTMLTM
WS-*
WCF
MSMQ
SQL
TxF
7. Virtualize
Hosted Virtualization ProductsMicrosoft Virtual PC 2007
Over 3.5 million downloadsSupport for Windows Vista as a host and guest64-bit host support Improved performanceSupport for Intel VT and AMD-V
Microsoft Virtual Server 2005 R2 SP1Support for Intel VT and AMD-VSupport for SLES 10VSS integration for live backup of running virtual machinesVHD mounting tool for offline servicingImproved performanceImproved scalability: 512 VMs on x64 systems
Server Server VirtualizationVirtualization
Application Application VirtualizatioVirtualizatio
nnDesktop Desktop
VirtualizatiVirtualizationon
PresentatioPresentation n
VirtualizatiVirtualizationon
ManagemeManagementnt
A comprehensive set of virtualization products, from the data center to the desktopAssets – both virtual and physical – are managed from a single platform
Microsoft Virtualization Products
Centralized Desktop
Hyper-V Server
Virtualization BenefitsServer consolidationServer consolidation
Business ContinuityBusiness Continuity FlexibilityFlexibility
UtilizationUtilization
Hyper-V
Flexible and dynamic virtualization solutionA role of Windows Server 2008 (Std, EE, DC)
Can be a full role with local UI or Server Core role
Hypervisor based architectureManaged by Microsoft System CenterAlso provided as a standalone server
Microsoft Hyper-V Server ($28)
Codename "Viridian", Windows Server Virtualization
Windows Server Core roleServer Core
Minimal Installation option in all x86/x64 editionsCommand line interface only, no GUI shellProvides essential server functionalityDeployed for a single role
– No need to deploy and service the whole OS
BenefitsLess code results in fewer patches and servicing burdenLow surface area targeted for server rolesMore secure and reliable with less management
Virtualization and High AvailabilityTraditional Non-Virtualized Environment
Downtime is bad, but affects only one workload
Virtualized Environment
Value of the physical server goes upDowntime is far worse because multiple workloads are affected
Virtualization and High-Availability Go Hand in Virtualization and High-Availability Go Hand in HandHand
Virtualization and High-Availability Go Hand in Virtualization and High-Availability Go Hand in HandHand
Microsoft Hyper-V High Availability
Planned downtimeMore common than unplannedQuickly move virtualized workloads in order to service underlying hardware
Unplanned downtimeNot as common and more difficultAutomatic failover to other nodes
– hardware or power failure
Quick Migration FundamentalsPlanned Downtime
Save stateSave entire virtual machine state
Move virtual machineMove storage connectivity from origin to destination host
Restore state and RunRestore virtual machine and run
VHDsVHDs
Network ConnectivityNetwork Connectivity
Shared StorageShared Storage
Quick Migration – Planned Downtime
• Active server requires Active server requires servicingservicing
• Move virtualized Move virtualized workloads to a standby workloads to a standby serverserver
• ~4 seconds downtime ~4 seconds downtime per virtual machineper virtual machine
• Active server requires Active server requires servicingservicing
• Move virtualized Move virtualized workloads to a standby workloads to a standby serverserver
• ~4 seconds downtime ~4 seconds downtime per virtual machineper virtual machine
Virtualization Virtualization ServersServers
(3 + 1 Servers)(3 + 1 Servers)
System CenterSystem CenterVirtual Machine ManagerVirtual Machine Manager
Windows Server 2008Windows Server 2008Failover Cluster ManagerFailover Cluster Manager
VHDs onVHDs onSANSAN
DomainDomainControllerController
Eth
ern
et
Storage Storage ConnectivityConnectivity
Quick Migration – Unplanned Downtime
• Active server loses Active server loses powerpower
• Virtual machines Virtual machines automaticallyautomatically restart restart on the next cluster on the next cluster nodenode
• If there is not enough If there is not enough memory, the failover memory, the failover automaticallyautomatically moves to moves to the next node until the next node until donedone
• Active server loses Active server loses powerpower
• Virtual machines Virtual machines automaticallyautomatically restart restart on the next cluster on the next cluster nodenode
• If there is not enough If there is not enough memory, the failover memory, the failover automaticallyautomatically moves to moves to the next node until the next node until donedone
Virtualization Virtualization ServersServers
(3 + 1 Servers)(3 + 1 Servers)
System CenterSystem CenterVirtual Machine Virtual Machine ManagerManager
Windows Server Windows Server 20082008Failover Cluster Failover Cluster ManagerManager VHDs onVHDs on
SANSAN
DomainDomainControllerController
Eth
ern
et
Storage Storage ConnectivityConnectivity
Quick Migration – How Quick Is It?
Disc /Disc /VM MemoryVM Memory
1 GbE iSCSI1 GbE iSCSI 2 Gb FC2 Gb FC 4 Gb FC4 Gb FC
512 MB512 MB ~8 seconds ~ 4 seconds ~2 seconds
1 GB 1 GB ~16 seconds ~8 second ~ 4 seconds
2 GB2 GB ~32 seconds ~16 seconds ~8 seconds
4 GB4 GB ~64 seconds ~32 seconds ~16 seconds
8 GB8 GB ~2 minutes ~64 seconds ~32 seconds
TerminologyHypervisor
A piece of software that provides the ability to run multiple operating systems on one piece of hardwareEnsures that the CPU and hardware answer the *correct* OSMicrokernelized or Monolithic
Hyper-VA role you can install in Windows that includes the Hypervisor as well as management software
PartitionAn “operating system” to the hypervisor
Virtual MachineA “child” partition
Hyper-V Overview
Windows Hypervisor• Powerful virtualization built into the
Windows platform
VirtualizationPlatform andManagement
Management toolsManagement tools
VM 2VM 2“Child”“Child”
VM 1VM 1“Parent”“Parent”
VM 2VM 2“Child”“Child”
Hyper-V Architecture
Parent PartitionParent Partition Child PartitionsChild Partitions
Kernel ModeKernel Mode
User ModeUser Mode
VirtualizationService
Providers(VSPs)
WindowsKernel
Server Core
IHVIHVDriversDrivers
VirtualizationServiceClients(VSCs)
WindowsKernel
EnlightenmentsVMBus
Windows hypervisor
Virtualization Stack
VM WorkerProcessesVM
Service
WMI ProviderApplicationsApplications
“Designed for Windows” Server Hardware
Provided by:Provided by:
WindowsWindows
ISVISV
OEMOEM
Hyper-VHyper-V
Example VSP/VSC DesignParent PartitionParent Partition Child PartitionsChild Partitions
Kernel ModeKernel Mode
User ModeUser Mode
Windows hypervisorWindows hypervisor
ApplicationsApplications
Provided by:Provided by:
WindowsWindows
ISVISV
OEMOEM
Hyper-VHyper-V
VMBusVMBus
Windows File SystemWindows File System
VolumeVolume
PartitionPartition
DiskDisk
Fast Path Filter (VSC)Fast Path Filter (VSC)
iSCSIprtiSCSIprtVirtual StorageVirtual Storage
Miniport (VSC)Miniport (VSC)
Virtual StorageVirtual Storage
Provider (VSP)Provider (VSP)
StorPortStorPort
HardwareHardware
StorPortStorPort
MiniportMiniport
VM Worker ProcessVM Worker Process
DiskDisk
Monolithic vs. MicrokernelizedMonolithic hypervisor
Simpler than a modern kernel, but still complexContains its own drivers model
Microkernelized hypervisorSimple partitioning functionalityIncrease reliability and minimize TCBNo third-party codeDrivers run within guests
VM 1VM 1(“Admin”)(“Admin”) VM 3VM 3
HardwareHardware
HypervisorHypervisor
VM 2VM 2(“Child”)(“Child”)
VM 3VM 3(“Child”)(“Child”)
Virtual-Virtual-ization ization StackStack
VM 1VM 1(“Parent”)(“Parent”)
DriversDriversDriversDriversDriversDrivers DriversDriversDriversDriversDriversDrivers DriversDriversDriversDriversDriversDriversHypervisorHypervisor
VM 2VM 2
HardwareHardware
DriversDriversDriversDriversDriversDrivers
Microkernelized Hypervisor has an inherently secure architecture with minimal Microkernelized Hypervisor has an inherently secure architecture with minimal attack surfaceattack surface
VMware ESX ApproachVMware ESX Approach Hyper-V ApproachHyper-V Approach
Virtual Server 2005 vs. Hyper-V
Hyper-V Features and AbilitiesPerformance
HypervisorSynthetic DriversServer Core
FlexibilityMulti-architectureMulti-OS VM’s
ManageabilityManaged through WMI (PowerShell)SCVMMWindows
Interoperability & Standards VHD (Virtual Hard Disk)
VHD specification is freely available under Open Specification Promise (OSP)VHD TestDrive program for ISVs
Standards based management APIsDMTF defining industry standard model for VM managementHyper-V uses this model
Hypervisor hypercall APIPreliminary documentation available under OSPFinal version will be at RTM
Interoperablity & 3rd Party OS SupportLinux
Working with XenSource– Developing adapter layer to map Xen hypercall API to
Hyper-V hypercall API– Developing disk and networking drivers (VSCs) to integrate
with the new I/O architecture
Working with Novell– Interoperability and joint support for Windows Server and
Novel SUSE Linux Enterprise Server 10
Support for Linux on Hyper-V
SolarisWorking with Sun to support Solaris on Hyper-V
Windows Server Enterprise/Datacenter Includes 4/Unlimited virtual instances
Windows Vista (Software Assurance Customer Benefit)Allows Vista Enterprise Centralized Desktop deployments
Licensing per Virtual ProcessorSQL Server, BizTalk Server, etc.
Instance Based LicensingWill enable new usage models
Demo Distribution of Virtual Images
Industry Leadership In Licensing
Virtualization Investments
ManagementManagementInteroperabiliInteroperabilityty ApplicationsApplicationsLicensingLicensingInfrastructureInfrastructure
Summary
Build More Flexible Web ApplicationsDesign Highly-Manageable ApplicationsDevelop Federation-Aware ApplicationsBuild Connected SystemsBuild For ScalabilityDevelop More Reliable ApplicationsVirtualize
MSDN in the UK
Visit http://msdn.co.uk NewsletterEventsScreencastsBlogs
© 2007 Microsoft Ltd. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the
date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.