Top Banner
1 Advanced Distributed Software Architectures and Technology group ADSaT Application Architectures Ian Gorton, Paul Greenfield
41

Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

1Advanced Distributed Software Architectures and Technology group

ADSaT

Application Architectures

Ian Gorton, Paul Greenfield

Page 2: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

2Advanced Distributed Software Architectures and Technology group

ADSaT

Aim

• Cover some typical N-tier application architectures

• Look at their strengths and weaknesses

• Look at a sample complex application

Page 3: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

3Advanced Distributed Software Architectures and Technology group

ADSaT

N-Tier Applications

• Layered Architectures– Client layer taking care of user

interfaces – Some number of business logic

layers implementing business processes and rules

– Data layer for accessing data and implementing data integrity rules

Page 4: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

4Advanced Distributed Software Architectures and Technology group

ADSaT

N-tier Architectures

• Client layer– Static Web pages– Web-based through CGI programs– Active client-side Web pages

• Scripting and applets

– Active server-side Web pages– Traditional client applications– Background/batch processes

Page 5: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

5Advanced Distributed Software Architectures and Technology group

ADSaT

N-tier Architectures

• Business logic– Multiple layers possible

• Web scripts, server components

– Distribute and replicate as necessary– Re-use of logic a primary goal

• Data access– Components enforce data integrity– Isolate business logic from database– Can be partitioned and replicated

Page 6: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

6Advanced Distributed Software Architectures and Technology group

ADSaT

N-tier Example

Order component

Customer component

Payment component

Order component

Goods component

Stock component

Delivery component

MTS*

DCOM/COM*

Web server Scripted

Web pages

User interface

app

Print invoicesPrint ship requests

Background processes

* Or other transactional ORB of your choice

Business Logic Layer

Data Access Layer

Client Access Layer

Page 7: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

7Advanced Distributed Software Architectures and Technology group

ADSaT

Pooling

• Keep a shared pool of expensive or scarce resources– Database connections (ODBC, …)– Objects (COM+, EJB, …)

• Allocate from pool only when needed

• Release as soon as not needed• Makes stateless transactional

object designs really feasible

Page 8: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

8Advanced Distributed Software Architectures and Technology group

ADSaT

DB Connection Pooling

• Database connections are…– Expensive to allocate (performance)– Limited in number (scalability)

OLE DB ODBC OLE DB ODBCpooled pooled no pooling no pooling

VB 3.98 4.72 7.24 12.20J++ 4.83 4.83 7.27 12.37C++ 3.80 4.62 6.16 11.91

Page 9: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

9Advanced Distributed Software Architectures and Technology group

ADSaT

Object Pooling

• Client keeps reference to object • Allocate new object on every

method call– Stateless, transactional objects

• Discard objects at commit time• Objects recycled to reduce costs

– May only help with expensive objects

Page 10: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

10Advanced Distributed Software Architectures and Technology group

ADSaT

Object Pooling

0

200

400

600

800

1000

1200

1400

0 50 100 150threads

tps

128 Pooled ComponentsStateful (COM+)Stateless

Page 11: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

11Advanced Distributed Software Architectures and Technology group

ADSaT

Architectural Patterns

• Common models for building systems– Stateless or stateful?– Synchronous or asynchronous?– Data layer access

• Complexity and correctness– Recovery after failure– Scalability and parallelism– Simple, working and obviously

correct is a good goal

Page 12: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

12Advanced Distributed Software Architectures and Technology group

ADSaT

Stateful Session

Server object

Server object

Server object

Clients

Server objectFactory

New Client

Page 13: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

13Advanced Distributed Software Architectures and Technology group

ADSaT

Characteristics• One server object dedicated for

each client• Server object can hold client-

specific information (state) • New clients request a Factory

object to create them a server object. Can be distributed.

• Transactions can span multiple calls

Page 14: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

14Advanced Distributed Software Architectures and Technology group

ADSaT

Issues• How long do server objects live?

• Life of client?• Forever? reusable

• What happens if a server object/node dies unexpectedly?

• How do clients find a factory?• How does load balancing work if

load becomes uneven?

Page 15: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

15Advanced Distributed Software Architectures and Technology group

ADSaT

Stateless Session

Server object pool

Clients

Page 16: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

16Advanced Distributed Software Architectures and Technology group

ADSaT

Characteristics• Any client can use any server• Server object pool can be

distributed• Server objects maintain no state

on behalf of client, and pool DB connections

• Each client-server interaction is a single transaction

Page 17: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

17Advanced Distributed Software Architectures and Technology group

ADSaT

Design Issues

• How big is server object pool?• Static• Dynamic

• How do clients decide which server object to connect to?

• Finding servers?• Length of time they use a server

• Closely related to load balancing...

Page 18: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

18Advanced Distributed Software Architectures and Technology group

ADSaT

Stateful v Stateless

• Stateless scales better in practice– Stateful may be faster

• Stateless is easier to build• Stateful can be very useful in some

applications:– greatly benefit from data caching– load balancing is not too much of an

issue

Page 19: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

19Advanced Distributed Software Architectures and Technology group

ADSaT

Entity Pattern

Customer table

Customer Server object

Customer Server object

Clients

CustomerServer object

Factory

1

2

Page 20: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

20Advanced Distributed Software Architectures and Technology group

ADSaT

Characteristics• Server objects represent specific

‘rows’ in the database• Client use a factory to create a

server object• Server objects have a get/set

style interface for each attribute of the database row

Page 21: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

21Advanced Distributed Software Architectures and Technology group

ADSaT

Issues

• How is concurrency control handled?

• 2 clients access same row at same time

• Scalability - many remote accesses to get/set individual attributes

• Plus all issues of stateful servers

Page 22: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

22Advanced Distributed Software Architectures and Technology group

