elie
Hi,
My first post here! I’m very new to Elixir and Phoenix (coming from the Meteor community).
I understand that Phoenix is great for real time apps (such as chat). Does the database need to be real time? How does Phoenix observe changes in real time to a PostgreSQL database (which I understand is the default for Phoenix apps)? And what sort of delay can you expect, if any?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Qqwy
Yes, Phoenix is great for applications where you want to use a persistent, two-way connection between server and client, where both the client and the server can keep sending updates to each other without needing to reconnect each time. This is what indeed enables ‘real time’ applications.
When building things like a chat application, each time someone posts a message, Phoenix will forward this message to all other open connections (that are part of the given context, i.e. chat room). The database is no part of this.
Because connections are persistent, Phoenix does not need to look at the database when a new request comes in. Instead, the database is only used to log what happened, so someone that connects at a later moment is able to see what took place.
So, because all of this is happening in memory, with the database being only an observer of the changes that happen, this kind of communication is ridiculously fast. What sort of delay you can expect is of course highly dependent on the needs of your specific application, but you might like to take a look at this benchmark, which shows that Phoenix can handle two million persistent connections on a single server with a non-trivial application without a problem.
elie
So based on this, does it matter at all what sort of database you use with Elixir?
I’m also wondering, wouldn’t this mean that Elixir needs an enormous amount of RAM for large applications? It basically has to hold the entire database in memory in a lot of cases no?
OvermindDL1
No, as in your DB holds persistent data, but anything that needs to be broadcasted out to existingly connected users can be done so immediately, and when a new user connects you can send them what they are missing.
elie
So would a real time database like RethinkDB add anything to an Elixir application?
Also, with the chat room example, let’s say we have 1000 chatrooms, would it be possible to have 2 Elixir instances each in charge of 500 rooms? And how does this sort of thing happen?
OvermindDL1
It can simplify some code but honestly not really.
Elixir/Erlang could handle a lot more than that in a single instance, but yes, Elixir/Erlang can distribute across a ‘mesh’ of nodes across computers to slave out work, and yes the Phoenix pubsub system supports it fantastically (built for it).
brightball
You can also do this with PG though even though you don’t need to for your use case. Postgres LISTEN/NOTIFY will allow outside processes like your elixir application to be notified when certain things happen in the database. I believe there is a library called Boltun that makes it pretty dang simple.
https://github.com/bitgamma/boltun