How do you deal the database while deploying your enterprise Phoenix application?

While deploying your elixir/phoenix applications, do you make only one database server, or multiple database servers? Do you keep all the database in one place (replicated/single-server), or do you divide different tables on different machines? Do you shard the tables or not? Do you use Mnesia instead of MySQL and Postgres? Does using Mnesia make it easier to deploy the application in distributed way? Does Mnesia makes it easier to scale database? Will Cassandra server better/worse with elixir than Mnesia? How would you make Postgresql as scalable with elixir as Mnesia?

These are too many questions, please reply any or all the question.

Thank you!

1 Like

While deploying your elixir/phoenix applications, do you make only one database server, or multiple database servers?

Depends on use case.

Do you keep all the database in one place (replicated/single-server), or do you divide different tables on different machines?

Depends on use case, but in almost all the cases a single-server SQL database is enough.

Do you shard the tables or not?

Depends on use case, but no, this would be one of the last resorts from my point of view.

Do you use Mnesia instead of MySQL and Postgres?

Depends on use case, but no. I don’t see mnesia as a replacement for SQL databases. Perhaps only for small embedded systems where you want to ship your product without external dependencies. Mnesia can be complementary to them being used as a cache or session database or other custom storage.

Does using Mnesia make it easier to deploy the application in distributed way?

No. Well it depends. Comparing to setting up a multi-master SQL database and you are hosting mnesia yourself and have experience with it, mnesia is easier. Otherwise other distributed databases are much easier to setup than mnesia,.

Does Mnesia makes it easier to scale database?

Depends what you compare it to and your requirements. It may be easier than scaling a SQL database, but if you need lots of nodes other NoSQL databases are easier to scale in my opinion.

Will Cassandra server better/worse with elixir than Mnesia?

Depends on use case. Cassandra will most likely be easier to scale and operate than mnesia, but you can’t really beat mnesia for speed in a read heavy situation. Write heavy loads are more problematic to scale in mnesia without customizing your application.

How would you make Postgresql as scalable with elixir as Mnesia?

You scale it vertically until it it seems like there is a problem. Then you seriously analyze your use-case and come up with a custom solution to address the problems. If you still need to scale beyond that you will likely have resources to deal with it :smiley:

In any case, for most applications the core business logic is in a SQL database of some sort. Postgres or MySQL. Sometimes you have complementary databases for things like caching and sessions (mnesia, redis, memcached) or statistics and logs (time serie databases).

This setup will get you really far. If you grow further than this you need to seriously think about performance and solutions for your specific use case. I don’t think there can be any general advice here.

One last thing. If you are shipping your application to customers rather than maintaining it yourself I recommend using mainstream technologies as much as possible. Mnesia is great, but it can require hands on maintenance requiring knowledge or erlang/elixir, especially if you need to scale and distribute it amongst several nodes. And even more so if you need to fragment the tables.

2 Likes