Homemade Analytics with Ecto and Elixir
dashbit.co
dashbit.co
Testing it (especially with async integration/e2e tests, which I prefer) would be tricky, I'd want some tests to verify that the "GenServer write cache" is more or less counting correctly under some (potentially stressful) scenarios that I can stress out by having other things run in the VM.
From what's presented, I'm not sure yet how to get this to work with distribution, in the case that you would want to drop this into a distributed phoenix setting. Do you start the pages :global instead of registered? Do you start a Registry with :global, and have the cluster restart it if vm that hosts it dies?
The testing story from Elixir is relatively straight-forward too. I send a bunch of requests and then ask the supervisor to shutdown, which forces all processes to terminate and perform their pending writes.
Perfect! thank you for clarifying. Or maybe i should have read it more carefully.
> The testing story
I keep forgetting ExUnit's start_supervised! exists.
1) The `bump` function interacts with the worker GenServers via `send(pid, :bump)` and the GenServer has a `handle_info` for that. I would normally add a client function to the worker module which uses a `GenServer.call(...)` instead. Was that just to make the blog post a bit shorter, or are there tradeoffs I'm missing?
2) In the case of millions of pages, the post suggests terminating the processes. What about `hibernate`? Could that be an intermediate approach to reach for, for some relatively large number of pages?
2) Good call on hibernate. It could definitely be an option to consider on all implementations.