stefanchrobot

stefanchrobot

I’m going through “Elixir in Action” for the second time while I’m working on building my next project. Throughout the chapters, @sasajuric is building a distributed web application which has a process per business entity (to-do list) that synchronizes the access to the resource. The application uses a global process registry to keep track of where each process is. From what I understand, the application is built for availability rather than consistency.

I’m wondering if the same technique could be reliably used for an application built for consistency. In my use case I’m working with a daily timetable and multiple users scheduling events. I have a business requirement that only one event can take place at a time. The requirement is a bit more involved so I’d rather not solve this with a RDBMS constraint especially that I expect the requirements to change in this area. It’s very tempting to solve this with a functional model wrapped with a process as a means for synchronization and consistency.

The more I read about the challenges of distributed solutions the more paranoid I get. When I realized that in some cases it can take over a minute for a node to acknowledge that some other node went down I begin to question if things like :global or Swarm are even usable in my scenario. I have a feeling that I’m getting something like “it’s going to work in 9X% cases”, but at a certain scale those few missing percentages are going to be a pain. And then there’s the issue of deployments: how does :global work with rolling deployments (how does it handle the case of node being stopped but another node forwarding requests to a process inside of it)? Are hot code upgrades the only reasonable solution for distributed systems?

On top of that, I’m going to run my application on Gagalixir, where nodes come and go and there’s a period of time during deployment where there’s always one extra node running which makes it a bit difficult to decide what exactly the quorum is if I were to use one.

With all that being said, it seems that as a general advice it’s best to keep away from clustering nodes and to rely on external synchronization mechanism (RDBMS constraints, explicit RDBMS locks, Redis) if consistency is important. Am I getting this right?

I think that adopting a usual request-response/sync-via-DB approach might work in my case (I can impose a granularity of 15 minutes for event scheduling and use a unique constraint in RDBMS), but I hoped I could leverage some of the Erlang’s features here. If I were to sacrifice some of the consistency for availability, are the any good recipes for this? Should I run some kind of background auditing job that would catch all the inconsistencies?

Are there any resources (books maybe?) about building such systems and how to tackle those challenges?

PS. thanks if you made it this far.

First 2 of 2 Posts Switch mode

keathley

keathley

I’d say that this is correct when it comes to storing important information. If you need consistency don’t try to write your own database.

But not all data in your system is crucial and in those scenarios clustering can be a useful tool. We use distributed erlang for caches and short lived user interactions, among other things. Both techniques are useful when used appropriately.

I wrote about some of these issues here and have given talks on it in the past.

stefanchrobot

stefanchrobot OP

Wow, thanks! Your blog post and the talk touch on exactly the points that I was confused about. Great stuff.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement