Architectural styles for software systems The cliet-server style Prof. Paolo Ciacarii Software Architecture CdL M Iformatica Uiversità di Bologa
Ageda Cliet server style CS two tiers CS three tiers CS -tiers 2
Cliet-Server (CS): Overview CS has bee coceived i the cotext of distributed systems, aimig to solve a problem of resources shared amog several computers The drivig idea is to make ubalaced the parters roles withi a commuicatio process Oe or may servers provide services to istaces of subsystems, called cliets Each cliet calls o the server, which performs some service ad returs the result 3
Cliet-Server: Overview Fuctios performed by cliet: Requires a service through the server iterface(s) Allows to users to commuicate with the system through a certai iput (Customized user iterface) Frot-ed processig of iput data Fuctios performed by server: Cetralized data maagemet Services provider Back-ed processig of the data provided by cliet 4
Cliet server patter: mai A cliet-server system ca be logically divided ito three parts: The presetatio tier, i charge of maagig the user iterface (graphic evets, iput fields check, etc ) The actual applicatio logic tier The data maagemet tier for the maagemet of persistet data ad trasactio maagers 5
The busiess logic tier Some patters help i structurig the busiess logic: Trasactio script: a procedure that takes the iput from the presetatio, processes it with validatios ad calculatios, stores data i the database, ad ivokes ay operatios from other systems. It the replies with more data to the presetatio, perhaps doig more calculatio to help orgaize ad format the reply. Domai model: a object model of a domai icorporates both behavior ad data Table module: a sigle istace that hadles the busiess logic for all rows i a database table or view (as i relatioal database) Fowler, Patters of eterprise applicatio architecture 6
Cliet-Server patter A cliet-server system architecture ca be: 2-tiered: presetatio ad applicatio logic modeled as a sigle tier cotaied i the cliet 3-tiered: oe tier for each part, with dedicated servers for applicatio logic ad data maagemet -tiered: the last two parts spread i a chai of servers 7
Cliet: CRC Class Cliet Resposibilities Compoet: hadles User iteractio Asks the Server for some service Collaborators Server
Server: CRC Class Server Collaborators Resposibilities Compoet (offers some services) Provides a API for receivig/aswerig messages
Cliet-Server: Architecture 10
CS 2-tiers: Overview This style is used to describe cliet-server systems where the cliet requests resources ad the server respods directly to the request usig its ow resources The server does ot call o aother applicatio i order to provide part of the service If the server is more powerful tha its cliets, it is possible to coect may cliets at the same time 11
CS 2-tiers: Architecture (1) Compoets: Cliet Active etity Cotais always the User System Iterface subsystem (sessio, text iput, dialog, ad display maagemet services) If it cotais the Applicatio Logic subsystem (process maagemet), tha it is a Fat Cliet Server Reactive etity Cotais a Database Maagemet subsystem (such as data ad file services) If it cotais the Applicatio Logic subsystem, tha it s a Fat Server Coectors: Procedure Calls, RPC, or others They require a protocol 12
CS 2-tiers: Architecture (2) The Applicatio Logic may be preset either at the cliet side withi a user iterface or withi the database o the server side or spread o the both R P C R P C R P C R P C R P C Fat Server Fat Cliet 13
CS 2-tiers: Compoet Diagram 14
CS 2-tiers: Class Diagram Cliet * requester * provider Server service1() service2() servicen() 15
CS 2-tiers: Sequece Diagram 16
CS 2-tiers example (1): web browser ad web server HTTP (Hypertext Trasfer Protocol): ASCII-based request/reply protocol that rus over TCP HTTPS: variat that first establishes symmetrically-ecrypted chael via public-key hadshake, suitable for sesitive ifo By covetio, servers liste o TCP port 80 (HTTP) or 443 (HTTPS) Uiversal Resource Idetifier (URI) format: scheme, host, port, resource, parameters, fragmet http://search.com:80/img/search/file?t=baaa&cliet=firefox#p2 17
CS example: World Wide Web 18
CS 2-tiers example (2): web browser ad web server Cliet s request: GET /idex.html HTTP/1.0 User-Aget: Mozilla/4.73 [e] (X11; U; Liux 2.0.35 i686) Host: www.yahoo.com Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/pg, */* Accept-Laguage: e Accept-Charset: iso-8859-1,*,utf-8 Server s reply: HTTP/1.0 200 OK Cotet-Legth: 16018 Set-Cookie: B=2vscoq5p0h2 Cotet-Type: text/html HTTP method & URI Cookie data: up to 4KiB MIME cotet type <html><head><title>yahoo!</title><base href=http://www.yahoo.com/> <img width=230 height=33 etc 19
CS 2-tiers: Pro & Cos (1) Beefits (towards a Moolithic Architecture): Good security, because the users usually caot see the database directly ad ca oly access the data by startig the cliet More scalable, because allows multiple users to access the database at the same time as log as they are accessig data i differet parts of the database Faster executio due to a shared workload 20
CS 2-tiers: Pro & Cos (2) Pitfalls: Exhibits a heavy message traffic sice the frot-eds ad the servers commuicate itesively The Applicatio Logic is ot maaged by a ad-hoc compoet, but it s shared by frot-ed ad back-ed Cliet ad server deped oe from each other It s difficult to reuse the same iterface to access differet data It s difficult to iteract with databases which have differet frot-eds The busiess logic is ecapsulated ito the user iterface, thus if the logic chages, the iterface has to chage as well 21
CS 3-tiers: Overview (1) I 3-tiers CS architecture, there is a itermediary tier, meaig the architecture is geerally split up betwee: A cliet, which requests the resources through a user iterface (i.e. web browser) for presetatio purposes The applicatio server, whose task it is to provide the requested resources, but by callig o aother server The data server, which provides the applicatio server with the data it requires 22
Geeric 3-tiers software architecture 23
CS 3-tiers: Overview (2) Tiers work as they were ot part of a sigle applicatio: Applicatios are coceived as collectios of iteractig compoets Each compoet ca take part to several applicatios at the same time Each server compoet is specialised with a certai task: web server, database server, etc Tiers 1 ad 3 do ot commuicate: The user iterface either receives ay data from data maagemet, or it ca write data Iformatio passig (i both the directios) are filtered by the Applicatio Logic 24
CS 3-tiers: Architecture (1) Compoets: Cliet Active etity Thi cliet cotaiig oly the Presetatio Logic subsystem (sessio, text iput, dialog, ad display maagemet services) Applicatio Server Cotais the Applicatio Logic subsystem providig process maagemet such as queuig, applicatio executio, ad database stagig Data Server Passive etity Cotais the Database Maagemet subsystem (such as data ad file services) 25
CS 3-tiers: Architecture (2) Coectors: Remote Procedure Calls (RPC) Protocol: The cliet calls for the busiess logic o the server, the busiess logic o the behalf of the cliet accesses the database 26
CS 3-tiers: Compoet Diagram 27
CS 3-tiers: Class Diagram Cliet * requester * provid er Applicatio Server - sessios - services sessio() doservice() use call iterface Middleware Data Server + GET() + PUT() + POST() + DELETE() select() isert() delete() update() 28
CS 3-tiers: Sequece Diagram 29
CS 3-tiers example: Web Mail 30
CS 3-tiers example: Struts framework Copyright IBM Struts framework The browser seds a request to a Actio servlet The Actio servlet istatiates a Java bea that is coected to a database The Actio servlet commuicates with a JSP file The JSP file commuicates with the Form bea The JSP file respods to the browser 31
CS 3-tiers: Pro & Cos (1) Beefits: High flexibility ad high modifiability: Compoets ca be used i several systems New fuctioalities ca be added to the system by oly modifyig the compoets which are i charge of realizig them, or by pluggig ew compoets More scalability ad performace because we ca add as may middle tiers as eeded Thi cliet, because oly little commuicatio is eeded betwee the cliet ad the middleware which implemets the Applicatio Logic 32
CS 3-tiers: Pro & Cos (2) Pitfalls: The additioal tier icreases the complexity ad cost of the system: Ad hoc software libraries have to be used to allow the commuicatio amog compoets Heavy etwork traffic Legacy software: May compaies make use of preexistig (ofte moolithic) software systems to maage data Adapters have to be implemeted to iteroperate with the legacy software 33
CS -tiers: Overview (1) I the 3-tier applicatios, the middle tier is geerally ot a moolithic program but is implemeted as a collectio of compoets that are iitiated by several cliet-iitiated busiess trasactio Thus, oe compoet ca call other compoets to help it implemet a request Geerally, a server ca use services from other servers i order to provide its ow service 34
CS -tiers: Overview (2) Fudametal items: User Iterface (UI): a browser, a WAP mii browser, a graphical user iterface (GUI) Presetatio logic, which defies what the UI has to show ad how to maage users requests Busiess logic, which maages the applicatio busiess rules Ifrastructure services: They provides further fuctioalities to the applicatio compoets ( messagig, trasactios support) Data tier: Applicatio Data level 35
CS -tiers: Architecture (1) Typical compoets: Cliet Same as 3-tiers Architecture Web Server Sessio maagemet Cotet creatio, format ad delivery Applicatio Server Data access objects Trasactios Busiess logic Resources adapters Data Server Same as 3-tiers Architecture 36
CS -tiers: Architecture (2) Coectors: Remote Procedure Calls (RPC) May protocols Copyright etutorials.com Architectural solutios 37
Example: 5 tiers Presetatio Data Logic Process Cliets Portal Browser Applicatio Cliet Process Web Services WSRP Data Maiframes Data Databases Data Legacy App Web Services WSRP Web Services Process Mobile Idetity/ Policy Web App Web Services Service Ifrastructure Security Services User Iteractio Services Busiess Process Services Custom Services Service Registry Meta-data Repository Compositio Tools Data Services Sematic Services: Mediatio Text Aalytics Iferecig Evet Processig Moitorig Messagig Services Service Maagemet
Cliet server middleware 39
Refereces Fowler et al., Patters of Eterprise Applicatio Architecture, AW 2002 Clemes et al., Documetig Software Architectures, Addiso Wesley, 2010
Questios?