Download presentation
Presentation is loading. Please wait.
Published byEdith Ford Modified over 9 years ago
1
Tzu-Han Wu15524883 Yi-Chi Chiang54641046 Han-Yang Ou59283702
2
Motivation System overview Basic functions Advanced functions Summary
3
Problems in single server ◦ Non-scalable ◦ Non-durable Solution: Design a seat-booking system in distributed environment ◦ Scalability: Multi-server ◦ Durability: Fully replication
4
Available Temp. Reserved Temp. Occupied Unavailable Reserved Client 1 Client 3 Client 2 Server 1 Server 2
5
Available Temp. Reserved Temp. Occupied Unavailable Reserved
6
Seat information ◦ Status Available Temporary reserved Temporary occupied Unavailable Reserved
7
Seat information ◦ Status Available Reserved The client ID which is processing (Temp. Occupying) ◦ Version To avoid updating old version status ◦ Flag The clients which connected to this server cannot request the seat if the flag is set to true
8
Server list (A list includes servers in the system) ◦ Server ID ◦ Server address ◦ Server load (Main) Number of clients connected to the server. Use for load balancing Client list (A list includes clients connected to it) ◦ Client ID Based on the server ID and sequence number ◦ Client address ◦ A list of seats which the client has requested
9
Request a seat Release a seat Session commit Session abort
10
Reserve an available seat temporary Problem: Several clients request the same seat at the same time ◦ Clients connect to same server Solution: Flag ◦ Clients connect to different servers Solution: Ricart-Agrawala algorithm
11
Client Send request message Server Check the flag of the seat ◦ If the flag is false then set the flag true then continues; else reject the request Send seat request messages to other servers ◦ Continue if gets OK messages from all other servers; otherwise break Set the seat status to client ID and update version Add the seat to the client in the client list Time
12
Client Modify the icon if request successfully Server Send seat status update messages to other servers Send seat status update messages to the clients Time
13
S1 S2 M S3 C101 C102 C202 C204 C205C306 C301 C003 C001 C005 The other server set flag 5 to trueThe other servers send OK to S2 Flag 5: True Assume seat 5 is available C204 send seat 5 request message to S2 Flag 5: false S2 set flag 5 to true S2 send seat request to other server Flag 5: true S2 sends update notification to other serversServers sends update notification to clients
14
Release a seat which is reserved temporary before No mutual exclusion problem
15
Client Send release message Modify the icon if request successfully Server Set the seat status to be available and update version Remove the seat from the client in the client list Set the flag of the seat to false Send seat status update messages to other servers Send seat status update messages to the clients Time
16
S1 S2 M S3 C101 C102 C202 C204 C205C306 C301 C003 C001 C005 Assume seat 7 is occupied by C202 Flag 7: true C202 sends release message to S2S2 sets flag 7 to false Flag 7: false S2 sends update notification to other serversServers send update notifications to clients Flag 7: false Other servers set their flag 7 to false
17
Commit all the seats which are reserved temporary before The client cannot make any modification after commitment No mutual exclusion problem
18
Client Send commit message Modify the icon if request successfully Time Server For each seats of the client in the client list ◦ Set the seat to be reserved and update the version ◦ Send seat status update messages to other servers ◦ Send seat status update messages to the clients Remove the client from the client list Notify main server the load decrease
19
S2 sends seat 2 update notifications messages to other servers S2 sends seat 3 update notifications messages to other servers Servers send seat 2 update notifications to clients S1 S2 M S3 C101 C102 C202 C204 C205C306 C301 C003 C001 C005 Assume C205 has requested seat 2 and 3 Flag 2: true Flag 3: true Flag 2: true Flag 3: true C205 sends commit message to S2Servers send seat 3 update notifications to clients
20
Release all the seats which are reserved temporary before and end the session
21
Add a new server Add a new client
22
Add a server to the system dynamically Get seat status from the main server Problem: Other servers may update seat status at the same time ◦ Solution: status version Compare status version before update
23
New server Connect to main server Query seat status Query server information Server Main server notifies other servers the new coming server Add to its own server list Send seat status Send server information Time
24
S1 S2 M S3 N Notify new server Send other servers info and status of seats Notify other servers new server coming At the same time, the other server may send seat status update messages The new server should compare the version and decide to update or ignore the messages
25
Add a client to the system dynamically Which server should a client connect to? ◦ Strategy 1: All clients connect to the same server Disadvantage: Non-scalable ◦ Strategy 2: Maintain a server list in clients Disadvantage: Inappropriate in the environment which servers join/leave dynamically
26
◦ Strategy 3: Every client connects to the main server first. Main server assigns the client to a server based on round-robin. Advantage: Transparency Disadvantage: The load of the servers may not be balanced ◦ Strategy 4: Every client connects to the main server first. Main server assigns the client to a server based on load of each server. Use number of transactions in each server as load measurement It’s the strategy the we use
27
Client Connect to main server Connect to assigned server Get the client ID Query seat status Server Main server find the server with the lowest load Return the address of that server Generate a client ID to the client Notify main server the load increasing Send seat status Time
28
ID: 103 Connection Request Client address Ask appropriate server S1 S2 M S3 C101 C102 C202 C204 C205C306 C301 C003 C001 C005 N Reply address of S1 C103 Ask status of seats Reply status of seats
29
Client ◦ Show seats status in real-time Server ◦ Multi-server processing in distributed environment ◦ Fully replication ◦ Load balancing ◦ Add servers dynamically Communication ◦ JAVA RMI
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.