advanced distributed software architectures and technology group adsat 1 microsoft middleware...

46
1 Advanced Distributed Software Architectures and Technology group ADSaT Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

Upload: allan-choate

Post on 31-Mar-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

1Advanced Distributed Software Architectures and Technology group

ADSaT

Microsoft Middleware Technology

Paul GreenfieldADSaTCSIRO

Page 2: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

2Advanced Distributed Software Architectures and Technology group

ADSaT

COM, MTS & COM+

• An evolving component technology– Components not objects– Designed for practical code re-use– COM for local components– DCOM for remote components– MTS for transactional components– COM+ integrating and extending MTS– ActiveX and OLE for adding confusion

Page 3: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

3Advanced Distributed Software Architectures and Technology group

ADSaT

COM

• Just one Component Object Model• Language-neutral, binary model

– Use any language to write components• VB, C++, Java, Delphi, C, Perl, …

– Call from any language, inc. scripts• Components are …

– Reusable software building blocks– Defined, contracted, stable behaviour

Page 4: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

4Advanced Distributed Software Architectures and Technology group

ADSaT

COM Interfaces• Components implement interfaces

– Interfaces define behaviour– Components have multiple interfaces– Clients only access interfaces

• Not objects and no access to internals

– Interfaces are immutable• Should be defined once and never changed• Give stability in distributed systems

– Polymorphism through interfaces• No class inheritance in COM itself

Page 5: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

5Advanced Distributed Software Architectures and Technology group

ADSaT

Component Example

• Kangaroo component class• Supports Hopping and Eating

behaviour

CKangaroo

IHop

IEat

IUnknown Dim BigHopper as IHopDim BigEater as IEatSet BigHopper = new CKangarooSet BigEater = BigRedBigHopper.Hop “over log”

BigEater.Graze “grass”

Page 6: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

6Advanced Distributed Software Architectures and Technology group

ADSaT

COM Run-time

• COM objects can be in …– A library (DLL) ‘in-process server’ – A separate program ‘out-of-process’

• Objects accessed through stubs and proxies

Client process

Out-of-process server In-process server

Page 7: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

7Advanced Distributed Software Architectures and Technology group

ADSaT

Distributed COM• Took COM into distributed computing

– Exactly the same programming model– Components can be remote

Client process

Out-of-process server In-process server

Remote server

Page 8: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

8Advanced Distributed Software Architectures and Technology group

ADSaT

COM/DCOM Practicalities• How does a client find a server?

– Through the registry on the client• Registry set up when client app installed

– No ‘name server’ … until COM+

• Are there really libraries of COM components that can be re-used?– Office, Visio, SAP, ActiveX controls, …

• Much additional flexibility– And subsequent (seeming)

complexity…

Page 9: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

9Advanced Distributed Software Architectures and Technology group

ADSaT

Building COM Code

• Good tool support – MS C++ with MFC/ATL, VB, J++,

Delphi, …– Templates, wizards and run-times– Compilers know about components

and their interfaces

Page 10: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

10Advanced Distributed Software Architectures and Technology group

ADSaT

Moving from the Desktop

• Addressing the enterprise market– Challenging mainframes and UNIX– Addressing questions of availability,

scalability, integrity, security– Keep ease of programming and admin

• Build enterprise apps in VB?• Avoid need for complex tuning and admin

• Response was MTS – Brought transactions to COM

Page 11: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

11Advanced Distributed Software Architectures and Technology group

ADSaT

MS Application Model

• Windows DNA– Three tier architecture– Client layer

• Web based using scripting (ASP)• Traditional client applications

– Business logic layer• Transactional business components

– Data access layer• Components enforce data integrity

Page 12: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

12Advanced Distributed Software Architectures and Technology group

ADSaT

Application LayersOrder

component

Customer component

Payment component

Order component

Goods component

Stock component

Delivery component

MTS

DCOM/COM

Web server Scripted

Web pages

Business Logic Layer

Data Access Layer

Client Access Layer

User interface

app

Print invoicesPrint ship requests

Background processes

Page 13: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

13Advanced Distributed Software Architectures and Technology group

ADSaT

MTS and Transactions

• MTS added transactions to COM– Simple programming model

• Write code as if it was all that was running on the system

• COM/MTS will ensure isolation• Minimal coding changes needed

– add commit/abort

– Full ACID properties• Using XA-compliant databases etc• Full support for distributed transactions

Page 14: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

14Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Programming• Encourages stateless programming

– Methods are complete business transactions

– Transaction starts when method called and ends when it returns

– No state left on server after method returns, except in databases…

• Other models possible– Client controlled transactions – Stateful objects

Page 15: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

15Advanced Distributed Software Architectures and Technology group

ADSaT

MTS and Server Objects

• MTS deletes server objects when transaction commits – Client still thinks it has a server object– Server object created anew if needed

• ‘Just-in-time activation’ • Makes it impossible to keep state in

server objects and so violate ACID properties

– Reduces resource usage on server– Server objects recycled in COM+

Page 16: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

16Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Architecture• Application ‘packages’

