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

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
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
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43806 214
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
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
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

We're in Beta

About us Mission Statement