0% found this document useful (0 votes)
8 views5 pages

Algorithms and Issues in Client-Server Design

The document outlines various server algorithms, categorizing them into iterative and concurrent types, each with distinct benefits and challenges. It emphasizes that while iterative servers are simpler to implement, they may lead to delays in handling requests, whereas concurrent servers can manage multiple requests simultaneously but are more complex to design. The choice between connection-oriented (TCP) and connectionless (UDP) protocols is also discussed, highlighting their implications for server performance and reliability.

Uploaded by

prathamesh110773
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Algorithms and Issues in Client-Server Design

The document outlines various server algorithms, categorizing them into iterative and concurrent types, each with distinct benefits and challenges. It emphasizes that while iterative servers are simpler to implement, they may lead to delays in handling requests, whereas concurrent servers can manage multiple requests simultaneously but are more complex to design. The choice between connection-oriented (TCP) and connectionless (UDP) protocols is also discussed, highlighting their implications for server performance and reliability.

Uploaded by

prathamesh110773
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

slide 2

slide 1 gaius
gaius

Server algorithms and their design The basic server algorithm

overview of a server
many ways that a client/server can be designed

conceptually each server follows a simple algorithm:


each different algorithm has various benefits and
problems
it creates a socket
are able to classify these algorithms by looking
binds the socket to a well known port
at the various server differences
loop
accept the next client
the main client/server algorithms can be classified: request from this port
iterative connectionless server serve this request
iterative connection oriented server formulate a reply
concurrent connectionless server send the reply to client
concurrent connection-oriented server end

slide 3 slide 4
gaius gaius

Problems with the simple server? Servers

unfortunately this is only good enough for simple iterative server


applications used to describe a server implementation that
processes one request at a time
consider a service requiring considerable time to
handle each request concurrent server
example suppose an ftp client server were used to describe a server that handles multiple
implemented like this! requests at one time
one user requests a huge file
moments later another user might wish to from a clients perspective
transfer a small file the server appears to communicate with multiple
clients concurrently.
the second user might has to wait a considerable time
just to transfer a small file The term concurrent server refers to whether the
server handles multiple requests concurrently, not to
the second user blocks until the first user has finished whether the underlying implementation uses multiple
with the server. concurrent processes

thus servers are seldom built like this


slide 5 slide 6
gaius gaius

Conclusions Iterative connection oriented servers and


connectionless servers

concurrent servers are more difficult to design and


build choice of transport protocol dictates choise of server
the resulting code is more complex TCP provides a connection-oriented
difficult to modify UDP provides a connectionless service

however most programmers choose concurrent server servers that use TCP are, by definition, connection
implementations as iterative servers oriented
cause unnecessary delays in distributed
applications those that use UDP are connectionless servers
may be a performance bottleneck that effects
many client applications
should also examine the application protocol
because an application protocol designed to use a
Iterative server implementations, which are easier to connection oriented protocol might perform
build and understand, may result in poor incorrectly or inefficiently when using a
performance because they make clients wait for connectionless protocol
service. Whereas in contrast, concurrent server why?
implementations, which are more difficult to build,
yield better performance.

slide 7 slide 8
gaius gaius

Comments on algorithm
create a socket and bind
to the well known address
of the service being offered. a less common server
used for services that require a trivial amount of
put socket into passive mode, making it processing
ready for use by a server it might incur a high overhead in establishing
and terminating connections
loop
accept the next connection
request from the socket,
and obtain a new socket
for the connection

repeat
read a request from
the client,
generate a reply,
send the reply
back to the client
until finished with the client ;
close connection
end
slide 9 slide 10
gaius gaius

Implementation notes Implementation notes

getportbyname accept
use this function to map a particular service onto use this function to obtain the next incoming
a well known port number connection request
need to ensure that our application port number returns the new descriptor of a socket which can
does not conflict with someone else application then be used by read and write
in UNIX all port numbers are defined in
/etc/services close
to close the connection with the client the server
bind uses close.
use this function to bind a socket to a port
number and the servers IP address

listen
the server uses this function to place a socket
into passive mode
it also takes an argument which specifies the
length of request queue for this socket

slide 11
gaius

Iterative connectionless server

iterative servers work best for services that have a


low request processing time
the connection oriented protocol TCP has a high
connection and disconnection overhead
thus most iterative servers use connectionless
protocol such as UDP

create a socket and bind


to a well known address
for which a service is
being offered

loop
read next request from client
process the request
send reply back to client
end

the most common form of connectionless server, used


especially for service that require a trivial amount of
processing for each request
iterative servers are often stateless, making them
easier to understand and less vulnerable to
failures
slide 13 slide 14
gaius gaius

Implementation notes Concurrent connection oriented servers


and connectionless servers

sendto
use this function to send data across a primary reason for introducing concurrency
connectionless socket provide faster response time to multiple clients

recvfrom works well when


use this function to receive data from a forming a response requires significant input
connectionless socket output
the processing time required varies dramatically

slide 15 slide 16
gaius gaius

Comments on the algorithm


create a socket and bind
to the well known address
for the service being offered an uncommon type in which the server creates a new
process to handle each request
leave the socket unconnected note time to create a process may dominate the
added efficiency gained from concurrency
loop
call recvfrom to obtain the
next client request
if (fork() == 0) {
/* child process */
do whatever the
client request says
form a reply and send
it to client
(use sendto)
exit
} else {
/* must be the parent */
}
end
slide 17 slide 18
gaius gaius

Concurrent connection oriented server


create a socket and bind
it to the well known address
for the service being offered
the most general type of server because it offers
reliable transport as well as the ability to handle
place socket into passive mode
multiple requests at the same time
making it ready for use by
note that connection oriented servers implement
the server
concurrency among connections rather than
individual requests
loop
call accept to receive the
next request from a client
if (fork() == 0) {
/* must be the child */
repeat
read request from client
do whatever the client
request says
form a reply and send
it to client
until client wishes to quit
close connection
exit
} else {
/* must be the parent */
}
end

slide 19 slide 20
gaius gaius

When to use each server type Conclusion

iterative vs concurrent only use connectionless transport if the application


iterative easier to design, implement and protocol handles reliability
maintain or the local area network exhibits:
concurrent can provide quicker response to low packet loss
requests no packet reordering (very few do)

use iterative implementation if use connection oriented transport whenever


request processing time is short a wide area network separates client and server
and the code produces fast responses times
never move a connectionless client and server to a
Connection oriented vs connectionless wide area network
connection oriented access means using TCP without checking to see if the application
implies reliable delivery protocol handles the reliability problems
because connectionless transport means using
UDP
it implies unreliable delivery

You might also like