– Collection of libraries (DLLs)– Each package has its own server

process• Multiple threads within each process• Failing application code isolated• Can also run application code ‘in-line’

– Method calls run on threads• No tuning parameters• Low overhead• No binding from client to thread

Page 17: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

17Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Architecture

MTS Process

Application Packages

Clients

Page 18: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

18Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Administration

Page 19: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

19Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Security

• COM security based on NT security– ACLs on components, interfaces, …– Based on users and groups

• MTS has role-based security– Rights assigned to ‘roles’

• ‘manager’, ‘clerk’, ‘teller’, …• Access to interfaces, packages, …• Separates security policy from admin

– Roles assigned to users and groups

Page 20: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

20Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Performance

• Stateless transactional applications – Minimal server resources used

• Database connection pooling– ODBC and OLE DB

• Method calls run on any thread– Minimal waiting unlike some OTMs– No tuning or rebinding needed

Page 21: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

21Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Performance

• Stock on-line application– Both application and SQL/Server

database running on Dell 2x 400MHz Pentium II with 512MB

– Application coded in … • C++ (ODBC), Visual Basic (ADO), J++ (ADO)

– Two versions• Using Keytable (heavy database locking)• Using Identity (avoids contention on Keytable)

Page 22: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

22Advanced Distributed Software Architectures and Technology group

ADSaT

C++ Sample

STDMETHODIMP CStocks::UpdateAccount(long subAccNo, long sCredit)

{ HRESULT hr = S_OK; SubscriberAccount sub ;

hr = sub.Update(subAccNo, sCredit) ;

if (m_spObjectContext) if FAILED(hr)

m_spObjectContext->SetAbort();else m_spObjectContext->SetComplete();

return hr;}

Page 23: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

23Advanced Distributed Software Architectures and Technology group

ADSaT

C++ SampleHRESULT SubscriberAccount::Update(long pAccNo, long pCredit) { HRESULT hr; SQLHENV henv = NULL; SQLHDBC hdbc = NULL; SQLHSTMT hstmt= NULL;

hr = GetSQLHandles(henv, hdbc, hstmt); if (FAILED(hr)) return hr; // ODBC handle allocations failed

RETCODE retCode; SDWORD cbNumLen = 0, cbNTS = SQL_NTS ; SQLCHAR stmt [MAX_STMT_LEN] ;

sprintf ((CHAR *) stmt, "UPDATE SUBACCOUNT SET SUB_CREDIT = %ld WHERE SUB_ACCNO = %ld", pCredit, pAccNo ); retCode = SQLExecDirect ( hstmt, stmt, SQL_NTS ) ; if (retCode != SQL_SUCCESS && retCode != SQL_SUCCESS_WITH_INFO) return error("SubAccount Update", henv, hdbc, hstmt);

ReleaseSQLHandles(henv, hdbc, hstmt); return S_OK;}

Page 24: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

24Advanced Distributed Software Architectures and Technology group

ADSaT

VB SamplePublic Sub update(pAccNo As Long, pCredit As Long) On Error GoTo ErrorHandler Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command conn.Open DSNString Set cmd.ActiveConnection = conn cmd.CommandText = "update SubAccount set sub_credit=" &

_ pCredit & " where sub_accno=" & pAccNo cmd.Execute conn.Close Set conn = Nothing GetObjectContext.SetComplete Exit Sub ErrorHandler: . . . . . . . . Err.Raise Err.Number, , Err.Description GetObjectContext.SetAbort

End Sub

Page 25: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

25Advanced Distributed Software Architectures and Technology group

ADSaT

MTS PerformanceMTS Stock Throughput

0

50

100

150

200

250

300

0 100 200 300 400 500 600

Client threads

TP

S

C++ Keytable

C++ Identity

VB Keytable

VB Identity

Page 26: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

26Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Performance• How many clients can be supported?

– 2 second average response time– No wait time between requests– Application and database on same box

VB Keytable 200 clients

VB Identity 300 clients

C++ Keytable 350 clients

C++ Identity 500 clients

Page 27: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

27Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Response TimesMTS Local Response Times

0

500

1000

1500

2000

2500

3000

3500

4000

4500

1 5 10 20 50 100 200 400 600 800 1000

Client threads

Res

po

nse

tim

e (m

s)

Buy

Create Account

Get Holding

QueryID

QueryCode

Sell

Update

Page 28: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

28Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Performance

• Performance limited by processor• Run with remote database

– Doubles available processor power– Needs 100M LAN

• Results for C++ and Identity– 800 clients with 2 sec response time– 430tps

Page 29: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

29Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Performance MTS Remote Response Time

0

500

1000

1500

2000

2500

3000

3500

4000

4500

1 5 10 20 50 100 200 400 600 800 1000

Client threads

Res

po

nse

tim

e (m

s)

Buy

Create Account

Get Holding

QueryID

QueryCode

Sell

Update

Page 30: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

30Advanced Distributed Software Architectures and Technology group

ADSaT

MTS Scalability• Good up to the capacity of the box

– $20,000 of hardware will support 800 concurrent clients – thousands of users

