3 ms·
It is what it is. It's useful to prototype with in Erlang. It may be useful to ship with. If Mnesia turns out not to fit your problem, here in 2015, you've got
by jerf 11y ago
It is what it is. It's useful to prototype with in Erlang. It may be useful to ship with. If Mnesia turns out not to fit your problem, here in 2015, you've got literally dozens of choices of alternate DB, with all sorts of consistency and distributibility and performance characteristics.
My guess is that if somehow Erlang was where it was in 2015 except it didn't have Mnesia, nobody would really perceive much of a hole there, and nobody would write it, because of the database explosion we've seen in the past 10 years. But it is there, and if it works for you, go for it.
My only slight suggestion is that rather than inlining all your mnesia calls, you ought to isolate them into a separate module or modules or something with an interface. But, that's not really because of Mnesia... I tend to recommend that anyhow. In pattern terms, I pretty much always recommend wrapping a Facade around your data store access, if for no other reason than how easy it makes your testing if you can drop in alternate implementations. And then, if mnesia... no, wait... And then, if $DATABASE turns out to be unsuitable, you're not stuck up a creek without a paddle. With this approach it's not even all that hard to try out multiple alternatives before settling on something.
- wcummings 11y ago>My only slight suggestion is that rather than inlining all your mnesia calls, you ought to isolate them into a separate module or modules or something with an interface. But, that's not really because of Mnesia... I tend to recommend that anyhow. +1 also nice to have a module per-table because you can have a behaviour for your mnesia tables so that things like initializing tables are standardized (i.e. they all export `init([node()]) -> ok | error').
- jerf 11y agoYes. To explain to others, it's easy to miss how dynamic Erlang is if you don't study the syntax, but generally, where ever you see a module or a function, you're actually using atoms, and they can be freely substituted by variables containing atoms. Eshell V5.10.1 (abort with ^G) 1> lists:reverse([1,2,3]). [3,2,1] 2> L = lists. lists 3> R = reverse. reverse 4> L:R([1,2,3]). [3,2,1] This makes it easy to iterate through lists of modules, calling an init function on them, or generally treating modules generically. It is, I think, perhaps less powerful than Python's capabilities, but it can still take you a long ways, and save you a lot of code.
- seiji 11y agomnesia is great in isolation with bounded datasets. erlang is great for operational observability of both the data flow and your application. they go great together, sometimes, if you know all your requirements up front. It's always good to keep in mind erlang+mensia were designed to run in a "network" consisting of a unified blade chassis (each blade is a new node, and the network is a physical backplane). So, things like network partitions around erlang distribution and remote mensia tables don't have easy/proper error recovery strategies. Even with unbounded datasets, mensia is great if you devote an engineering team to managing the scaling of it because amnesia can't do simple things like move a DB from one node to another without semi-advanced erlang+mnesia knowledge. But, whatsapp was (is?) 100% mensia last I recall, even though they had to reengineer some of it: http://www.erlang-factory.com/upload/presentations/558/efsf2012-whatsapp-scaling.pdf http://www.erlang-factory.com/upload/presentations/558/efsf2... But, mensia still relies on dets and dets still, in 2015, has a 2 GB max file size. If your data grows beyond 2 GB, you have to do mnesia fragmentation which is just an operational burden. My scaling thoughts tend towards: sqlite -> postgres -> riak
- toast0 11y agoIf you can fit all your data in ram, you can use disk_copies, which doesn't use sets. schema is always disk_only_copies, but if it gets to be 2gb, wow! Edit to add: Adding nodes isn't that hard? Connect to dist, add to extra copies of schema table, then the tables that you want. More complex if you're trying to merge together different sets of tables into one schema though.
- seiji 11y agoEdit to add: Adding nodes isn't that hard? Adding nodes isn't hard, but try restoring a mnesia table from service@node1 to service@node2. You have to do something like http://stackoverflow.com/questions/463400/how-to-rename-the-node-running-a-mnesia-database http://stackoverflow.com/questions/463400/how-to-rename-the-... It's not a great solution for modern AWS-style API-driven-deployment operational models.
- 11y ago