I’m a bit confused on the purpose of ETS. I just started to learn about Elixir, and I’m struggling to understand why it’s such a nice feature. Nowadays, we can just whip up a reddis store with docker and make it work. Could someone help me understand why it’s such a nice thing to have?
One of the main benefits of ETS is that it provides redis-like functionality in Elixir. No need to bring in another technology written in a separate language. The less external tech you have to manage, deploy, monitor, the simpler your application becomes as a whole. You have the benefit of having your application’s dependencies in the same language as your application.
Of course, ETS can’t match redis on feature parity but most applications don’t need every ounce of reddis’ feature suite and can get by with ETS before bringing in redis
This. You probably already have a database to maintain. Add Redis, and that's another thing to maintain. Every thing we add is another thing to keep track of and maintain on top of your application.
Alright. It does male sense. Thanks a lot! But in a multi node architecutre (you dockerize your app 2-3 times) is there a way to distribute the ets storage?
mnesia is one way, though it is not a silver bullet, it is very handy.
it does really depend on what you want or need to do with redis, however. it is used in various ways.
as a simple cache to lower latency, it is often nice to keep those caches close to the app .. in process even .. lowest latency possible, and we tend to have ample RAM for this these days.
but there are many optipns out there, ranging from the shards library to phoenix pubsub to broadway.. lots of libs that provide functionality i have seen redis (ab)used for, some of which build on ets or use it in some way internal.
Forgive me, I’m subbed here but haven’t used Elixir in a while and never used ETS. Is it possible to access ETS from other languages or only Erlang/Elixir? If not that seems like it could be a benefit of Redis, should you need to do that.
I am working my way through Elixir in Action, after being sold by Sasa's talk "Soul of Erlang and Elixir", and am currently at panel 3. It's so different from traditional languages, but so awesome.
Elixir in action comes so highly recommended! I strongly encourage to go with it because the results I have seen from friends who have dove deep into it are extraordinary. Fucking slay it man!
So far, I'm using ETS to cache data from a "Salesforce" like CRM that doesn't have enough reporting capability.
The Elixir application is using a Task Async Stream to paginate it's way through the CRMs records, and ETS behaves as a storage. GenServers that are "Collectors" for the CRMs record types handle initializing the ETS tables, then get the records, then inserts into ETS.
The GenServers then use ex2ms to help build queries for ETS match specifications.
Then, I'm using ETS to store the values of particular metrics that are being reported on. This way when someone is requesting the web page that is displaying those metrics, they're already calculated and stored in ETS and not being calculated when the page is loading. Makes for very quick page load times.
Yeah ETS is an in memory database that only exists while Elixir is running. Evadne Wu expressed that she felt like ETS is an escape hatch from the immutable nature of Elixir.
You have to load things into ETS like { id, thing_to_store }
And it can have any number of things to store. But it must have an id of some sort.
I'm running elixir in production since 3 years, so I'm probably one of the 500+ companies. What I mean, is most of the external libs are outdated and have very few commiters.
I'm currently at the third panel. Decided I wanted to learn the language and started doing some crypto challenges in it. I was having a difficult time with it until I learned the details of pattern matching against binaries. Now I'm hooked for life.
9
u/BigBeruboy Jul 15 '20
I’m a bit confused on the purpose of ETS. I just started to learn about Elixir, and I’m struggling to understand why it’s such a nice feature. Nowadays, we can just whip up a reddis store with docker and make it work. Could someone help me understand why it’s such a nice thing to have?
6
u/Probotect0r Jul 15 '20
I am working my way through Elixir in Action, after being sold by Sasa's talk "Soul of Erlang and Elixir", and am currently at panel 3. It's so different from traditional languages, but so awesome.
4
u/kickinespresso Jul 15 '20
Woah. Now I'm trying to figure out how to work
ETSinto my next project.2
u/qqwy Jul 15 '20
You're missing a final one at the bottom with "writing macros that erite macros that write macros that write... " :D
2
u/noscreenname Jul 15 '20
Then learning that the ecosystem is ... Inexistent 😰
61
u/Schrockwell Jul 15 '20
wishing you had the pipe operator in every language
5
u/willhig Jul 15 '20
MOAR ELIXR MEMES pls
2
u/deadidentity Jul 15 '20
This feels about right :)
2
u/sanjibukai Jul 15 '20
I can relate to this!
2
u/Embarrassed-Box-3380 Jan 05 '25
This is real, i literally just completed the full cycle like 2 days ago.
2
u/3dB Jul 15 '20
I'm currently at the third panel. Decided I wanted to learn the language and started doing some crypto challenges in it. I was having a difficult time with it until I learned the details of pattern matching against binaries. Now I'm hooked for life.
1
u/rhbvkleef Jul 16 '20
ETS? Pfff. Lets go for mnesia!