Best erlang memory in cross-network host cache = mnesia?

Morning everyone

I am new to erlang, but I am trying to create my first erlang project to be as good as possible. Here I need some suggestion for an erlang memory system in memory.

  • A cache element is key based storage. the key is usually an ASCII string; value are erlang types, including number / list / tuple / etc.
  • A cache element can be set by any of the node.
  • A cache element can be obtained by any of the node.
  • The cache element is common to all nodes even on different servers.
  • dirty reading is allowed, I do not want a lock or transaction to slow performance.
  • A fully distributed, not centralized machine or service.
  • Good performance
  • Easy installation and deployment, configuration and maintenance

The first choice seems to me mnesia , but I have no experience in it. Does this fit my requirements? How can I expect performance?

Another option is memcached - but I'm afraid that performance is lower than mnesia because extra serialization / deserialization is done because the memcached daemon belongs to a different OS process.

Any suggestion is help :)

+6
source share
1 answer

Yes. Mnesia meets your requirements. However, as you said, a tool is good when someone who uses it understands it in detail. We used mnesia on a distributed authentication system , and so far we have not encountered any problem. When mnesia is used as a cache, it is better than memcached, for one reason "Memcached cannot guarantee that you write, you can read at any time due to memory problems and issues" (follow here ).

However, this means that your distributed system will be built on Erlang. Indeed, mnesia in your case is superior to most NoSQL cache solutions because their systems are Eventually consistent . Mnesia is consistent because network availability can be ensured through the cluster. For a distributed caching system, you donโ€™t need a situation where you read different values โ€‹โ€‹for the same key from different nodes, so the mnesia sequence is convenient here.

Something you should think about is that it is possible to have a centralized memory cache for a distributed system. This works as follows: your RABBITMQ server is running and is available to AMQP clients on each node cluster. Systems communicate through the AMQP interface. Since the cache is centralized, consistency is ensured by the process / system responsible for writing and reading from the cache. Other systems simply place the key request on the AMQP message bus , and the system responsible for the cache receives this message and responds with a value.

We used Message bus Architecture using RABBITMQ for a recent system that included integration with banking systems, an ERP system, and a public online service. What we built was connected to merge all this together, and we are glad that we used RABBITMQ . There are many details, but we did to come up with a message format and a system identification mechanism. All systems must have a RABBITMQ client to write and read messages from the bus. Then you will create a read Queue for each system so that the other system writes its requests to this queue, whose name inside RABBITMQ matches the system that owns it. Then, later, you should encrypt messages passing through the bus. As a result, you have systems connected to each other over a long distance / between states, but with an efficient network you wonโ€™t believe how quickly RABBITMQ connects these systems. Anyway, RABBITMQ can also be grouped, and I must tell you that it is Mnesia , which provides RABBITMQ (which tells you how good mnesia can be).
Another thing is that you need to read and write a lot of programs until you feel comfortable.

+10
source

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


All Articles