dojap

dojap

System resources used when using Elixir with MySQL vs PostgreSQL

Have any of you compared MySQL vs PostgreSQL resource usage in your Phoenix app? I would go with Postgres but I am afraid that because my site is mostly about reads (MySQL is better here) and less about writes (Postgres is better here) Postgres would be a bad choice. Also, apparently Postgres is much more RAM hungry and spawns more processes and MySQL can handle more connections with the same amount of RAM.

But this is only stuff I read, I have no real world experience with this.

Have any of you tested both MySQL and Postgres with your Phoenix app? What were the results?

Most Liked

hauleth

hauleth

Their documentation?

And for super simple generator of config that will be “ok enough” you can use PgTune and you can read PG Wiki on tuning.

Also check out this article - Elixir and Postgres: A Rarely Mentioned Problem | Lainblog

dimitarvp

dimitarvp

Consider sqlite then? You won’t need a separate DB server, everything happens right there inside your app, no network connections to DBs. You will only have 1 server – your Elixir application server. You will not have a separate DB server.


As a broader reply to your scaling problems, others are correct. You will hit 1000 other problems before your choice of DB really starts to matter. And let’s be honest here, most businesses never get to that scale.

That, plus modern DBs like PostgreSQL and MySQL have decades of development behind them and are extremely efficient. You should worry how efficient your Elixir code is instead. :slight_smile: And even then, don’t concern yourself with this before your application server starts lagging.

To expand on – and explain in more details – on what @hauleth said: do NOT pick technologies based on which huge company is using them! Reason: they have very specific problems and they have to micromanage their technology choices to hell and back because for them that might mean the difference between paying for 100 servers or 2000 servers, e.g. they might end up paying non-trivial amounts of cash if they misstep. You don’t have that problem.

Don’t pay attention to what Google / Netflix / Amazon / Microsoft / Apple / Uber etc. use. They use those technologies because they solve a very specific problem for them.

Any normal smaller business is very likely to severely shoot themselves in the foot if they just blindly follow a corporation’s tech choices.

And finally, deciding between using PostgreSQL or MySQL is 99% irrelevant because you’re very likely to pick a managed DB instance a la Amazon’s RDS or DigitalOcean’s DB droplets where the pricing completely hides any underlying performance differences like CPU or I/O or RAM usage. Chances are, you will still pay at least $25 a month no matter which DB you pick.


A piece of advice: don’t agonize over such details because even though they might seem important in your head, in practice these details will be trivialized and hidden from you almost everywhere you go (I mean the hosted solutions). Those toy problems are fun to think about when you are a hobbyist – but if you want to make an actual business you should stick to the well-trodden and beaten paths because that hugely increases your chances to get support from the community as you progress with your code. In Elixir’s case, definitely stick with PostgreSQL because that’s Ecto’s first class DB citizen.

But again, for what you describe, it seems that sqlite might actually be the best choice.

hauleth

hauleth

Until you grow to the size, where you will be able to hire someone to handle that for you, then you will probably do not see any difference.

It is hard to tell what will work better in your particular use case, so you will need to do benchmarking on your own. However I think that you will still see no difference, and if so, it will be indistinguishable from noise.

Where Next?

Popular in Questions Top

beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52774 488
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
New

We're in Beta

About us Mission Statement