for developers n.
Skip this Video
Loading SlideShow in 5 Seconds..
for Developers PowerPoint Presentation
Download Presentation
for Developers

for Developers

96 Views Download Presentation
Download Presentation

for Developers

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. for Developers Daniel Moth Developer and Platform Group Microsoft

  2. AGENDA • Top 7 Ways To “Light Up” Your Apps on Windows Server 2008 • Part 1 emphasis on • IIS7, PowerShell • Part 2 emphasis on • WER, Restart and Recovery APIs, TxF

  3. 1. Build More Flexible Web Apps

  4. 2. Design Highly-Manageable Apps

  5. 3. Develop Federation-Aware Apps

  6. 4. Build Connected Systems

  7. The Top 7 Ways… Part 2 • Build More Flexible Web Applications • Design Highly-Manageable Applications • Develop Federation-Aware Applications • Build Connected Systems • Build For Scalability • Develop More Reliable Applications • Virtualize

  8. 5. Build For Scalability

  9. 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

  10. Thread Pool in Vista and Server 2008 • Re-architected Thread Pool • Simpler, more reliable, higher performance • Does not use a timer thread • Single queue • Dedicated persistent thread • Clean-up groups • Single worker thread type (both I/O and non-I/O) • Multiple pools per process • More flexible API

  11. One-Time Initialization • Interlocked functions ensure that only one thread performs the initialization • One-time initialization is better • Optimized for speed • Appropriate barriers are created on processor architectures that require them • Support for both locked and parallel initialization • No internal locking so the code can operate asynchronously or synchronously

  12. One Time Init Steps • BOOL 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 );

  13. Slim Reader/Writer Lock • SRW locks – new synchronization primitive • enable threads to access shared resources • optimized for speed • take very little memory • built on top of windows kernel keyed events • Two modes • Shared mode • grants shared read-only access to multiple reader threads • Exclusive mode • grants read/write access to one writer thread at a time

  14. 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 );

  15. Condition Variables • Used to synchronize a group of threads based on the result of some conditional test • Enable threads to atomically release a lock and enter the sleeping state • Benefits • Much clearer and less error-prone • Can be more efficient • Tries to avoid trips to kernel mode (unlike WaitForSingleObject)

  16. Condition Variable APIs • VOID 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 );

  17. Thread Ordering Service (TOS) • TOS controls the execution of client threads • Ensures that they run once and in order • 5 APIs – AvRtXxxxThreadOrderingGroup • parent thread calls Create to set up the TOS • client threads call Join to join the TOS • all of them call Wait, run their code and Wait • ...client threads call Leave when they are done • parent thread calls Delete to end it all

  18. TOS APIs - avrt.h BOOL 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 );

  19. 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 following • ALPC, COM, Critical sections, Mutexes, SendMessage

  20. 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 ); • typedefstruct _WAITCHAIN_NODE_INFO { <SNIP>

  21. 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

  22. 6. Develop More Reliable Apps

  23. Windows Error Reporting & winqual • New User Experience • In addition to crashes, hangs are also detected • Privacy evaluation, Queuing and transport • Problem Reports and Solutions • Response management • New Public APIs • Adding additional file and memory data to a report (inc. minidump & heap information) • Create reports for custom events

  24. WER, Restart, Recovery

  25. Restart API • Register to be restarted after fatal problems • Registration also used for Restart Manager • Restarts process after patch installation • All applications should support restart • Especially if support document recovery • How it works • Register 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

  26. Recovery APIs • Attempt to recover data after a fatal event • Users should not lose any work to an app bug • How it works • 1. 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

  27. Restart Manager Overview With the Restart Manager technology installers can Automatically shutdown only the applications and services holding a file to be updated When available, leverage specific application functionality to restore the user to the state they were in before the restart When a reboot cannot be avoided, automatically re-launch apps after reboot

  28. Restart Manager

  29. Restart Manager, Call to Action • Installer software • call the Restart Manager APIs • Applications and Services • Restart Manager "aware”

  30. Transactional NTFS • Windows Vista and Windows Server 2008 • Does what it says on the tin • System.Transactions.dll + PInvoke

  31. Transactional Platform • Kernel Transaction Manager (KTM) • Makes transactions available as kernel objects • Provides transaction management services to system components such as TxF • Can 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

  32. System.Tx Managed LTM SQL DTC MSMQ Native KtmRm KtmW32 Transactional NTFS (TxF) WCF KTM WS-* Kernel NTFS Registry CLFS

  33. TxF

  34. 7. Virtualize

  35. Hosted Virtualization Products • Microsoft Virtual PC 2007 • Over 3.5 million downloads • Support for Windows Vista as a host and guest • 64-bit host support • Improved performance • Support for Intel VT and AMD-V • Microsoft Virtual Server 2005 R2 SP1 • Support for Intel VT and AMD-V • Support for SLES 10 • VSS integration for live backup of running virtual machines • VHD mounting tool for offline servicing • Improved performance • Improved scalability: 512 VMs on x64 systems

  36. Microsoft Virtualization Products A comprehensive set of virtualization products, from the data center to the desktop Assets – both virtual and physical – are managed from a single platform Server Virtualization Hyper-VServer Presentation Virtualization Management Application Virtualization Desktop Virtualization Centralized Desktop

  37. Virtualization Benefits Utilization Server consolidation Business Continuity Flexibility

  38. Hyper-V Codename "Viridian", Windows Server Virtualization • Flexible and dynamic virtualization solution • A role of Windows Server 2008 (Std, EE, DC) • Can be a full role with local UI or Server Core role • Hypervisor based architecture • Managed by Microsoft System Center • Also provided as a standalone server • Microsoft Hyper-V Server ($28)

  39. Windows Server Core role • Server Core • Minimal Installation option in all x86/x64 editions • Command line interface only, no GUI shell • Provides essential server functionality • Deployed for a single role • No need to deploy and service the whole OS • Benefits • Less code results in fewer patches and servicing burden • Low surface area targeted for server roles • More secure and reliable with less management

  40. Virtualization and High Availability • Traditional Non-Virtualized Environment • Downtime is bad, but affects only one workload • Virtualized Environment • Value of the physical server goes up • Downtime is far worse because multiple workloads are affected Virtualization and High-Availability Go Hand in Hand

  41. Microsoft Hyper-V High Availability • Planned downtime • More common than unplanned • Quickly move virtualized workloads in order to service underlying hardware • Unplanned downtime • Not as common and more difficult • Automatic failover to other nodes • hardware or power failure

  42. Save state Save entire virtual machine state Move virtual machine Move storage connectivity from origin to destination host Restore state and Run Restore virtual machine and run Quick Migration FundamentalsPlanned Downtime VHDs Shared Storage Network Connectivity

  43. Quick Migration – Planned Downtime Virtualization Servers (3 + 1 Servers) • Active server requires servicing • Move virtualized workloads to a standby server • ~4 seconds downtime per virtual machine Domain Controller System Center Virtual Machine Manager Windows Server 2008 Failover Cluster Manager Ethernet Storage Connectivity VHDs on SAN

  44. Quick Migration – Unplanned Downtime Virtualization Servers (3 + 1 Servers) • Active server loses power • Virtual machines automaticallyrestart on the next cluster node • If there is not enough memory, the failover automaticallymoves to the next node until done Domain Controller System Center Virtual Machine Manager Windows Server 2008 Failover Cluster Manager Ethernet Storage Connectivity VHDs on SAN

  45. Quick Migration – How Quick Is It?

  46. Terminology • Hypervisor • A piece of software that provides the ability to run multiple operating systems on one piece of hardware • Ensures that the CPU and hardware answer the *correct* OS • Microkernelized or Monolithic • Hyper-V • A role you can install in Windows that includes the Hypervisor as well as management software • Partition • An “operating system” to the hypervisor • Virtual Machine • A “child” partition

  47. Windows Hypervisor Powerful virtualization built into the Windows platform VM 2“Child” VM 2“Child” VM 1“Parent” Hyper-V Overview Management tools VirtualizationPlatform andManagement

  48. Virtualization Stack Provided by: Windows VM WorkerProcesses Hyper-V WMI Provider VMService ISV OEM WindowsKernel WindowsKernel VirtualizationServiceProviders(VSPs) Server Core IHVDrivers Windows hypervisor VirtualizationServiceClients(VSCs) Enlightenments VMBus Hyper-V Architecture Parent Partition Child Partitions Applications User Mode Kernel Mode “Designed for Windows” Server Hardware