Presentation is loading. Please wait.

Presentation is loading. Please wait.

Centralized Architectures

Similar presentations


Presentation on theme: "Centralized Architectures"— Presentation transcript:

1 Centralized Architectures
Figure 2-3. General interaction between a client and a server. What to do with lost message? idempotent = possible to resend message without harm, e.g., read account

2 Server design issues Server organization
Iterative Concurrent Multithreaded Fork (unix) Stateless or stateful Client contact: End point (port) Well-known Dynamic: daemon; superserver (unix) Stateless = no info kept about the state of clients If info lost does not lead to disrutpion of the server’s service (important) Alternatvie: soft state: promise to follow state for limited time, for example inform client about updates to a resource Stateful: persistent info on its clients - info must be explicitly deleted by the server . Example: file server allows clients to keep local copy of files and also update them locally (table with client-file entries) However, if server crashes, it has to recover the table!

3 End Point, General Design Issues (1)
Exempel: time-of-day, som behöver vara uppe konstant Klienten måste först leta upp end point-adress - speciell daemon som håller reda på aktuella adresser till tjänster daemon själv finns på en well-known port Figure (a) Client-to-server binding using a daemon.

4 End Point, General Design Issues (2)
Figure (b) Client-to-server binding using a superserver. Exempel: inetd i unix = the server process for the Internet standard services /etc/inetd.conf innehåller en lista på tjänsterna: ftp, echo, telnet, finger lyssnar på tcp- och udp-portarna efter anrop slöseri med resurser att implementera varje tjänst med en specifik server I unix finns t.ex. massvis med servrar som körs samtidigt, många är passivt väntande - använder istället en superserver, som lyssnar på alla portar som är aktuella inetd exempelvis är en sådan superserver När en request kommer, gör inetd fork och skapar en annan process

5 Server Clusters (1) Figure The general organization of a three-tiered server cluster. 3-tiered Tier 1 = logical switch (the access point to the cluster; can be replicated) example: tcp switch or http switch - dns can be used to return several addresses for the same host name, if using several access points to increase availability Tier 2: high-performance computers, most often single service (stream movie) Tier 3: data-processing, sometimes included in tier 2, disk access, cache Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

6 Server Clusters (2) Figure 3-13. The principle of TCP handoff.
The switch in tier 1: Spoof source ip when server is responding (looks like it comes form the switch) Requires OS-level modifications Load-balancing = round-robin Or more advanced: distinguish between diff port numbers Or examine http contents (context-aware request distribution) Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

7 Sockets: Processes in different hosts communicating
TCP with buffers, variables socket host or server process TCP with buffers, variables socket host or server process sends/receives messages to/from its socket socket analogous to door sending process shoves message out door sending process relies on transport infrastructure on other side of door which brings message to socket at receiving process controlled by app developer Internet controlled by OS Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different hosts communicate by exchanging messages Client process: process that initiates communication Server process: process that waits to be contacted Note: applications with P2P architectures have client processes & server processes Addressing processes - to receive messages, process must have identifier host device has unique 32-bit IP address Q: does IP address of host on which process runs suffice for identifying the process? A: No, many processes can be running on same host identifier includes both IP address and port numbers associated with process on host. Example port numbers: HTTP server: 80 Mail server: 25 to send HTTP message to gaia.cs.umass.edu web server: IP address: Port number: 80 well-known port numbers API: (1) choice of transport protocol; (2) ability to fix a few parameters. How to address processes? TDTS04 Lecture 2: Application layer and transport

8 Berkeley Sockets Figure 4-14. The socket primitives for TCP/IP.
varför sockets? enkelt sätt att rpogrammera nätapplikationer på om man vill programmera närmare nätet än vad rpc tillåtter - måste känna till hur tcp och udp fungerar (ström versus paket) Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

9 Connection-oriented socket (tcp)
Figure Connection-oriented communication pattern using sockets. Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

