For developers
Download
1 / 61

for Developers - PowerPoint PPT Presentation


  • 209 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'for Developers' - wind


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
For developers

for Developers

Daniel Moth

Developer and Platform Group

Microsoft

http://www.danielmoth.com/Blog


Agenda
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






The top 7 ways part 2
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



Native threading enhancements in windows vista and windows server 2008
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
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


One time initialization
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
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
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
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
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
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
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
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
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
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>


Native threading enhancements in windows vista and windows server 20081
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



Windows error reporting winqual
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



Restart api
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
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
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



Restart manager call to action
Restart Manager, Call to Action

  • Installer software

    • call the Restart Manager APIs

  • Applications and Services

    • Restart Manager "aware”


Transactional ntfs
Transactional NTFS

  • Windows Vista and Windows Server 2008

  • Does what it says on the tin

  • System.Transactions.dll + PInvoke


Transactional platform
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


Transactional ntfs txf

System.Tx

Managed

LTM

SQL

DTC

MSMQ

Native

KtmRm

KtmW32

Transactional NTFS (TxF)

WCF

KTM

WS-*

Kernel

NTFS

Registry

CLFS



7 virtualize

7. Virtualize


Hosted virtualization products
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
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


Virtualization benefits
Virtualization Benefits

Utilization

Server consolidation

Business Continuity

Flexibility


Hyper v
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
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
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
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

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


Quick migration planned downtime
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


Quick migration unplanned downtime
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



Terminology
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

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


Hyper v architecture

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


Example vsp vsc design

Applications

User Mode

Disk

StorPort

iSCSIprt

Disk

Partition

Volume

Windows File System

StorPort

Miniport

Windows hypervisor

VM Worker Process

VMBus

Virtual Storage

Miniport (VSC)

Virtual Storage

Provider (VSP)

Fast Path Filter (VSC)

Example VSP/VSC Design

Parent Partition

Child Partitions

Provided by:

Windows

Hyper-V

ISV

OEM

Kernel Mode

Hardware


Monolithic vs microkernelized

VM 2

(“Child”)

VM 3

(“Child”)

VM 1(“Parent”)

Virtual-

ization

Stack

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Drivers

Hypervisor

Hardware

Monolithic vs. Microkernelized

  • Microkernelized hypervisor

    • Simple partitioning functionality

    • Increase reliability and minimize TCB

    • No third-party code

    • Drivers run within guests

  • Monolithic hypervisor

    • Simpler than a modern kernel, but still complex

    • Contains its own drivers model

VM 1

(“Admin”)

VM 3

VM 2

Hypervisor

Hardware

Hyper-V Approach

VMware ESX Approach

MicrokernelizedHypervisor has an inherently secure architecture with minimal attack surface



Hyper v features and abilities
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
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
Interoperablity & 3rd Party OS Support

  • Linux

    • Working with XenSource

      • Developing adapter layer to map Xenhypercall 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
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
Virtualization Investments

Infrastructure

Interoperability

Management

Applications

Licensing

  • Ease consolidationonto virtual infrastructure

  • Better utilizemanagementresources

  • Free up IT spend

  • Create agility

  • Better utilizeserver resources

  • Partner with AMD and Intel

  • Supportheterogeneityacross thedatacenter

  • OSP (Open Specification Promise) VHD and HyperCall

  • Deliver cost-effective, flexible and simplified licensing

  • Acceleratedeployment

  • Reduce the cost of supportingapplications

  • Turn apps into dynamic, real-time services


Summary
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
MSDN in the UK

  • Visit http://msdn.co.uk

    • Newsletter

    • Events

    • Screencasts

    • Blogs