使用Zookeeper存储用户权限有意义吗
我正在编写一个涉及多个前端节点的分布式应用程序,这些前端节点需要拒绝用户的操作,除非它们是列表的一部分。
现在我们有超过 4 个节点,但只有一个数据库服务器运行 DB2,而且经常停机进行维护。
现在,我们正在轮询数据库以更新内存列表,这样如果从列表中删除用户,更改就会反映到所有 4 个节点。但是,如果在数据库关闭时重新启动其中一个节点,我们最终会得到一个空列表,该列表将拒绝我们不想要的所有用户请求。即使数据库关闭,我们也可以接受用户的请求,因为我们将它们缓冲在消息队列中,但如果需要拒绝它们,我们希望立即拒绝它们!
在我们的 4 个节点上每个运行一个 Zookeeper 实例并将用户权限存储在 Zookeeper 中是否有意义。因此,读取速度应该很快,并且数据高度可用且一致。我们不必再进行轮询,即使我们重新启动数据库,节点也将能够从 Zookeeper 获取其配置!
I am writing a distributed application involving several front-end node that need to deny action to the user unless they are part of a list.
Right now we have more then 4 of those noded but only a single database server running DB2 which is often down for maintenance.
Right now we are polling the database to update an in memory list so that if a user is removed from the list the change get reflected to all 4 nodes. But if one of the node is rebooted while the database is down we would end up with an empty list which will deny all user request which we dont want. We can accept request from user even if the database is down as we buffer them in a message-queue but we want to reject them immediatly if they need to be rejected!
Does it make sense to run a Zookeeper instance on each of our 4 node and store the user permission in Zookeeper. Reading should thus be fast and the data highly available and consitent. We would not have to do polling anymore and even if we restart the database the node will be able to get their config from zookeeper!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,按照您描述问题的方式,Zookeeper 应该完全符合要求。不过,有几个问题需要回答:
我们谈论的是多少数据?Zookeeper 将数据保存到磁盘,但仅在数据适合 RAM 时才工作。
数据多久更改一次?Zookeeper 将确保一半以上的节点收到更新,因此写入性能不高。
一次应读取多少数据?Zookeeper 的响应大小有 1MB 的限制,但他们的建议是将数据保持在远低于该限制的水平。请注意,如果您列出具有大量子节点的节点,也可能会达到此限制,因为子节点名称算作数据。
考虑到数据是从 RAM 提供的,读取数据应该不是什么大问题,但您始终可以缓存结果,并在适当的节点上设置监视以使本地数据无效。
Yes, the way you've described your problem, Zookeeper should fit the bill perfectly. There are few questions though that needs to be answered:
How much data are we talking about? Zookeeper persists data to disk, but works only if data fits RAM.
How often is data changed? Zookeeper will assure that more than half nodes received the update, so writes aren't exactly performant.
How much data should be read at once? Zookeeper has limit of 1MB response size, but their recommendation is to keep data well below that limit. Note that this limit can also be reached if you are listing a node with lots of children, as children names count as data.
Considering that data is served from RAM, reading it shouldn't be much of a problem, but you can always cache results, and set watch on appropriate nodes to invalidate local data.