1 / 81

ITEC801 Distributed Systems

ITEC801 Distributed Systems. Client-Server Liu Chapter 5. Important Things. Understanding of basic client server model That client-server can be both connection-oriented and connectionless Have looked at some example code. Client-Server.

lana
Download Presentation

ITEC801 Distributed Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITEC801Distributed Systems Client-Server Liu Chapter 5

  2. Important Things • Understanding of basic client server model • That client-server can be both connection-oriented and connectionless • Have looked at some example code Client-Server

  3. Client-Server • most prevalent model for distributed computing protocols • it is service-oriented, and employs a request-response protocol Client-Server

  4. Client-Server • an overloaded term • Client-Server system architecture • the terms clients and servers refer to computers • Client hosts make use of services provided on a server host • Client-Server computing paradigm • the terms clients and servers refer to processes • Client processes (objects) make use of a service provided by a server process (object) running on a server host Client-Server

  5. Client-Server Server host Client host … Server request Client process Server process Service Client-Server

  6. Client-Server Client host Server host note server may be contacted by multiple clients … Client-Server

  7. Client-Server Server host Client host and a client may contact multiple servers Client-Server

  8. Example - Napster Client-Server

  9. Applications and Services • On the Internet, many services are client-server applications. • These services are often known by the protocol that the application implements. • For example HTTP, FTP, DNS, finger, gopher, etc. • User applications may also be built using the client-server paradigm. • Most well known Internet protocols are client-server, request-response, and text-based. Client-Server

  10. Session • session refers to the interaction between the server and one client. • The service managed by a server may be accessed by multiple clients, sometimes concurrently. • Each client engages in a separate session with the server Client-Server

  11. Service Session Start Service Accept a client’s request for a session Conduct a session with the client Client-Server

  12. Locating the Service • A mechanism must be available to allow a client process to locate a server • A service can be located by • host name and • Server process protocol port number • This is the scheme for Internet services. Client-Server

  13. Locating Server • Each Internet service is assigned to a specific port number. • In particular, a well-known service such as ftp, HTTP, or telnet is assigned a default port number reserved on each Internet host for that service. Client-Server

  14. Locating Server • At a higher level of abstraction, a service may be identified using a logical name registered with a registry • the logical name will need to be mapped to the physical location of the server process. • If the mapping is performed at runtime then it service’s location may be dynamic Client-Server

  15. Protocol Examples • client and server programs must adhere to protocol specification for the service • Daytime service [RFC867]: • Client: Hello, <client address> here. May I have a timestamp please. • Server: Here it is: (time stamp follows) Client-Server

  16. Protocol Examples • World Wide Web session: • Client: Hello, <client address> here. • Server: Okay. I am a web server and speaks protocol HTTP1.0. • Client: Great, please get me the web page index.html at the root of your document tree. • Server: Okay, here’s what’s in the page: (contents follows). Client-Server

  17. Multiple Servers • Services may be implemented as several server processes • the processes interact as necessary to provide the service • the necessary objects may be partitioned between the servers • the objects may be replicated across the servers Client-Server

  18. Multiple Servers Service Server Client Server Client Server Client-Server

  19. Client-Server • How clear should be the distinction between client and server? • Some systems make it very clear • clients and servers cannot run on the same machine • sometimes the platform for each is different • in others the same machine, even the same process, can be both a client and a server Client-Server

  20. Application Layering • We can distinguish different functionality within a client-server system • Distinction at three levels advocated: • User-Interface level: Interacts with user. • Processing level: Core functionality of application. • Data level: Operated on database/file system Client-Server

  21. User Interface • Directly interfaces with the user • implemented by a client • Interfaces range from the simple to the sophisticated Client-Server

  22. Processing Level • Contains the core functionality of application. • Examples • search engine • Decision support system for stock brokerage Client-Server

  23. Data Level • Contains programs that maintain the actual data on which applications operate • data is persistent • Also responsible for keeping data consistent across different applications. • Can be implemented as a file system or database Client-Server

  24. Layering Example User Interface User-interface level HTML page containing list Keyword Expression HTML Generator Ranked list of page titles Query Generator Processing level Ranking Component Database Queries Web page titles with meta-information Data level Client-Server

  25. Client-Server Architectures User Interface User Interface User Interface User Interface User Interface Application Application Application Database User Interface Application Application Application Database Database Database Database Database Client-Server

  26. Proxy Servers and Caches • A cache is a store of recently used data that is “closer” than the actual objects • when another data object is accessed it is added to the store • proxy servers allow clients to access the proxy’s cache • we will see many other uses of caches Client-Server

  27. Proxy Server Client Server Proxy Server Client Server Client-Server

  28. Callback • client server model • the server is passive: • IPC is initiated by the client • server waits for the arrival of requests and provides responses Client-Server

  29. Callback • Some applications require the server to initiate communication upon certain events. • Examples • monitoring • games • auctioning • voting/polling • chat-room • message/bulletin board • groupware Client-Server

  30. Outline • Clients register with server • Event types they want notification of • Clients provide means for server to call them • Server calls client on event occurence Client-Server

  31. Polling vs. Callback • What if communication does not support callback • Eg., client can’t be called • a client will have to repeatedly poll a passive server if it needs to be notified that an event has occurred at the server end. Client-Server

  32. Polling vs. Callback Polling Callback Server Server … Client Client Client repeatedly issues a request to the server until the desired response is obtained Client registers itself with the server and waits un til the server calls back Client-Server

  33. Two-way communications • Some applications require that both sides may initiate IPC. • Using sockets, duplex communication can be achieved by using two sockets on either side. • With connection-oriented sockets, each side acts as both a client and a server. Client-Server

  34. Callback Process 1 Process 2 request response request response Client-Server

  35. Connections • A client-server application can be either connection-oriented or connectionless. Client-Server

  36. Connectionless Server • No setup • A connectionless server • accepts one request at a time from any client • processes the request • sends the response to the requestor. Client-Server

  37. Connection-Oriented Server • server accepts one connection at a time. • client issues connection request, and waits for its connection to be accepted. • Once a server accepts a connection, it waits for a request from the client. • When a client is connected to the server, it issues a request and waits for the response. Client-Server

  38. Connection-Oriented Server • server receives request, processes it and sends response • then waits for the next request, if any. • The client receives the response and processes it. • If the client issues are further requests, the process repeats itself Client-Server

  39. Basic Connection-Oriented Client-Server Model Server host Client process at head of connection queue server process Server connection queue service Client process connected to server Client-Server

  40. Concurrent, Connection-Oriented Server • A basic connection-oriented server services one client at a time. • duration of client session may be significant, • latency or turnaround time of a client request may be unacceptable due to waiting • To improve the latency can use threads or child processes • a server process spawns a child process or thread to process the protocol for each client. • Such a server is termed a concurrent server, compared to an iterative server. Client-Server

  41. Concurrent, connection-oriented server • A concurrent server uses its main thread to accept connections • spawns a child thread to process the request of each client. • Clients queue for connection, then are served concurrently • concurrency significantly reduces latency Client-Server

  42. Concurrent, connection-oriented server Server host Client process at head of connection queue concurrent server process Main thread accepts connection Server connection queue service child thread processes each client request Client process whose connection has been accepted Client process whose connection has been accepted Client-Server

  43. Connectionless vs. connection-oriented server • A connectionless server • Uses a connectionless IPC API (e.g., connectionless datagram socket) • Sessions with concurrent clients can be interleaved. • A connection-oriented server • Uses a connection-oriented IPC API (e.g. stream-mode socket ) • Sessions with concurrent clients can only be sequential unless the server is threaded Client-Server

  44. Daytime Protocol client server m1 m2 Data representation: text (character strings) m1: null message – any contents will be ignored m2: contains a timestamp, in a format such as Tue Aug 24 18:30:48 2004 Client-Server

  45. Daytime Example 1 • Client – Liu pages 142-144 • Server – Liu pages 146-148 • Connectionless – uses Datagram Socket • Notice client and server classes use other classes • hides the details of the application logic and the underlying service logic. • Programmers of the upper layers need not be aware of which socket types is used for the IPC.  Client-Server

  46. UML Diagram - Client presentation logic DaytimeClient1 DatagramPacket DaytimeClientHelper1 MyClientDatagram Socket DatagramSocket sendMessage ( ) receiveMessage ( ) Client-Server application logic

  47. UML Diagram - Server DatagramPacket DatagramMessage presentation + application logic DaytimeServer1 MyServerDatagram Socket DatagramSocket sendMessage ( ) receiveMessage ( ) receiveMessageAnd Sender( ) service logic Client-Server

  48. DaytimeClient1.java import java.io.*; /**contains presentation logic of a DaytimeClient*/ public class DaytimeClient1 { public static void main (String[] args) { InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); try { System.out.println(“Welcome to the Daytime Client.\n” + “what is the name of the server host?”); String hostname = br.readline( ); if (hostName.length() == 0) hostName = “localhost” Client-Server

  49. DaytimeClient1.java System.out.println(“What is the port number of the server host?”); String portnum = br.readline(); if (portnum.length == 0) portnum = “13”; System.out.println(“Here is the timestamp received from the server” + DaytimeClientHelper1.getTimeStamp (hostname,portnum); } // end try catch (Exception ex) { ex.printStackTrace(); } //end catch } //end main } //end class Client-Server

  50. DaytimeClientHelper1.java import java.net.*; /**contains application logic of a DaytimeClient*/ public class DaytimeClientHelper1 { public static String getTimeStamp (String hostName, String portNum) { String timestamp = “”; try { InetAddress serverHost = InetAddress.getbyname(hostName); int serverPort = Integer.parseInt(portNum); MyDatagramSocket mySocket = new MyDatagramSocket(); mySocket.sendMessage(serverHost, serverPort, “”); timestamp = mySocket.receiveMessage(); mySocket.close(); } //end try Client-Server

More Related