10 Clock Synchronization
I ett centralierat system är tiden otvetydigt definierad via central klocka – anropa kernel Figuren: Viktigt för make-programmet i unix, så att man omkompilerar alla källkodsfiler som har ändrats efter senaste kompileringen (titta på objektfilernas tidsstämpel och jämför) Andra exempel: Aktiehandel, övervaka händelser vid säkerhetsövervakning – fler exempel? Figure 6-1. When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

11 Physical Clocks (2) Klockan är egentligen en timer i datorn Kvartskristall som svänger med viss frekvens, varierar fårn dator till dator över tiden = skevande klockor Två register: räknare och hpållningsregister: varje svängning minskar räknaren med ett, när den når noll genereras en interrupt (ett klocktick) och räknarens återställs till ursprungsvärdet från hållningsregistret Datum och tid sparas i CMOS-RAM-minnet, ett speciellt batteriförsett minne bredvid CPU:n. Figuren: Sedan 1948 finns atomur med cesium 133 där man har definienrat en sekund som övergångar hos cesium-133-atomen = 1 genomsnittlig solsekund – dess atomur finns hos laboratorier i världen och rapporterar till BIH i Paris, som tar medelvärdet och procuderar TAI = International Atomic Time Stämmer ej exakt med verkligheten eftersom jorden roterar allt långsammare; just nu är TAI ca 3 msec efter  måste införa skottsekunder med jämna mellanrum (när skillnaden är 800 msec till verkligheten)  detta system kalla UTC, Universal Coordinated Time (obs. förkortningen fransk!) - finns på kortvågsradion som WWV +/- 10 msec eller satellit 0,5 msec korrekt Figure 6-3. TAI seconds are of constant length, unlike solar seconds. Leap seconds are introduced when necessary to keep in phase with the sun.

12 Lamport’s Logical Clocks (1978)(1)
The "happens-before" relation → can be observed directly in two situations: If a and b are events in the same process, and a occurs before b, then a → b is true. If a is the event of a message being sent by one process, and b is the event of the message being received by another process, then a → b - Leslie Lamport:reserach.microsoft.com/~lamport Ofta tillr’ckligt att noderan endast är överens om en gemensam tid, vilken som helst och ej nödvändigtvis den absoluta tiden i verkligheten t.ex för make behöver två noder endast komma vöerens om en fil är äldre än en anna fil  behöver endast hålla reda på vad de två noderna har utfört (skrivit i källkodsfil etc.) och när  använd logisk klocka för relativ tid mellan de två noderna = lamports logiska klockor  senare utvidgning: vektorklockor/tidsstämplar Figuren Ett meddelande kan inte tas emot av en process I förrän det har skickats av process J, ej ens på samma tid (nätet har fördräjning)

13 Lamport’s Logical Clocks (2)
Figure 6-9. (a) Three processes, each with its own clock. The clocks run at different rates. Mät tid genom att låta varje nod ha sin egen klocka med sin egen hastighet (olika antal tick per sekund) Tavla: klockan i varje nod måste ha egenskpaen att de alltid räknas upp, aldirg ned + korrigeringar av tiden är alltid additioner, aldrig subtraktioner och, så att Om ab så gäller C(a) < C(b) - samma gäller för en nod I som skickar ett meddelande vid tiden C(a) och processen J tar emot medd vid tiden c(b) så gäller C(a) < C(b) Figuren: klockan tickar 6 i P1, 8 i P2 och 10 i P3 + fyra medd skickas och tas emot - Medd innehåller varje process tidsstämpel från när de skickades

14 Lamport’s Logical Clocks (3)
När en process tar emot ett medd så måste dess tidsstämpel följa egenskaperna för C(a) och C(b) P2 korrigerar sin tid när den ser P3 medd m3 med plus-ett - P1 korrigerar sin tid efter m4 från P2 med plus-ett Figure 6-9. (b) Lamport’s algorithm corrects the clocks.

15 Lamport’s Logical Clocks (4)
Figure The positioning of Lamport’s logical clocks in distributed systems.

