for Developers Daniel Moth Developer and Platform Group Microsoft http://www.danielmoth.com/Blog AGENDA Top 7 Ways To “Light Up” Your Apps on Windows Server 2008 Part 1 emphasis on IIS7,

Download Report

Transcript for Developers Daniel Moth Developer and Platform Group Microsoft http://www.danielmoth.com/Blog AGENDA Top 7 Ways To “Light Up” Your Apps on Windows Server 2008 Part 1 emphasis on IIS7,

for Developers
Daniel Moth
Developer and Platform Group
Microsoft
http://www.danielmoth.com/Blog
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
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.
2.
3.
4.
5.
6.
7.
Build More Flexible Web Applications
Design Highly-Manageable Applications
Develop Federation-Aware Applications
Build Connected Systems
Build For Scalability
Develop More Reliable Applications
Virtualize
5. Build For Scalability
Native Threading Enhancements
in 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 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
Feature
Original API
Synch
RegisterWaitForSingleObject
UnregisterWaitEx
Work
QueueUserWorkItem
Timer
CreateTimerQueue
CreateTimerQueueTimer
ChangeTimerQueueTimer
DeleteTimerQueueTimer
DeleteTimerQueueEx
I/O
BindIoCompletionCallback
Clean-up group
Pool
Current API
CloseThreadpoolWait
CreateThreadpoolWait
SetThreadpoolWait
WaitForThreadpoolWaitCallbacks
CloseThreadpoolWork
CreateThreadpoolWork
SubmitThreadpoolWork
TrySubmitThreadpoolCallback
WaitForThreadpoolWorkCallbacks
CloseThreadpoolTimer
CreateThreadpoolTimer
IsThreadpoolTimerSet
SetThreadpoolTimer
WaitForThreadpoolTimerCallbacks
CancelThreadpoolIo
CloseThreadpoolIo
CreateThreadpoolIo
StartThreadpoolIo
WaitForThreadpoolIoCallbacks
CloseThreadpoolCleanupGroup
CloseThreadpoolCleanupGroupMembers
CreateThreadpoolCleanupGroup
CloseThreadpool
CreateThreadpool
SetThreadpoolThreadMaximum
SetThreadpoolThreadMinimum
Callback environment
DestroyThreadpoolEnvironment
InitializeThreadpoolEnvironment
SetThreadpoolCallbackCleanupGroup
SetThreadpoolCallbackLibrary
SetThreadpoolCallbackPool
SetThreadpoolCallbackRunsLong
Callback
CallbackMayRunLong
Callback clean up
DisassociateCurrentThreadFromCallback
FreeLibraryWhenCallbackReturns
LeaveCriticalSectionWhenCallbackReturns
ReleaseMutexWhenCallbackReturns
ReleaseSemaphoreWhenCallbackReturns
SetEventWhenCallbackReturns
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
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 );
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
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 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)
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 );
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
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 );
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
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 Enhancements
in 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 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
WER, Restart, Recovery
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
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
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
Windows Installer (MSI)
Key Microsoft Office 2007 Applications
• Fewer reboots when using the Windows
Add/Remove Programs feature
• Automatically restart after a reboot due
to an installation or update
• Developers can reduce reboots for
installations and updates by using the
Windows Installer v4.0
• Recreate application state upon restart
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 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
Kernel
Native
Managed
Transactional NTFS (TxF)
LTM
System.Tx
SQL
DTC
KtmRm
KtmW32
WCF
KTM
NTFS
Registry
CLFS
MSMQ
WS-*
TxF
7. Virtualize
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
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-V Server
Presentation
Virtualization
Management
Desktop
Virtualization
Centralized Desktop
Application
Virtualization
Virtualization Benefits
Server consolidation
Business Continuity
Utilization
Flexibility
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)
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
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
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
Quick Migration Fundamentals
Planned Downtime
Save state
Save entire virtual
machine state
VHDs
Shared Storage
Move virtual machine
Move storage
connectivity from origin
to destination host
Restore state and Run
Restore virtual machine
and run
Network Connectivity
Quick Migration – Planned Downtime
Virtualization Servers
(3 + 1 Servers)
Domain
Controller
• Active server requires
servicing
• Move virtualized workloads
to a standby server
• ~4 seconds downtime per
virtual machine
Windows Server 2008
Failover Cluster Manager
Ethernet
System Center
Virtual Machine Manager
Storage
Connectivity
VHDs on
SAN
Quick Migration – Unplanned Downtime
Virtualization Servers
(3 + 1 Servers)
Domain
Controller
Windows Server 2008
Failover Cluster Manager
Ethernet
System Center
Virtual Machine Manager
• Active server loses power
• Virtual machines
automatically restart on the
next cluster node
• If there is not enough
memory, the failover
automatically moves to the
next node until done
Storage
Connectivity
VHDs on
SAN
Quick Migration – How Quick Is It?
Disc /
VM Memory
1 GbE iSCSI
2 Gb FC
4 Gb FC
512 MB
~8 seconds
~ 4 seconds
~2 seconds
1 GB
~16 seconds
~8 second
2 GB
~32 seconds
~16 seconds
4 GB
~64 seconds
~32 seconds
8 GB
~2 minutes
~64 seconds
~ 4 seconds
~8 seconds
~16 seconds
~32 seconds
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
Hyper-V Overview
Management tools
Virtualization
Platform and
Management
Windows Hypervisor
Powerful virtualization built into
the Windows platform
VM 1
“Parent”
VM 2
“Child”
VM 2
“Child”
Hyper-V Architecture
Parent Partition
Child Partitions
Virtualization Stack
WMI Provider
VM
Service
Server Core
Windows
Kernel
Provided by:
Windows
Applications
VM Worker
Processes
ISV
User Mode
Virtualization
Service
Providers
IHV
(VSPs)
Drivers
Hyper-V
Virtualization
Service
Clients
(VSCs)
VMBus
Windows
Kernel
Enlightenments
Kernel Mode
Windows hypervisor
“Designed for Windows” Server Hardware
OEM
Example VSP/VSC Design
Parent Partition
Child Partitions
Applications
VM Worker Process
Provided by:
Windows
User Mode
Hyper-V
Windows File System
ISV
Volume
OEM
Partition
Virtual Storage
Provider (VSP)
Disk
Disk
Fast Path Filter (VSC)
StorPort
Virtual Storage
Miniport (VSC)
StorPort
Miniport
VMBus
Windows hypervisor
Hardware
iSCSIprt
Kernel Mode
Monolithic vs. Microkernelized
Monolithic hypervisor
Microkernelized hypervisor
Simpler than a modern kernel,
but still complex
Contains its own drivers model
VM 1
(“Admin”)
VM 2
VM 3
Hypervisor
Simple partitioning functionality
Increase reliability and minimize TCB
No third-party code
Drivers run within guests
VM 1
(“Parent”)
Virtualization
Stack
Drivers
Drivers
Drivers
VM 2
(“Child”)
VM 3
(“Child”)
Drivers
Drivers
Drivers
Drivers
Drivers
Drivers
Drivers
Drivers
Drivers
Hypervisor
Hardware
VMware ESX Approach
Hardware
Hyper-V Approach
Microkernelized Hypervisor has an inherently secure architecture with minimal attack surface
Virtual Server 2005 vs. Hyper-V
Virtual Server 2005 R2 SP1
Hyper-V
32-bit Virtual Machines
Yes
Yes
64-bit Virtual Machines
No
Yes
Multi Processor Virtual Machines
No
Yes, up to 4 core VMs
Virtual Machine Memory Support
3.6GB per VM
32GB per VM
256 GB
1 TB
Managed by System Center Virtual
Machine Manager
Yes
Yes
Support for Microsoft Clustering
Services
Yes
Yes
Host side backup support (VSS)
Yes
Yes
COM
WMI + HyperCall API
Web Interface
MMC 3.0 Interface
Physical Memory Support
Scriptable / Extensible
User Interface
Hyper-V Features and Abilities
Performance
Hypervisor
Synthetic Drivers
Server Core
Flexibility
Multi-architecture
Multi-OS VM’s
Manageability
Managed through WMI (PowerShell)
SCVMM
Windows
Interoperability & Standards
VHD (Virtual Hard Disk)
VHD specification is freely available under Open
Specification Promise (OSP)
VHD TestDrive program for ISVs
Standards based management APIs
DMTF defining industry standard model for VM
management
Hyper-V uses this model
Hypervisor hypercall API
Preliminary documentation available under OSP
Final version will be at RTM
Interoperablity & 3rd Party OS Support
Linux
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
Solaris
Working with Sun to support Solaris on Hyper-V
Industry Leadership In Licensing
Instance Based Licensing
Will enable new usage models
Windows Server Enterprise/Datacenter
Includes 4/Unlimited virtual instances
Licensing per Virtual Processor
SQL Server, BizTalk Server, etc.
Windows Vista (Software Assurance Customer
Benefit)
Allows Vista Enterprise Centralized Desktop deployments
Demo Distribution of Virtual Images
Virtualization Investments
Infrastructure Interoperability
Create agility
Better utilize
server
resources
Partner with
AMD and
Intel
Support
heterogeneity
across the
datacenter
OSP (Open
Specification
Promise)
VHD and
HyperCall
Management
Ease
consolidation
onto virtual
infrastructure
Better utilize
management
resources
Free up IT
spend
Licensing
Applications
Deliver
costeffective,
flexible and
simplified
licensing
Accelerate
deployment
Reduce the
cost of
supporting
applications
Turn apps
into dynamic,
real-time
services
Summary
Build More Flexible Web Applications
Design Highly-Manageable Applications
Develop Federation-Aware Applications
Build Connected Systems
Build For Scalability
Develop More Reliable Applications
Virtualize
MSDN in the UK
Visit http://msdn.co.uk
Newsletter
Events
Screencasts
Blogs
© 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.