简体   繁体   English

通过文件系统窗口跨多台计算机同步多个进程

[英]Synchronize multiple processes across multiple machines through file system windows

I'm writing an application, which receives some packages over the network and then some client receives these packages from this application. 我正在编写一个应用程序,该应用程序通过网络接收一些软件包,然后一些客户端从此应用程序接收这些软件包。 Now I would like to make the architecture scalable. 现在,我想使体系结构可扩展。 Packages are stored temporarily on file system until they are received by consumer application. 程序包临时存储在文件系统上,直到被消费者应用程序接收到为止。 If I store ready to send packages in some folder I need some way to distinguish packages, which are being processed, from packages, which are still waiting to be processed. 如果我准备将要发送的程序包存储在某个文件夹中,则需要某种方式来区分正在处理的程序包和仍在等待处理的程序包。 The idea is to create special lock file in package folder and keep it locked until package transfer is completed (on completion delete this lock file and the package folder itself). 这个想法是在程序包文件夹中创建特殊的锁定文件,并保持锁定状态,直到程序包传输完成为止(完成后删除此锁定文件和程序包文件夹本身)。 The alternative ideas are to use some kind of shared resource (for example, message queue or database). 替代方案是使用某种共享资源(例如,消息队列或数据库)。 The question is whether using the file system for this kind of interprocess communication safe enough? 问题是使用文件系统进行这种进程间通信是否足够安全?

You can use any medium to store your data (it will end up in the filesystem one way or the other, anyways). 您可以使用任何介质来存储您的数据(无论哪种方式,它最终都将存储在文件系统中)。 Main question you should probably ask yourself is what functionality you want to have at hand: it might be quite problematic to scale raw files, it might be hard to implement layers of security (role-based access, for example), etc. 您可能应该问自己的主要问题是您想拥有什么功能:扩展原始文件可能会遇到很多问题,可能难以实现安全性层(例如,基于角色的访问)等。

Seems like your case is nicely solved by RabbitMQ as it provides versatile queuing mechanism as well as persistence and scalability. RabbitMQ似乎可以很好地解决您的情况,因为它提供了通用的排队机制以及持久性和可伸缩性。 I don't know details of your project, but I'd advice to look at Redis for similar functionality plus ability to modify objects in the "queue". 我不知道您的项目的详细信息,但是我建议您查看Redis的类似功能以及在“队列”中修改对象的功能。

In any case, file-based storage might be a good idea to experiment with (create MVP), but I'd advice against it in the future. 无论如何,基于文件的存储可能是尝试(创建MVP)的一个好主意,但我建议将来不要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM