How DB connection share state?

Hello, guys!

Thinking about elixir and erlang concepts, I ask myself a question, how elixir handles concurrent DB connections?

Specifically, If erlang VM separates everything into isolated processed, does it mean, that every process, who wants to connect to database, must have their own copy of DB connection state?

Is it really a way? Or it somehow happens via sharing some state (like Agents, for ex.) ?

No, not a copy. Each process that connects separately to the DB has a separate physical connection to it, e.g. host/port pairs like db:1001, db:1002 etc.

From then on job pooling takes over but if you’re more curious you can look into how is Ecto made.

1 Like