开发者

client failure detection in client-server systems (distributed)

Assume a distributed communication system where client and server communicate via a stateless channel.

The client sends requests to the server and the server does processing and keeps internal records for each client.

Server sends back notifications to the clients as various events happen to the system, as needed.

The notification mechanism depends on the internal records.

My question is, what is the standard appoach in distributed computing to handle the client failures?

I.e. in this context, assume that the client process crashes or simply restarts. The server still has the records for the client but now client and server are of sync. As a result client will get notifications according to records created before restart. This is undesirable.

What is a standardized way to detect the client failures? E.g. client has restarted and previous records must be erased?

I thought of periodic开发者_JAVA百科 callbacks to clients and if a client is not reachable, erase its records but I am not sure if this is a good idea. [EDIT] I thought of callbacks because, the period events send back to the client can be in very large intervals and so the client failure would not be noticable soon

Can anyone help on this? The context of my application domain is web services.

Thank you!


The standard approach varies from system to system depending to the architecture and domain. How the server finds out that the client is down? I think you don't need callbacks, since you send the notifications and can detect that the client is unreachable. For example:

  1. send a notification to the client;
  2. if success, goto 1;
  3. else erase all the notifications in the queue for the client, set a flag to not collect events for the client.

When a client is connected:

  1. unset the flag;
  2. start sending notifications

Or even a simpler approach:

  1. erase the notification queue for the client when it connects before initializing the conversation;
  2. run a low-priority thread to erase all the notifications for all the clients which are older then X, to clean notifications for the client which will never come back.

Update after the original author comments

It strongly depends on how things are organized in your system. Assuming:

  1. The server starts a thread (let's call it "agent") to serve a client, a thread per client.
  2. The agent exits when the clients shuts down the session properly or goes down.
  3. there is a private (which is not shared among agents/clients) record set for each client
  4. there is a shared list of current clients which is used by another component (not an ordinary agent, let's call it "dispatcher") to distribute records for clients.

solution: 1. the server starts an agent and registers the client just connected to list of clients. The dispatcher gets notified that a new client arrived. 2. the agent consumes the records until client is connected. On client's shutdown and/or failure the agents unregisters the client and cleans the record set.

If things in your system aren't organized in the way described above, please provide some details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