• But what if we want to support tens of thousands of very active users?– Bigger boxes – scale up

• Commodity 8x servers, Itanium, GHz chips• Proprietary SMP boxes – Unisys, Sequent,..

– More boxes – scale out• Share workload over many servers

Page 31: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

31Advanced Distributed Software Architectures and Technology group

ADSaT

Scale Out

• Stateless, transactional applications– No binding between clients and servers– Transactions can go to any server

• Need load balancing support to share workload over available servers– Web server-based– Write-your-own– COM+ load balancing coming soon

• Moved to Windows 2000 Application Server

Page 32: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

32Advanced Distributed Software Architectures and Technology group

ADSaT

Integration

• Integrating with non-COM/MTS code– COMTI for full integration with CICS

servers – Support for CICS clients expected– Bridges between COM, CORBA, EJB,

Page 33: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

33Advanced Distributed Software Architectures and Technology group

ADSaT

Sample System

Customercomponent

Paymentcomponent

Ordercomponent

Goodscomponent

Stockcomponent

Deliverycomponent

DCOM/COM

MTS

Databaseserver

Applicationserver

Warehousemanager

Printinvoices

Webserver

Webserver

Local clientworkstations

Internet/Intranet

Remote warehousesScripted

Webpages

Central Office

Userclientapps

Remote sales offices

Router

Remote sites

HTTP

ORPC

ORPC/MQ

Userclientapps

CICSinterface

Externalcompany

accountingsystem

Page 34: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

34Advanced Distributed Software Architectures and Technology group

ADSaT

COM+

• The Windows 2000 version of COM– Features of MTS folded back into

mainstream COM and extended– COM GUI administration tool– Asynchronous method calls– Load balancing– Publish-subscribe events– Compensating resource manager– Object pooling– Performance improvements

Page 35: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

35Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Administration

Page 36: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

36Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Features

• Asynchronous methods– Client can call method and continue– Method call turned in queued message– Uses MSMQ (Microsoft Message Queue)

• Compensating Resource Managers– Allow use of non-transactional

resources within a transaction– Write code to back out changes

• Called if transaction aborts

Page 37: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

37Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Features

• Publish/Subscribe– Event-based programming model– Publish events and subscribers notified

• Use of Windows 2000 features– Reduced use of registry– Use of Active directory to find servers– Use of standard Windows Installer

Page 38: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

38Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Load Balancing

• Scale-out by spreading workload over multiple computer systems– Router knows what servers are

available and how busy they are– Client calls router to find a server– Client gets component reference

and calls methods as normal– Router only involved at component

creation time• no overhead on calls

Page 39: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

39Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Component Load Balancing

Client

Client

Client

Response time tracker

RouterCreate object

Call object’s methods

Pass request to server

Create object and pass back reference

COM + CLB balancing load across multiple systems

Page 40: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

40Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Performance

• Object Pooling– Server-side objects are pooled and

recycled on activation• Lowers cost of object creation/activation

• Dynamic thread pool – Adjusts no. of server threads with load

• Faster but still evaluating how much– Good improvements so far– Tests hitting limits on database server

• Expect improvements with Win2K db server

Page 41: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

41Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ PerformanceMTS and COM+ Throughput

0

50

100

150

200

250

300

350

400

450

500

0 200 400 600 800 1000 1200

Client threads

MTS localMTS remoteCOM+ localCOM+ remoteCOM+ cp localCOM+ cp remote

Page 42: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

42Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Performance

Calculated response times

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 200 400 600 800 1000 1200

Client threads

Resp

on

se t

ime (

ms)

MTS local

MTS remote

COM+ local

COM+ remote

COM+ cp local

COM+ cp remote

Page 43: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

43Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Performance

Page 44: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

44Advanced Distributed Software Architectures and Technology group

ADSaT

COM+ Performance

• Ported application MTS -> COM+– Reduced application processor

usage– 300tps, 600 users with local db– 400tps, 800 users with remote db

• Object pooling– Pool objects rather than connections– 400tps, 800 users with local db– 450tps, 900 users with remote db

Page 45: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

45Advanced Distributed Software Architectures and Technology group

ADSaT

TPCC Performance?

• TPCC figures for Windows 2000, COM+ and SQL/Server 2000– Top 2 places on TPCC performance list

• 227,000 TPMC – 96 processors - $19/tpmc• 152,000 TPMC – 64 processors - $19/tpmc• ‘shared nothing’ partitioned database

– Then UNIX boxes• About 135,000 TPMC at $50 - $100+

/tpmc

Page 46: Advanced Distributed Software Architectures and Technology group ADSaT 1 Microsoft Middleware Technology Paul Greenfield ADSaT CSIRO

46Advanced Distributed Software Architectures and Technology group

ADSaT

MTS and COM+

• Microsoft’s transactional middleware – Good tool integration for ease of use

• C++, VB, Java – coding, debugging

– Performance good and getting better– Very scalable for the right applications

• Scale-up limited compared to UNIX?• Scale-out requires right architectures

– Good value for money…• Comes as part of NT and Windows 2000