本文介绍了客户端 - 服务器同步模式/算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种感觉,必须有客户端 - 服务器同步模式。但我完全没有google上一个。

I have a feeling that there must be client-server synchronization patterns out there. But i totally failed to google up one.

情况很简单 - 服务器是中央节点,多个客户端连接和操纵相同的数据。数据可以在原子中分裂,在冲突的情况下,无论在服务器上,具有优先权(以避免使用户进入冲突解决)。部分同步是首选,因为可能有大量的数据。

Situation is quite simple - server is the central node, that multiple clients connect to and manipulate same data. Data can be split in atoms, in case of conflict, whatever is on server, has priority (to avoid getting user into conflict solving). Partial synchronization is preferred due to potentially large amounts of data.

有这种情况的任何模式/良好做法,或者如果你不知道任何 -

Are there any patterns / good practices for such situation, or if you don't know of any - what would be your approach?

下面是我现在想要解决的问题:
与数据并行,修改日志将被挂起,所有事务都被加上时间戳。
当客户端连接时,它接收自上次检查以来的所有更改,以合并的形式(服务器通过列表删除添加,后跟删除,合并每个原子的更新等)。
Et voila,我们是最新的。

Below is how i now think to solve it:Parallel to data, a modification journal will be held, having all transactions timestamped.When client connects, it receives all changes since last check, in consolidated form (server goes through lists and removes additions that are followed by deletions, merges updates for each atom, etc.).Et voila, we are up to date.

替代方法是保留每个记录的修改日期,而不是执行数据删除,只需将它们标记为已删除。

Alternative would be keeping modification date for each record, and instead of performing data deletes, just mark them as deleted.

任何想法?

推荐答案

变更管理工作。查看SVN,CVS和管理deltas工作的其他存储库。

You should look at how distributed change management works. Look at SVN, CVS and other repositories that manage deltas work.

您有几个用例。


  • 同步更改。您的更改日志(或增量历史)方法看起来不错。客户端将其三角函数发送到服务器;服务器合并并分发delta到客户端。这是典型的情况。数据库称为事务复制。

  • Synchronize changes. Your change-log (or delta history) approach looks good for this. Clients send their deltas to the server; server consolidates and distributes the deltas to the clients. This is the typical case. Databases call this "transaction replication".

客户端已失去同步。通过备份/恢复或由于一个错误。在这种情况下,客户端需要从服务器获取当前状态,而无需通过delta。这是从主人到细节,三角洲和性能的一个副本。这是一次性的事情;客户端崩溃;

Client has lost synchronization. Either through a backup/restore or because of a bug. In this case, the client needs to get the current state from the server without going through the deltas. This is a copy from master to detail, deltas and performance be damned. It's a one-time thing; the client is broken; don't try to optimize this, just implement a reliable copy.

客户端可疑。在这种情况下,您需要将客户端与服务器进行比较,以确定客户端是否是最新的,并且需要任何增量。

Client is suspicious. In this case, you need to compare client against server to determine if the client is up-to-date and needs any deltas.

您应该遵循数据库(和SVN)设计模式,对每个更改进行顺序编号。这样,客户端可以在尝试同步之前发出一个简单的请求(我应该进行什么版本修改?即使这样,查询(自2149年以来的所有增量)对于客户端和服务器都很容易处理。

You should follow the database (and SVN) design pattern of sequentially numbering every change. That way a client can make a trivial request ("What revision should I have?") before attempting to synchronize. And even then, the query ("All deltas since 2149") is delightfully simple for the client and server to process.

这篇关于客户端 - 服务器同步模式/算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:59