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
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










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