简体   繁体   English

数据从MySQL同步到NoSQL键值存储

[英]Data sync from MySQL to NoSQL key-value store

I am having a legacy system with the MySQL at the backend and python as the primary programming language. 我有一个后端为MySQL的旧系统,而python为主要编程语言。

Recently we have a scenario where we need to display a dashboard with the information present in the MySQL database. 最近,我们有一个场景,需要显示一个仪表板以及MySQL数据库中存在的信息。 The data in the table changes every second. 表中的数据每秒更改一次。

This can be thought of similar to a bid application where people bid constantly. 可以认为这类似于人们不断出价的出价应用程序。 Every time a user bids a record goes in to the database. 每次用户出价记录时,都会进入数据库。 When an user updates his bid it updates the previous value. 用户更新出价时,它会更新以前的值。

I also have few clients who monitor this dashboard which updates the statistics. 我也很少有客户监视此仪表板,该仪表板会更新统计信息。

  • I need to order this data in realtime as people bid in real time. 当人们实时出价时,我需要实时订购这些数据。
  • I don't prefer to run queries against MySQL because at any second I may have few 1000 clients querying the database. 我不喜欢对MySQL运行查询,因为在任何时候我可能只有几千个客户端在查询数据库。 This will create load on database. 这将在数​​据库上创建负载。

Please advice. 请指教。

If you need to collect and order data in realtime you should be looking at the atomic ordered map and ordered list operations in Aerospike. 如果需要实时收集和订购数据,则应查看Aerospike中的原子有序地图有序列表操作。

I have examples of using KV-ordered maps at rbotzer/aerospike-cdt-examples . 我在rbotzer / aerospike-cdt-examples上有使用KV顺序映射的示例

You could use a similar approach with the user's ID being the key, the bid being a list with the structure [1343, { foo: bar, ts: 1234, this: that} ] . 您可以使用类似的方法,将用户ID作为密钥,将出价作为具有[1343, { foo: bar, ts: 1234, this: that} ]结构的列表。 The bid amount in cents (integer) is the first element of the list, all the other information is in a map in the second element position. 以磅(整数)为单位的出价金额是列表的第一个元素,所有其他信息都位于第二个元素位置的地图中。

This will allow you to update a user bid with a single map operation, get back the user's bid with a single operation, order by rank (on the bid amount) to get the top bids ordered, get all the bids in a particular range, etc. You would have one record per item, with all the bids in this KV-sorted map. 这样一来,您就可以通过一次地图操作来更新用户出价,通过一次操作来获取用户出价,按排名(按出价金额排序)来获得所订购的最高出价,并获得特定范围内的所有出价,等等。您将在每个项目中有一条记录,并且所有出价在此KV分类的地图中。

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

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