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
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
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
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 10 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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
OvermindDL1
I really quite find Benchee a lot more useful nowadays.
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.
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!pmonson711
I would test with epocxy | Hex which already has a ring buffer implemented in ETS.
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?
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
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) …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
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 …