0
9.5kviews
Explain Stateful and Stateless servers.

Similar questions

1) Justify the needs of Stateful and Stateless server in RPC management.

2) What is the difference between stateful and stateless server implementation models? Give examples of distributed applications using each of the implementation models.

1 Answer
0
283views

Stateful Servers

  • Client’s state information from one RPC to the other is maintained within a Stateful server.
  • When two subsequent calls are made by a client to the Stateful servers, some state information of the service performed for the client is stored by server process, which is used at while executing the next call.

In a server for byte stream files the following operations take place:

i. Open (filename, mode): This operation opens a file named filename in the specified mode. An entry for this file in file table is created which maintains file state information. When file is opened R/W pointer is set to zero and the client receives the file Fid.

ii. Read (Fid, m, buffer): This operation gets m bytes of data from the Fid file into the buffer. When this operation is executed the client receives m bytes of file data starting from the byte addressed by R/W pointer and then the pointer is incremented by m.

iii. Write (Fid, m, buffer): When this operation is executed, m bytes of data are taken from the specified buffer and writes it into the Fid file at byte position which is addressed by the W/R pointer and then increments the pointer by m.

iv. Seek (Fid, position): This operation changes the value of read-write pointer of the file Fid to a new value specified as position.

v. Close (Fid): This operation is used to delete file state information of the file Fid from its file-table.

Example of Stateful file server

Example of Stateful file server

  • For the above diagram after opening a file if a client makes to subsequent Read(Fid,10,buffer) calls, the first call will return first 10 bytes(0-9) and the second call will return the next 10 bytes(10-19)

ii. Stateless Servers - Stateless servers do not maintain any client information. - Every request from a client is accompanied with parameters that are needed for an operation.

For a byte stream file server the operations for a file to be stateless are:

i. Read (filename, position, m, buffer): For this operation the server returns to the client with m bytes of data of the file identified as filename and saves it in the buffer. The value of the bytes is returned to the client and the position for reading is specified as position parameter.

ii. Write (filename, position, m, buffer): This operation takes m bytes of data from the buffer and writes it into the file named filename. The position to start writing in the file is specified by position parameter.

Example of Stateless file server

Example of Stateless file server

  • In the diagram the file server does not keep track of any file state information resulting from a previous operation. If a client makes two subsequent Read calls then the operation will be Read (filename, 0, 10, buffer), Read (filename, 10, 10, buffer).

In this the client has kept track of file state information.

  • Stateful servers provide an easier programming paradigm and are more efficient than stateless servers. Stateless servers have a distinct advantage over stateful servers in the event of a failure.
  • With stateful servers, if a crashes and restarts later, the state information that it was holding may be lost and the client process might continue its task unaware of the crash. Stateless servers can be constructed around repeatable operations that make crash recovery easy.
Please log in to add an answer.