Hacker News new | past | comments | ask | show | jobs | submit login

currently my main system in prod is a (very smart) stateless caching system, I don't have a database, but I will eventually spin up a (probably amazon) database, for the web gateway, when the keys to that are handed over to me. One of the nice things is that using elixir really puts you in the mindset of thinking hard about who should have responsibility for "the truth". No hiding behind objects backed by ORMs. State is pushed out as far as possible to the edge and I don't trust my server to keep state correctly. As soon as it's at risk of being inconsistent (netsplit, e.g.) the state-holders in the server are slaughtered, rebooted, and told to reconnect to the edge machines, which are trusted with the truth. The nice thing about elixir is that restart logic costs the the price of like 5-6 lines of code across the entire codebase (no worrying about cleaning up resources like tcp connections or anything).

Not in prod (personal project), I have a websocket-scraper on an aws free tier that's dropping data into a sqlite file, that I can transfer to my laptop for offline processing, so there are lots of interesting options.




This is really interesting to read, I’ve primarily thought about the DB as something which keeps your objects warm. Any recommended sources to read more about this way of treating state?


Haha I dunno, I just came up with it because that seemed like the sensible thing to do. And the virtualization library I use (libvirt) is basically a database anyways. Whenever I've talked with people who know better than I about distributed state (and iot) everyone seems to agree that pushing state management to the edge is the correct strategy in this case. For some things (like tracking customer intent and business logic) where consistency is important, like for you're responsible for someone's $$$, then you want to centralize and really be 100% certain your state is safe, and - I learned this analogy from stephen nunez, who got it from Toyota principles - you want a 'stop the world' lever when things go wrong. To prevent compounding inconsistency.

In crude and probably wrong terms, AP concerns can be more easily pushed to the edge and CP concerns like to be centralized.


When you say push state to the edge, would this be similar to how with the onion architecture you have the domain model in the center but repo access to get data on the outside?

Edit: So as not to have the DB be the ‘core’ of the app?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: