Maximizing COM Application Throughput Steve Swartz Program Manager

  • Slides: 34
Download presentation
Maximizing COM+ Application Throughput Steve Swartz Program Manager COM+ Team Microsoft Corporation 1 -402

Maximizing COM+ Application Throughput Steve Swartz Program Manager COM+ Team Microsoft Corporation 1 -402

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+ Synchronization COM+ Activation

Demo

Demo

Throughput l l l Throughput defined Throughput and infrastructure Throughput and scalability Throughput and

Throughput l l l Throughput defined Throughput and infrastructure Throughput and scalability Throughput and performance Performance vs. scalability

Throughput and Resources l l l l Maximizing throughput means using resources efficiently Minimize

Throughput and Resources l l l l Maximizing throughput means using resources efficiently Minimize create/destroy costs Acquire late/release early Avoid creating too many resources Avoid waiting for resource Avoid requiring particular resources Avoid holding unused resources

Throughput and COM+ l l l COM+ services relevant to throughput: Thread models &

Throughput and COM+ l l l COM+ services relevant to throughput: Thread models & pools Synchronization domains Process pools JIT and Object Pools

Costs to keep in mind l l XProcess vs. XThread calls Regular vs. context

Costs to keep in mind l l XProcess vs. XThread calls Regular vs. context marshalling Activations and calls Cross-machine hops vs. localization

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+ Synchronization COM+ Activation

COM+ Threading Models l l Apartments vs. threads Single threaded apartments Ø Ø Ø

COM+ Threading Models l l Apartments vs. threads Single threaded apartments Ø Ø Ø l l Concurrency & reentrancy Thread-local storage STAs are a bottleneck The multi-threaded apartment The neutral apartment

COM Threads Process MTA Pool RPC Thread Pool (MTA) Main STA

COM Threads Process MTA Pool RPC Thread Pool (MTA) Main STA

COM+ Threads Process MTA Pool RPC Thread Pool (MTA) STA Pool Main STA

COM+ Threads Process MTA Pool RPC Thread Pool (MTA) STA Pool Main STA

STA Pool vs. MTA Pool l STA pooled objects Ø Ø l Contend for

STA Pool vs. MTA Pool l STA pooled objects Ø Ø l Contend for a specific thread Cannot take advantage of new threads MTA pooled objects Ø Ø Contend for all threads Can take advantage of new threads

Example: STA Pool l What you have to change to use the STA Thread

Example: STA Pool l What you have to change to use the STA Thread Pool:

Server App Hints l l l Server App==Out. Of. Proc COM+ App Stick to

Server App Hints l l l Server App==Out. Of. Proc COM+ App Stick to one thread model Concentrate on parent objects Avoid shared child objects Neutral apartment for infrastructure objects

Library App Hints l l Library App==In. Proc COM+ App Behavior of caller matters

Library App Hints l l Library App==In. Proc COM+ App Behavior of caller matters Ø Ø l l l Are your object references shared? Are you called from different kinds of apartments? Specify known caller’s threading model “Both” for single user/unknown caller “Neutral” for many user

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+ Synchronization COM+ Activation

Process Pooling? ? ? l Process pools can help throughput when you’ve got: Ø

Process Pooling? ? ? l Process pools can help throughput when you’ve got: Ø Ø Ø Single-threaded applications Applications that serialize the processing of requests Apps prone to server sized slowdowns or bottlenecks

Example: Process Pooling l What you have to change to use Process Pools:

Example: Process Pooling l What you have to change to use Process Pools:

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+ Synchronization COM+ Activation

STA Synchronization l l Prevents concurrent access Allows reentrancy (to avoid deadlocks) Allows multiple

STA Synchronization l l Prevents concurrent access Allows reentrancy (to avoid deadlocks) Allows multiple copies (in different apartments) A Throughput Bottleneck

COM+ Activities l l Synchronization domains Four levels of configuration Ø Ø l Requires

COM+ Activities l l Synchronization domains Four levels of configuration Ø Ø l Requires New Requires Supports Not supported Cross-apartment, not out-of-proc

COM+ Synchronization l l l Prevents concurrent access Allows reentrancy Allows multiple copies Can

COM+ Synchronization l l l Prevents concurrent access Allows reentrancy Allows multiple copies Can be used in MTA Less of a throughput bottleneck

Example: Synchronization l What you have to change to use COM+ synchronization

Example: Synchronization l What you have to change to use COM+ synchronization

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+

Overview l l l Throughput: What and How COM+ Threading COM+ Process Pooling COM+ Synchronization COM+ Activation

Programming Models l l COM+: Fewer longer-lived clients IIS: Many transient clients Focus on

Programming Models l l COM+: Fewer longer-lived clients IIS: Many transient clients Focus on COM+ model, BUT… … IIS is COM+’s longer-lived client

Optimizing COM+ Activation l l l JIT Object Pooling Recent TPC-C benchmarks

Optimizing COM+ Activation l l l JIT Object Pooling Recent TPC-C benchmarks

JIT l l l On Activation, Proxy/Stub created Object created at first use Object

JIT l l l On Activation, Proxy/Stub created Object created at first use Object controls its own lifetime JIT enables scalable programming model JIT is not useful by itself

Object Pooling l l l Pool of stateful instantiations Request/wait architecture When should I

Object Pooling l l l Pool of stateful instantiations Request/wait architecture When should I pool objects Ø Ø l When create costs are relatively high When use costs are relatively low When an object will be reused often Experiment! Don’t pool objects with clientspecific state

Object & Connection Pools l l l Object Pools are 2 x faster Object

Object & Connection Pools l l l Object Pools are 2 x faster Object Pools are asynchronous Object Pools handle min/max well Object Pools handle more resources Object Pools handle more resource types

JIT and Object Pooling l l l JIT caches COM infrastructure Object pool caches

JIT and Object Pooling l l l JIT caches COM infrastructure Object pool caches state, objects Together, they Ø Ø Ø Minimize overhead of starting work Minimize size of resource caches Maximize throughput

Example: JIT and Object Pooling l What you have to change to use JIT

Example: JIT and Object Pooling l What you have to change to use JIT and Object Pooling: Ø Ø Ø Client does not call Release() Server must call Set. Complete() Server must implement IObject. Control Server must be thread-neutral Server must enlist itself

Example: JIT and Object Pooling ISAPI Queued Pool of MTA Threads JITted Objects in

Example: JIT and Object Pooling ISAPI Queued Pool of MTA Threads JITted Objects in Object Pool SQL Server