16 Lamport’s Logical Clocks (5)
Updating counter Ci for process Pi Before executing an event Pi executes Ci ← Ci + 1. When process Pi sends a message m to Pj, it sets m’s timestamp ts (m) equal to Ci after having executed the previous step. Upon the receipt of a message m, process Pj adjusts its own local counter as Cj ← max{Cj , ts (m)}, after which it then executes the first step and delivers the message to the application. En nod ökar tiden med 1 när en händelse inträffar (händelse = skicka medd, ta emot medd, etc.) Mottagande nod sätter tiden till max av medd tidsstämpel och den egna tiden och ökar sedan sin egen tid med 1

17 Middleware Protocols Figure 4-3. An adapted reference model for networked communication. Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

18 Types of Communication
Figure 4-4. Viewing middleware as an intermediate (distributed) service in application-level communication. persistent kommunikation = medd som har skickats lagras av sändnings-middleware tills det kommer fram till mott sändaren behöver inte vänta på svar utan kan fortsätta med annat transient kommunikation = medd lagras av middleware endast så länge som sändare och mottagare är online och exekverar om det blir fel i transporten så förloras medd eller om mott saknas/ej online asynkront = sändaren fortsätter med annat direkt efter att ha sänt medd synkront = sändaren blockeras (måste vänta på svar) tills medd accepterats av middleware – tre ställen möjliga för blockning: medd mottagits av middlware medd levererats (till servern) mott svarat (bearbetat förfrågan) Vanliga kombinationer: persistens + synkronisera vid middleware (meddelandekösystem) - transient + synkronisera vid svar Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

19 Client and Server Stubs
vanligt anrop = read-funktionen länkas av länkaren till read-systemanropet (enkel rutin) RPC = read-fkn länkas till klientstubbe + anropar också OS, men begär inte OS om data, utan istllet packar stubben ihop parametrarna i ett litet paket inklusive funktionsnamnet och ber OS att sända meddelandet till mottagande server där funktionen finns Figure 4-6. Principle of RPC between a client and server program. Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

20 Remote Procedure Calls (1)
A remote procedure call occurs in the following steps: The client procedure calls the client stub in the normal way. The client stub builds a message and calls the local operating system. The client’s OS sends the message to the remote OS. The remote OS gives the message to the server stub. The server stub unpacks the parameters and calls the server Continued … Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

21 Remote Procedure Calls (2)
A remote procedure call occurs in the following steps (continued): The server does the work and returns the result to the stub. The server stub packs it in a message and calls its local OS. The server’s OS sends the message to the client’s OS. The client’s OS gives the message to the client stub. The stub unpacks the result and returns to the client. Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

22 Passing Value Parameters (1)
Figure 4-7. The steps involved in a doing a remote computation through RPC. parameternedpackning och uppackning = marshalling/unmarshalling kan ta tid att göra I java = serializinge/seralisera objekt; göra dem överförbara över nätet t.ex. tala om hur många byte en integer eller float är, hur de representeras (ebcdic, ascii eller ngn iso-standard) Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

23 Asynchronous RPC (2) Figure (b) The interaction using asynchronous RPC. asynkron rpc Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved

24 Asynchronous RPC (3) Figure A client and server interacting through two asynchronous RPCs. Här: två asynkrona anrnop (ett från klienten, ett från servern)( - t.ex. hämta nätadresser till en mängd klienter först, för ett kommande anrop av dem i ett program; gära andra saker under tiden Detta kallas (figuren) deferred syncrhonous rpc = kombinera två¨asynkrona rpc-anrop - alternativ: klienten kan polla servern om svar har blivit klart än finns även One-way rpc = klienten väntar ej på Accept request från servern i början (kan ge problme om nätet ej är pålitligt; klienten vet ej säkert om begäran har mottagits av servern coh att servern arbetar med den) Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved


Download ppt "Centralized Architectures"

Similar presentations


Ads by Google