Server software design Algorithms and Issues Chuan-Ming LIu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN CSIE NTUT Taiwan
1 CSIE, NTUT, Taiwan Server Software Design Algorithms and Issues Chuan-Ming Liu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN
●。 Conceptual Server Algorithm o Simple server Algorithm 1. Create a socket 2. Bind the socket to the port 3. Enter an infinite loop Accept request Process request Reply request o Not enough in practice generall SIE, NTUT, Taiwan
2 CSIE, NTUT, Taiwan Conceptual Server Algorithm Simple Server Algorithm 1. Create a socket 2. Bind the socket to the port 3. Enter an infinite loop • Accept request • Process request • Reply request Not enough in practice generally
●。 Conceptual Server Algorithm o Consider file transfer first client needs a 200 Mb file o Second client needs a 20 byte file If the server processes them in Fifo fashion The second client will wait an unreasonable amount of time for a small transfer Server usually handles more than one request at a time SIE, NTUT, Taiwan
3 CSIE, NTUT, Taiwan Conceptual Server Algorithm Consider file transfer ⚫ First client needs a 200 MB file ⚫ Second client needs a 20 byte file ⚫ If the server processes them in FIFO fashion The second client will wait an unreasonable amount of time for a small transfer Server usually handles more than one request at a time
。。 Concurrent vs. Iterative o Iterative server: one request at a time o Concurrent server: multiple requests at one time o Note: the concurrency is conceptual and generally will use one thread for one request o Concurrent server refers to whether the server permits multiple requests to proceed concurrently, not whether the underlying implementation uses multiple and concurrent threads 4 CSIE. NTUT. Taiwan
4 CSIE, NTUT, Taiwan Concurrent v.s. Iterative Iterative server: one request at a time Concurrent server: multiple requests at one time Note: the concurrency is conceptual and generally will use one thread for one request Concurrent server refers to whether the server permits multiple requests to proceed concurrently, not whether the underlying implementation uses multiple and concurrent threads
●。 Concurrent vs. Iterative o Concurrent servers are difficult to design and build o Why concurrency? o Long delay caused by iterative servers o Performance bottleneck resulted from iterative servers effects many clients 5 SIE NTUT. Taiwan
5 CSIE, NTUT, Taiwan Concurrent v.s. Iterative Concurrent servers are difficult to design and build Why concurrency? ⚫ Long delay caused by iterative servers ⚫ Performance bottleneck resulted from iterative servers effects many clients
●。 Connection Access or not o Two major transport protocols o TCP(Transmission Control protocol) UDP (USer Datagram Protocol) o tCP is connection-oriented and udp is connectionless o The corresponding servers are o Connection-oriented servers o Connectionless serves 6 SIE, NTUT, Taiwan
6 CSIE, NTUT, Taiwan Connection Access or Not Two major transport protocols: ⚫ TCP (Transmission Control Protocol) ⚫ UDP (User Datagram Protocol) TCP is connection-oriented and UDP is connectionless The corresponding servers are ⚫ Connection-oriented servers ⚫ Connectionless serves
●。 TCP Semantics o Point-to-point communication o Reliable connection establishment o Reliable delivery o Flow controlled transfer o Full-duplex transfer o Stream paradigm SIE, NTUT, Taiwan
7 CSIE, NTUT, Taiwan TCP Semantics Point-to-point communication Reliable connection establishment Reliable Delivery Flow controlled transfer Full-duplex transfer Stream paradigm
●。 UPD Semantics o Many-to-many communication o Unreliable service o Lack of flow control o Message paradigm SIE, NTUT, Taiwan
8 CSIE, NTUT, Taiwan UPD Semantics Many-to-many communication Unreliable Service Lack of flow control Message paradigm
TCP or UDP o Because the semantics of TcP and UDP differ sharply, a designer cannot choose between connection-oriented and connectionless transport protocols without considering the semantics required by the application protocol o Depends on the applications, not the pes SIE, NTUT, Taiwan
9 CSIE, NTUT, Taiwan TCP or UDP? Because the semantics of TCP and UDP differ sharply, a designer cannot choose between connection-oriented and connectionless transport protocols without considering the semantics required by the application protocol Depends on the applications, not the types
●。 Connection- Oriented servers o Easier to program since tCP provide all the reliabili o Drawbacks o Need a separate socket for each connection o cares about the socket allocation and resource consuming o Resource limitation problem-due to the clients crash often 10 SIE, NTUT, Taiwan
10 CSIE, NTUT, Taiwan Connection-Oriented Servers Easier to program since TCP provide all the reliability Drawbacks: ⚫ Need a separate socket for each connection ⚫ Cares about the socket allocation and resource consuming ⚫ Resource limitation problem – due to the clients crash often