简体   繁体   English

使用ArangoDB时,复制架构会有所帮助

[英]Replication architecture help when using ArangoDB

In my quest to solve the 1000's of clients, each with individual ArangoDB's, recording individual information as something is running…We need to aggregate this information back to a collection in a singular Master Node server so that queries and reports can be made on it. 在我寻求解决1000个客户端的过程中,每个客户端都有单独的ArangoDB,在运行某些内容时记录个人信息......我们需要将这些信息聚合回单个主节点服务器中的集合,以便可以在其上进行查询和报告。 Looking into the power of JavaScript and actions within ArangoDB… Is this possible and fast enough to 'replicate' data back to the Master Node.. 研究ArangoDB中JavaScript和动作的强大功能......这是否可行且足够快,可以将数据“复制”回主节点。

1) Local run data is being logged on each client 1)每个客户端上都记录了本地运行数据

2) An action trigger is executed (let's take the holy crap scenario first, no bulk uploading or anything)…for each insert, take the locally inserted data and make that exact request to the Master Node for insertion into the common collection (the document data stored on each client has properties that uniquely identify it etc). 2)执行动作触发器(让我们首先采取神圣的废话场景,不进行批量上传或任何事情)...对于每个插入,获取本地插入的数据并向主节点发出确切的请求以插入公共集合(文档存储在每个客户端上的数据具有唯一标识它的属性等。

3) This would effectively 'replicate'/aggregate each client's unique data to the single Master Node collection. 3)这将有效地“复制”/聚合每个客户端的唯一数据到单个主节点集合。

Thoughts? 思考?

Thanks, 谢谢,

Ken

An initial thought on this: 最初想到这个:

You could wrap insert / update / delete operations to a specific collection(s) in an API of your own. 您可以将插入/更新/删除操作包装到您自己的API中的特定集合中。 Instead of using the regular HTTP POST, PUT/PATCH, DELETE routes that ArangoDB provides for documents, you can write your own routes inside ArangoDB. 而不是使用ArangoDB为文档提供的常规HTTP POST,PUT / PATCH,DELETE路由,您可以在ArangoDB中编写自己的路由。 ArangoDB has a framework, Foxx, to do this. ArangoDB有一个框架Foxx来做这件事。

For example, you may create your own insert route. 例如,您可以创建自己的插入路径。 Inside the route, you can execute any sort of JavaScript code. 在路线内,您可以执行任何类型的JavaScript代码。 For example, here is a simple insert wrapper that justs inserts data into a collection mydata: 例如,这是一个简单的插入包装器,只是将数据插入到集合mydata中:

controller.post('/my-insert', function (req, res) {
  var document = req.body();

  try {
    var result = db.mydata.save(doc);
    // TODO: send off data to external server etc.

    res.json(result); // send back result to original client
  }
  catch (err) {
    // TODO: handle and report error
  }
});

In the above example, data is stored in a local collection and the response is sent back to the client. 在上面的示例中,数据存储在本地集合中,并将响应发送回客户端。 However, you may execute extra JavaScript code after the save operation. 但是,您可以在保存操作后执行额外的JavaScript代码。 So you may actually send data to another server from there. 所以你实际上可以从那里向另一台服务器发送数据。

You may do the same for the update and delete routes. 您可以对更新和删除路由执行相同操作。 This solution requires that all your operations use the custom routes, and you don't modify data using the regular document APIs. 此解决方案要求所有操作都使用自定义路由,并且不使用常规文档API修改数据。 Using the regular APIs would still work of course, but won't fire off the custom actions. 使用常规API当然仍然有效,但不会触发自定义操作。

The interesting questions are if you can accept the thread blocking on the "send to another server call" and what you would do if sending data to another server fails for whatever reason. 有趣的问题是,如果您可以接受“发送到另一个服务器调用”的线程阻塞,并且如果由于某种原因将数据发送到另一个服务器,您会怎么做。

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

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