Persistency Cluster

Hello,

I am using the persistency library in order to persist a knowledge base. In a production environment, I’d like to have some redundancy, so that, if one instance fails, the other one continues to handle the requests, while the first one is recovered.

Is it possible for multiple instances of a Prolog application to be attached to the same persistency database file? If not, is there another library, or some way to work around that while using the persistency library? For example, by locking the database file at the filesystem level?

Any information is appreciated,
Quenio

You can attach multiple Prolog processes to on db as long as only one writes. The others should call db_sync(update), either regularly or after receiving some notification. For example, on Linux systems you could use inotify to monitor the file change. If you want to use this, allowing multiple systems to write you’ll have to add network communication to find the process in charge of writing and vote a new one in case that node is down.

A more robust approach to sharing data in a cluster is using the bundled Redis library. Then you can also run Redis in cluster mode and realize full redundancy.

1 Like