Does it make sense to use Zookeeper to store user rights

I am writing a distributed application with several node interfaces that should reject an action for the user if they are not part of the list.

Currently, we have more than 4 of these encoded, but only one database server running DB2, which is often unavailable for maintenance.

Now we are conducting a database survey to update the list in memory, so that if the user is removed from the list, the change is reflected in all 4 nodes. But if one of the nodes reboots when the database is down, we get an empty list that will reject the entire user request that we don’t want. We can accept a request from the user, even if the database does not work, when we buffer them in the message queue, but we want to reject them immediately if they should be rejected!

Does it make sense to run a Zookeeper instance on each of our 4 nodes and save user permissions in Zookeeper. Thus, reading should be fast and data highly accessible and consistent. We will no longer need to do polls, and even if we reload the database, node will be able to get its configuration from zookeeper!

+6
source share
1 answer

Yes, the way you described your problem, Zookeeper should fit the bill perfectly. There are several questions, although this must be answered:

  • How much data are we talking about? Zookeeper saves data on disk, but only works if the data matches RAM.

  • How often do the data change? Zookeeper guarantees that more than half of the sites received the update, so the records are not entirely efficient.

  • How much data do you need to read at once? Zookeeper has a 1 MB response size limit, but their recommendation is that the data be well below this limit. Note that this restriction can also be achieved if you list a node with a large number of children, since the names of the children are considered data.

Considering that the data is served from RAM, reading it should not be a big problem, but you can always cache the results and set local data on invalid data on the corresponding nodes.

+10
source

Source: https://habr.com/ru/post/899991/


All Articles