idi527
How would one store a time series (updates in “real time”) with elixir/erlang? I’m getting some market data over a socket and would like to know how would you guys decide to store it efficiently. Ideally, I would also like to run some rolling calculations (not sure if it’s how it called, I want to apply some aggregation over some pre-scpecified time period (like for the last minute)) on the incoming data.
It’s not a real project, it’s just for a hobby. So I would like to just use erlang/elixir tools, and not reach out for leveldb or anything like that.
Found this discussion on using mnesia for storing time series data Mnesia not suitable for time series storage?, but even mnesia seems like overkill to me.
Trending in Questions
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
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
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
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
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
I think I just need to keep a list of a fixed length in process’s memory. So that when the new data comes in, that last element gets removed from the list and the new data gets put in the head of the list.
Don’t know how to do that without pointers … Will look into how
:queuemodule works.Something like this maybe. Don’t like all these calls to
:lists.reverse…Seems to work. But also seems hacky …
kip
When I researching into this topic a while back I thought to use ETS ordered sets. Basically use the ordered set with a counter like
{n, payload}and monotonically increasen. Then you can use:ets.next/1for access. But of course then you need a sweeper to delete the head of the set on some kind of regular basis. Or managenpredefined slots in an ordered set and manage the read and write “pointers” manually.I also tried the list-based approach you describe above but it does involve a lot of list copying on pretty much each update. I never finished up my experiments so I have no useful data to offer.
idi527
Wrote a simple benchmark
history to listis a bit too slow … Maybe I can run rolling calculations on the{new, old}tuple and forgo converting this tuple to list.Will try
:etsapproach next. Thanks for the idea, @kip! I’m afraid though, that it would also introduce extra copying (frometsinto the process) …mbuhot
Can you amortize the cost of popping the old items from the list by allowing the list to grow up to 2x the desired size, then calling
Enum.taketo keep the required prefix?idi527
But that would require me to check the length of the list at least sometimes, which is also a pricey operation (unless done via pattern matching? But that would require a macro). Or have I misunderstood what you meant?
pmonson711
I would test with epocxy | Hex which already has a ring buffer implemented in ETS.
idi527
With
:etswith using the following unfinished (doesn’t delete stale values) codeis much slower than the naive list implementation above …
Couldn’t use Benchfella with
:ets, so had to turn to:timer.tcwhereas using
for the list implementation:
Will try
:epocxynow, thank you, @pmonson711!oboudry
You may be interested in riak-ts, an open source NoSQL database optimized for time-series and written in Erlang.
Riak TS
I’ve not used it myself yet but it looks interesting for logging time series data.
OvermindDL1
I really quite find Benchee a lot more useful nowadays.
Qqwy
A couple of months ago, I was working on something that exactly keeps track of things like market data, where you have a sliding window of datapoints that you want to aggregate in possibly multiple ways.
The code was uploaded to Github; it’s not yet on Hexpm because it is still a little bare-bones (although there are tests!).
.
Actually, the tests might be the best explanation as to how it works
https://github.com/Qqwy/elixir_sliding_window