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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Hello all. I have a question as to best practices for code organization when implementing a liveview with a lot of responsibilities.
Sup...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
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
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
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
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #processes
- #security
- #api
- #forms
- #performance










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