You are on page 1of 27
Lecture 1: Multi-tier Architecture Overview Tiers/ Layers Characteristics - in Software World 5 Each tier/layer should be able to be constructed separately, possibly by different teams of people with different skills. 2 Several tiers/layers should be able to be joined together to make a whole "something". 1 Each tier/layer should contribute something different to the whole. A chocolate layer cake, for example, has layers of chocolate cake and cream. Tiers/ Layers Characteristics - in Software World (cont.) 2 There must also be some sort of boundary between one tier and another. 0 Each tier/layer should not be able to operate independently without interaction with other tiers/layers. Basic Idea of Multi-tier Design © The basic idea of a multi-tier design is that all of the logical functions of the application are (or at least have the potential to be) separated on provides output to other layers. The Standard Logical Layers © Presentation logic: The user interface (Ul) which displays data to the user and accepts input from the user. In a web application, this is the part which receives the HTTP request and returns the HTML response. 2 Business log landles data validation, business rules and task-specific behavior. © Data Access logic: Communicates with the database by constructing SQL queries and executing them via the relevant API. Example of Business Logic ‘Transferring money from one checking account to another Fst what are the rings that you need to know (put? ‘+ Theldertiy ofthe person making the transfer 1 Theameant of money tobe wanstrret ‘+ The source chocking acount ruber + Thetarget checking account ruber What are some ofthe business rues" that must be apple? ‘+The person mating the aquest must have he auton 04050. + Thetraneacton mustbe tome 4+ Thetransacton may have reporing reqarement othe goverment iis over ace amount 18 "tome "| mean thatthe vansacton must cempley succeed crust completa a. You cat have account vansacSens whore nen is iaken out of ene accour wihout arngin te thet ((maney dsappea's), of money 5 deposted ro an accour, but el debited em athe account (tmaney magically appears ram nowhere). Tiers vs. Layers in Software © Tier is a physical unit, where the code / process runs. E.g client, application server, database server a Layer is a logical unit, how to organize the code. By resentation (view), controller, models, repository, data access © A three-layer solution could easily be deployed on «@ single tier, such as a personal workstation 1-Tier Architecture ‘Application Component Presentaton Business |—of Data Access 1 bie ge fe] bc Lt ostabase SS © All 3 layers are on the same machine 4 All code andl processing kept on a single machine © Presentation, Logic, Data layers are tightly connected 4 Scalability: Single processor means hard to increase volume of processing Portability: Moving to a new machine may mean rewriting everything 1 Maintenance: Changing the layer requires changing other layers 1-Tier Architecture 1-Tier Architecture (blurry boundary) 2-Tier Architecture sta Layer Daa Access tage fe ‘Client Server | Database runs on Server 4 Separated from client 4 Easy to switch to a different database 15 Presentation and logic layers still tightly connected 4 Heavy lead on server 2 Potential congestion on network 4 Presentation stil ted to business logic 2-Tier Architecture 3-Tier Architecture Database © Each layer can potentially run on a different machine © Presentation, logic, data layers disconnected 3-Tier Architecture FER staareyer 1629 Ge Si The Rules of the Multi-tier Architecture 0 The code for each layer must be contained with separate files which can be maintained separately. 1 Each layer may only contain code which belongs in that layer. Thus business logic can only reside in the Business layer, presentation logic in the Presentation layer, and data access logic in the Data Access layer. Requests and Responses in the 3 Tier Architecture REQUEST @ Afra -! ee a < reronse — The Rules of the Multi-tier Architecture (Cont.) G The Presentation layer can only receive requests from, and return responses to, an outside agent. This is usually a person, but may be another piece of software. The Presentation layer can only send requests to, and receive responses from, the Business layer. It cannot have direct access to either the database or the Data Access layer. The Rules of the Multi-tier Architecture (Cont.) co The Business layer can only receive requests from, and return response to, the Presentation layer. 1 The Business layer can only send requests to, and receive responses from, the Data Access layer. It cannot access the database directly. The Rules of the Multi-tier Architecture (Cont.) 0 The Data Access layer can only receive requests from, and return responses to, the Business layer. It cannot issue requests to anything other than the DBMS which it supports. a Each layer should be totally unaware of the inner workings of the other layers. The 3-Tier Architecture for Web Application © Presentation Layer 4. Static or dynamically generated content rendered by the browser, e.g., HTML, CSS, Javascript (front-end) © Logic Layer 1 A dynamic content processing and generation level pplication server, e.g., Java EE, ASPNET, PHP, ColdFusion platform (middleware) © Data Layer 4. A database, comprising both data sets and the database management system or RDBMS software that manages and provides access to the data (back-end) N-Tier Architecture Ekewhere Layer Soo oie Requester/ ‘Consumer layer Web browser/ XML parser| or other client Preserarion) [Boies Aecesior loyer togietyer | | Layer Validation/ Procening/ Content Get Updete, Disploy Providing | [Delete mmedules trodes mmadules Persistonce Lover N-Tier Architecture (cont.) © This architecture differs from standard (3-Tier) in three respects: It explicitly states that the persistence layer (the database ‘and its database management system) and the accessor layer, which feeds SQL queries to the persistence layer, are separated. It explicitly lists the requester/consumer layer as part of the application, even though the software running there is usually not under the control of the developer building the rest of the application (in the case of a browser, it’s from the Mozilla team or Microsoft or whomever). It acknowledges that remote resources (the elsewhere layer) can be an integral part of a multi-tier application. N-Tier Architecture (cont.) © Persistence Layer: The database or other storage mechanism that keeps data in an organized way. © Accessor Layer: The programs that pass queries to the persistence layer (in other words, the programs in which structured query language (SQL) statements are hard- coded). These programs expose “get” and “set” functions. © Business-Logic Layer: The programs that process user input and stored data and come up with a useful result. © Presentation Layer: The programs that format the results of the logic layer as hypertext markup language (HTML), extensible markup language (XML), or whatever else the user requires. N-Tier Architecture (cont.) © Requester/consumer Layer: The Web browser, XML parser, or other client that makes requests of the application and receives its output. = Elsewhere Layer: The external Web services, HTML pages, and other resources to which applications make reference. Advantages of Multi-Tier Architecture ibility - By separating the business logic of an ication from its presentation logic, a Multi-Tier architecture makes the application much more flexible to changes. © Maintainability - Changes to the components in one layer should have no effect on any others layers. Also, if different layers require different skills (such as HTML/CSS in the presentation layer, PHP/Java in the business layer, SQL in the data access layer) then these can be managed by independent teams with skills in those specific areas. Advantages of Multi-Tier Architecture © Reusability - Separating the application into multiple layers makes it easier to implement re-usable components. A single component in the business layer, for example, may be accessed by multiple components in the presentation layer, or even by several different presentation layers (such as desktop and the web) at the same time. © Scalability - A Multi-Tier architecture allows distribution of application components across multiple servers thus making the system much more scalable. © Reliability - A Multi-Tier architecture, if deployed on multiple servers, makes it easier to increase reliability of a system by implementing multiple levels of redundancy.

You might also like