ADSaT

State(ful/less) + Entity

Customer table

Customer Server object

Customer Server object

Server object

Server object

Page 23: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

23Advanced Distributed Software Architectures and Technology group

ADSaT

Characteristics

• Combines service-based patterns with entity pattern

• Clients access state(ful/less) server objects (see previous slides)

• Server objects create entity objects as needed

• Server objects isolated from DBMS - a good thing...

Page 24: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

24Advanced Distributed Software Architectures and Technology group

ADSaT

Issues

• All of the previous ones…• Need to rely on DBMS locking to

handle concurrency• Need to be careful with DBMS

deadlocks• Scales only if server object and

entity object in same process/node

Page 25: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

25Advanced Distributed Software Architectures and Technology group

ADSaT

Synchronous Messaging

Server object

Client

Request Queue

Reply Queue

Page 26: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

26Advanced Distributed Software Architectures and Technology group

ADSaT

Characteristics• Client writes a service request to a

queue in a transaction, and indicates where to write the results

• Server object removes request, performs service, and writes results to a reply queue (all in a transaction)

• Client removes results from reply queue in a transaction

Page 27: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

27Advanced Distributed Software Architectures and Technology group

ADSaT

Issues• Emulating synchronous behaviour

with asynchronous technology• Breaking 1 transaction up in to 3

• client has to remember state for recovery purposes

• How do we scale up to many clients?

• many request and reply queues• many server objects• many queues per server object

Page 28: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

28Advanced Distributed Software Architectures and Technology group

ADSaT

Asynchronous Messaging

QueueServer object

Client

Request Queue

State(ful/less)Server object

Page 29: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

29Advanced Distributed Software Architectures and Technology group

ADSaT

Characteristics

• Client makes synchronous call to server object

• Server object updates DBMS, places request on queue and returns results to client in a transaction

• Queue server object takes request from queue and updates DBMS in a transaction

Page 30: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

30Advanced Distributed Software Architectures and Technology group

ADSaT

Issues

• Used for delayed processing• when part of a synchronous transaction

is slow • write slow part to queue transactionally• no need to delay client, process request

some time later (but will get processed)

• Very commonly deployed architecture, one of the strengths of messaging

Page 31: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

31Advanced Distributed Software Architectures and Technology group

ADSaT

Example

Customercomponent

Paymentcomponent

Ordercomponent

Goodscomponent

Stockcomponent

Deliverycomponent

DCOM/COM

MTS

Databaseserver

Applicationserver

Warehousemanager

Printinvoices

Webserver

Webserver

Local clientworkstations

Internet/Intranet

Remote warehouses ScriptedWeb

pages

Central Office

Userclientapps

Remote sales offices

Router

Remote sites

HTTP

ORPC

ORPC/MQ

Userclientapps

CICSinterface

Externalcompany

accountingsystem

Page 32: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

32Advanced Distributed Software Architectures and Technology group

ADSaT

Web-based Clients

Paul Greenfield

Page 33: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

33Advanced Distributed Software Architectures and Technology group

ADSaT

The Web

• A single standard user interface technology– Web browsers

• A common client platform

– Using HTML to get to a Web server• A common protocol

• Except for ….– Many variations and standards to

choose from….

Page 34: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

34Advanced Distributed Software Architectures and Technology group

ADSaT

Static Web Pages

• Static HTML– Simple forms – No complex logic– Simple HTML is very portable

across browsers– Very limited as a tool for building

user interfaces• No way to include user logic • Presentation/forms only

Page 35: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

35Advanced Distributed Software Architectures and Technology group

ADSaT

CGI Scripts

• Running logic on the server– The traditional UNIX way– URL references a CGI program

rather than a web page– Web server runs a program or

script (C, Perl, …) when the page is requested

– Program/script runs and returns HTML

– Complex to write and scales poorly

Page 36: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

36Advanced Distributed Software Architectures and Technology group

ADSaT

ISAPI and NSAPI

• Call a library rather than starting a program– Microsoft and Netscape APIs– Much faster than CGI (no startup time)– Call returns HTML

• code has to write HTML strings

– Still hard to write and complex– Java servlets are a later equivalent

Page 37: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

37Advanced Distributed Software Architectures and Technology group

ADSaT

Client-side Scripting

• Add logic to the HTML– Logic in Jscript, VBscript, …– Script sees Web page as an object

• Manipulate the page being displayed• Change text, check values, hide fields,…

– Portability? • MS, Netscape; v3, v4, v5, …

– Useful for building dynamic, responsive Web-based user interfaces

Page 38: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

38Advanced Distributed Software Architectures and Technology group

ADSaT

Applets

• Downloadable code run inside the Web page– Java applets, ActiveX controls– Severe security restrictions?

• Java sandbox (no files, little networking, …)

• Code signing (ActiveX and Java)

– Relegated to niche usage• Graphics, expanding indexes, viewers

Page 39: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

39Advanced Distributed Software Architectures and Technology group

ADSaT

Server-side Scripting

• Scripted Web pages with the Web server running the script– Easier programming than CGI

• Script running within a Web page

– Script can call on business components• Fits in with n-tier model• Script does UI/presentation functions

– Can produce portable HTML– ASP (Microsoft) and JSP (SUN)

Page 40: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

40Advanced Distributed Software Architectures and Technology group

ADSaT

N-tier Clients

• Simple browsers on desktops– Good chance of portability– Simple HTML

• Server-side scripted Web pages– ASP or JSP– Calling on transactional

components for business processes (COM, EJB)

Page 41: Advanced Distributed Software Architectures and Technology group ADSaT 1 Application Architectures Ian Gorton, Paul Greenfield.

41Advanced Distributed Software Architectures and Technology group

ADSaT

Next Week…

• CORBA