如何分析MongoDB中的数据流量?
数据流量是 MongoDB Atlas 集群中的主要成本驱动因素。能够按集合名称甚至查询类型细分流量可以帮助识别导致高数据流量的低效查询和操作,作为优化它们的第一步。
根据 MongoDB Atlas 支持(截至 2022 年 3 月),目前除了集群节点之外,没有任何本地方法可以通过任何来分解数据流量。因此,解决方案只能位于客户端的某个位置,在我的具体情况下,服务器使用 MongoDB Node.js 驱动程序向 MongoDB Atlas 集群发出请求。
显而易见的方法是在 MongoDB Node.js 驱动程序之上构建一个层来记录所有发送和接收的请求数据的数据大小并从中计算指标。
但是,发出请求的服务器在 AWS 中的 EC2 实例上的 Node.js 环境中运行,因此我想知道是否有更优雅的方法使用 AWS CloudWatch?挑战在于,需要根据 MongoDB 集合和 MongoDB 查询类型对请求进行细分,这是在请求正文中编码的信息,而不是 URL。
Data traffic is a major cost driver in a MongoDB Atlas cluster. Being able to break down traffic by collection name or even query type could help to identify inefficient queries and operations that cause high data traffic as a first step to optimize them.
According to MongoDB Atlas support (as of March 2022) there is currently no native way to break down data traffic by anything other than a cluster node. So the solution can only be somewhere on the client side, in my specific case the server that uses the MongoDB Node.js driver on make requests to the MongoDB Atlas cluster.
The obvious approach would be to build a layer on top of the MongoDB Node.js driver to log the data sizes for all sent and received request data and calculate the metrics from that.
However, the server that is making the requests runs in a Node.js environment on a EC2 instance in AWS, so I wonder whether there is a more elegant approach using AWS CloudWatch? The challenge is that the requests need to be broken down per MongoDB collection and MongoDB query type, which is information that is encoded in the request body, not the URL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论