dongma2388 2017-07-03 15:19
浏览 93
已采纳

基本的客户端/服务器体系结构和交互

I'm trying to implement a client and server and define their interactions. The client is designed using Golang, the server is designed in Node.js, and they interact using gRPC.

So the basic gist is:

  1. Client contacts server to update backend DB
  2. Client receives success response from server
  3. Client then itself changes the state of the overall system that the DB now reflects

But say something were to happen such that the process dies between steps 2 and 3 (Client process is terminated somehow). What is the best way to ensure that my backend DB doesn't reflect a system state that is inconsistent with reality? I'm sure this isn't a novel problem and would just like a couple pointers to how people typically cope with this type of design.

So I've already thought of redesigning this interaction such that the server is the entity that will handle the system changes— that way everything is handled in the same request and on the backend— but I'm using an open source technology that is designed in Go (so I can easily wrap it in my Go client). In other words, the client must be the entity that performs that system-change operation.

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • douqian9729 2017-07-03 17:02
    关注
    1. The client ACKs (responds to server) that it has also updated local state to be synchronous with the server.

    If 4. doesn't happen, then the server rolls back the transaction done in 1. and the entire operation of 1 - 4 is atomic.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常