I would like to know which database you prefer for chat applications?
I do not know if traditional databases are preferable or maybe there is some other option that works well with Elixir / Phoenix?
I would appreciate it if you can share your experience.
In this case it will be a fairly complete and large chat app.
Actually, even though cockroach is very nice, I might still stay with postgres because of postgis (might come in handy if you plan to support location sharing, “users nearby”, “boys from my hood” etc.).
Note: I’ve never written anything more complex than a “hello world.” So you should really just skip to the next answer.
Eh, I’d honestly just use PostgreSQL for all that, it even has very advanced searching abilities that can out do elasticsearch in many cases, all while using the same database so no worry about things getting out of sync. Plus a chat app is mostly write and read with little to no ‘updating’, which is the perfect use-case for PostgreSQL (it flies the less ‘updating’ you do, mostly just reading and writing).
Sure, it’s just that master-master story in postgres is still far from perfect, although postgres can make it far without any need to scale/replicate, but then (in case the chat app is international) I would want to spin up a database server on each continent in an attempt to reduce latency, and that would make postgres a bit harder to operate.
No, they save messages in Mnesia as well. You can send instant messages to people who aren’t online. Once they sign in it will pop them from the db. If I remember correctly I think I saw a talk where they stated the average amount of time a message remained in the db was about 27 minutes.
I think that’s not enough
I would at least add Kafka, Spark, Hadoop, Nifi, NATS, K8s, and Terraform
I would also roll my own implementation of viewstamped replication
I obviously forgot a few things but for initial roll out this should be OK
We are getting very good results with Risk and its integrated SOLR search functions. There is a small delay while SOLR indexes update to the Risk database, but otherwise very scaleable with multiple writers and readers. It really depends on how complex your data model is, and how much traffic you expect. PG will be fine for anything under 1k simultaneous users for sure, and can go higher with effort.
Just a note about using mnesia in 201* https://news.ycombinator.com/item?id=10388488
It might have been an ok decision on whatsapp’s part in 2008, but now there are plenty of much better alternatives, I think. Myself, I would look at what discord guys are using, since they are also doing quite well.
Also, if you watch Rick Reed’s talk from 2012 or 2014, it would seem that mnesia was quite a big pain point for them even back then. I honestly think some of their problems could have been avoided if they had used something like cassandra. Instagram’s team used it well for their little chat.