The ultimate sequential mnesia database with erlang. Best practics?

I am writing a bittorrent tracker in erlang. Given the nature of the service, I do not need absolute consistency (i.e., the Client can be completely satisfied with a slightly outdated peer list or torrent status).

My strategy so far has been to create mnesia tables in RAM with disc_copies enabled, so that mnesia automatically deletes disk memory when the log size exceeds a certain size.

If the server crashes, some information will be lost. Not really.

Another approach would be to indicate two tables (only one drum and only one disk) and to have a copy of the process from ram to disk every minute or so. This is more naive, but it allows you to reset only part of what is in memory, reducing the total load on the disk and possibly avoiding the use of the log at all (I'm not really sure about this last statement).

I am sure there are many other ways to do this. What's yours

-teo

+5
source share
3 answers

You can check redis and erldis . Redis uses a second approach: everything is stored in memory, and then periodically flushed to disk.

+2
source

This, of course, is off topic regarding your original question, but if you are really writing a clean tracker, it is best to refuse persistence and save the data exclusively in memory.

For a minimal tracker, the announcement only weighs a few bytes: 16 bytes for the SHA1 hash, 6 bytes for the peer IP port and port, and a few more bytes, since you also need to save the time stamp, But even with a little overhead, you can literally store millions records in memory.

+1
source

All Articles