Qqwy
Mnesia vs Cassandra (vs CouchDB vs ...) - your thoughts?
Looking at the stacks that existing large companies have used, WhatsApp internally uses Mnesia to store the messages, while Discord uses Cassandra.
Also, in the past we’ve had quite a long discussion about ‘When to use Mnesia’ (vs. a traditional relational database), but this was about a year ago, and maybe there have been changes to the Mnesia Ecto bindings or similar?
What I already know:
- Cassandra runs on Java, Mnesia runs inside your BEAM.
- Both are distributed databases.
- Mnesia does not do conflict resolution (although you can write your own, and the packages
unsplitand [reunion](GitHub - snar/reunion: Mnesia partition handler · GitHub exist to do this for you). Cassandra always uses last-write-wins for conflict resolution.
Most Liked
rvirding
No, mnesia has always had the ability to store data on disk. You just specify on which nodes you want disc copies. The only earlier limitation has been that the disk files must not be larger than 2 Gb but you got around this by partitioning your tables.
OvermindDL1
Going with the last few posts, put it all behind a module interface, start with the most basic, which might just be ETS or so in RAM, maybe mnesia later, maybe move to eleveldb or something later, maybe even migrate to PostgreSQL later, all without changing the interface.
dch
I saw your request on the couchdb mailing list, and while it’s “not supported” it’s not very hard to do it either, as this is actually how CouchDB is built internally anyway.
These notes are for 1.7.x which is what I’ve got to hand:
- create your elixir application as usual and compile it
- unpack the release into couchdb plugins dir (or
/usr/local/lib/couchdb/erlang/lib/...) for whatever your OS uses - add a
[daemons]section to yourlocal.iniconfig withmyapp={'Elixir.MyApp', start_link, []}which will ensure it gets started up as part of the main supervision tree of couch - set ERL_FLAGS environment variable to use
-config /usr/local/etc/couchdb/sys.configto get your custom application settings loaded up - look through https://github.com/apache/couchdb/tree/master/src/couch_plugins which has some useful comments and source snippets
I’m reasonably sure this is complete, and while the complexities of 2.x series with cluster support make this moire complicated, the guts of that should remain the same.
At some point, somebody will decide to put a nice tidy shim in between the chttpd “clustered httpd” layer that exposes the soft erlang underbelly of couchdb, and then you’d have native erlang terms accessible to Elixir as well. There are a few not-so-handwavey details to deal with - no maps yet as couch uses proplists (no maps at the time in Erlang, and to support some quirks of JSON), things like structs have no way of being converted back to JSON at the http layer, and a bunch of valid BEAM types that would need to be cleaned when turning them into JSON again etc etc, once the shim is available.
The big issue is that releases for a clustered db are a serious thing, and we tend to update and restart our apps far more often than our DBs. If you’re already co-locating the DB and the app on the same server, only the JSON encoding & recoding is the bottleneck.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









