information systems development 3 lecture 2 3-tier application architecture a technical view

28
Information Systems Development 3 Lecture 2 3-tier application architecture A technical view

Post on 22-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Information Systems Development 3

Lecture 2

3-tier application architectureA technical view

Themes

• Architecture : The large scale structure of a system, especially a computer system

• Communications : The interaction between components

• Description: Patterns and story-telling• Choice

– Design decisions: design decisions which face a developer

– Infrastructure choice: selecting the most appropriate software from the available range.

Displaying a Web page in a Browser

• <a href= http://www.cems.uwe.ac.uk/~cjwallac/UFIE8V-2004/l2_3tier.html>Lecture 2</a>

• URL is decoded : protocol/host/file• Page requested from host• Page is returned

• HTML codes determine how text is rendered• If page contains links e.g. <img src=red.gif>,

browser must repeat the same process on each

Dynamic Web page needed when:

• consistent look and feel on each page of a large site

• data is derived from a database

• depends on real time

• pages depend on user choice

• business transactions e.g. e-commerce…

3-tier architecture

• A Presentation layer using Browser technology

• An Application layer using a web application server platform + application programs

• A Persistence layer using a relational database or other data store technology

BUS (Level 1 Diagram)

usersa

information need

presentation layer

1

application layer

2

HTTP requests

persis tance layer

3

SQL requests tables

HTML files

information

service providers

b timetablesBrowser such as IE6, FoxFire

Apache or MS IIS server +PHP

MySQL RDBMS

Presentation layer arch

• Issue request to remote server • accept the returned HTML (or JPEG..) file • render (i.e. create a 2-d image ) the HTML• allow plug-ins to handle new file types• execute client-side scripts in JavaScript• support interaction between client-side scripts

and the web page• accept user input via a variety of controls on a

form

Persistence layer arch

• interaction with the database using standard languages e.g SQL queries and table returns

• define and modify the data structures (e.g. tables) themselves ( the Database Schema)

• insert, update and delete data• maintain data persistently, with backup and

recovery• handle transactions to support concurrent

access to the database via locking et• optimise access by compilation of queries,

indexing, replication of tables etc.

Application Layer arch

• accepting requests from the Presentation layer• interpreting the requests according to business rules and

past transactions from this client• requesting the appropriate data from the Persistence

layer• computing derived data• creating the HTML (or GIF, MIDI..) for the page • providing run-time support for:

– thousands of concurrent users – compilation to machine code– multi-threading [ allow multiple processes to run concurrently]– caching [holding results in a temporary store to reduce re-

calculation]

Web Application Platforms

• Server side includes - files with a .shtml extension • Cgi using Perl or other scripting language • PHP like SSI, a scripting language which is embedded in

an HTML page. • Microsoft’s ASP (Active Server Pages ) • J2EE

– JSP for page scripting– Java + class library– Multiple runtime vendors Tomcat, BEA

• .NET is the latest technology from MS. – range languages (VB.NET, C#, , C++, Cobol... )– compiled to a common intermediate code (MSIL)– Extensive class library– ASP.NET scripting page scripting

3-tier Issues• Advantages:

– Re-use of appropriate software – Software can be located on different machines for

convenience and performance – Resolves one-many relationships – many clients –

one application, many applications – one database

• Challenges:– well-defined, standardised interfaces between layers

required. – Software must be built to conform to interface

standards– The designer has to decide where to locate specific

functions

Communication

• The ‘glue’ in this architecture is communication between software in the layers

• A single request from a user results in a complex flurry of communications and executions

• The flurry is composed of hundreds of simple interactions

• Sequence diagrams can be useful to provide a simplified description

Simple Interaction

• Call/reply pattern

caller callee

parameters

function

reply

A function call in PHP

• <?php print date(“H:I”); ?> in a php script– the script is the caller– the date procedure is the callee – the string “H:I” is the parameter –– the function is to get the current date and

time –– the reply – a string containing the time in the

required format e.g. “13:45”

A browser requests a page

• The user clicks on a link on a page. The link has an href=http://host/dir/page.html– The browser is the caller– The web server program(Apache or IIS) on

the machine host is the callee.– The string “dir/page.html” is the parameter– The function is to read that file in its file store– The reply is the contents of the file

A browser requests a script to execute

• The user clicks on a link on a page. href=http://host/dir/getemp.php?empno=5– The browser is the caller– The web server on the machine host is the callee.– The string “dir/getemp.php?empno=5” is the

parameter– The function when the suffix is php is to find the

script, call it with the parameter and get the output. – The reply is the reply from getemp.php

Server runs a PHP script

• The web server is the caller• The getemp.php script is the callee• The parameter is empid = 5• The function is to find the details of employee

5 and format a report• to perform this function, the script calls

mysql_connect procedures which in turn calls the mySQL server ….

• The reply is HTML text

Simple Interaction Variations

• How does the caller find the callee?

• What does the caller do when is waiting for a reply?

• What happens if the callee doesn’t reply?

• How long should the caller wait until it thinks the callee isn’t going to reply?

• Is a reply always required?

Sequence diagram of SMS bus times requestsmsrequest

user :

078. / mobile phone : Message centre : Clickatell : web03 / web server : smsrequest : mysql :

bus 99()

076.. bus 99()

078 .. 076.. bus 99()

mo.php?text=bus+99&from=078()

mo.php :

text=bus 99, from=078()

text=99&from=078&code=BUS()

select dtime from service, timetable...()

table dtime, destination

Reply: next 99 departures ..

req?text=next+99+dep&to=078()

message centre 2 :

to 078 next 99 dep()

next 99 departures()

read()

A Pattern

• A pattern recurs in different guises – have the same overall structure and purpose,– with slight differences

• Patterns help us understand and describe complex systems

• Patterns ‘normalise’ descriptions – one thing in one place

• Same unit plays different ‘roles’ – webserver is callee with respect to (wrt) browser,

caller wrt getemp.php• Patterns are ‘fractal’

Other layered architectures

• ANSI/SPARC Database model– The external or user level, characterised by

Views– The Conceptual level, comprising the full

corporate data model at a logical level– The Physical level, where data is stored in

files

Channels between Layers

• Layered communications model (Tanenbaum)• Application Layer• Transport Layer• Network Layer• Data Link Layer• Physical Layer

• Presentation <> Middleware– HTTP (The protocol which supports GET and POST

messages) carrying a limited number of types of content (MIME types)

• Middleware <> Data stores– ODBC with SQL request and table returns (whole

table or row at a time)

Review Questions

• Place the following terms in the 3-tier architecture:– JavaScript, SSI, J2EE, MySQL, Oracle, CSS,

PHP, ASP.NET, Flash, Java Applets, JSP, Dreamweaver, Visual .NET

Straw Poll application

• Which parts belong to which tier of the 3-tier model script?

• What is the ER model of the database?

• What must be done to make selected improvements to this application?

• Describe the interaction when a user votes; when the tally page is requested.

Platform Comparision

• Enterprise solutions

• J2EE versus .NET– Simple words such as “better” or “faster” are best used by

simpletons. Life, especially when it involves critical enterprise applications, is more complicated.

• PHP versus .NET– Language wars

Comparison criteria

• Other considerations, such as the perception of the vendor as an “enterprise company”, conformance to standards, strength of the ecosystem around the product, the degree to which the product is a de facto standard amongst its class, stability of the product or technology, ease of use, IDE integration and other tool support, total cost of ownership (TCO), portability and lock-in (or lack thereof), scalability and many other such factors often outweigh Performance among our customers.