danschultzer
Simple feature flags in Elixir
I wrote a post on how to implement a feature flag system and A/B testing in an Elixir app with no need for third-party services or libraries. I used this system in production with a relatively large platform.
I’m also getting into what I think is some pitfalls of A/B testing and what mindset we should have when building products, with this quote in mind:
When a measure becomes a target, it ceases to be a good measure
Most Liked
aicost_tools
Rolling your own flags makes sense to me: a table plus a cached lookup covers most of what teams pay a SaaS for. I’d push the Goodhart point one step further for AI features, where an A/B test can happily optimise engagement while the per-request cost quietly climbs, so I like seeing cost per user right next to the conversion metric. Do you store assignments per user, or hash user ids on the fly?
danschultzer
Yes, I have been in companies that used feature flags through mixpanel and lanchdarkly, but in both cases it was used so lightly that it really didn’t make sense to me why it was not just hand rolled (which is what I then did for another company).
This is also why I haven’t had the need to cache the feature assignments. Instead of depending on a third-party API where I need to think about caching them, I can calculate them on the fly instantly. I think even if the feature flags were loaded from the db it would still be minimal perf penalty to do it on the fly. The only scenario I can think of where storing them per user makes sense would maybe be in an edge case where I need to guarantee that the features are exactly what they were calculated at a specific time.
Missing the increase in cost per user while optimizing for an engagement metric is a great one.
Popular Backend topics
Other popular topics
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /java
- /clojure
- /typescript
- /emacs
- /haskell
- /svelte
- /onivim
- /kotlin
- /react
- /c-plus-plus
- /crystal
- /tailwind
- /gleam
- /ocaml
- /elm
- /vscode
- /flutter
- /html
- /deepseek
- /ash
- /zig
- /opensuse
- /php
- /centos
- /react-native
- /scala
- /lisp
- /textmate
- /sublime-text
- /nixos
- /debian
- /agda
- /deno
- /django
- /nodejs
- /kubuntu
- /arch-linux
- /ubuntu
- /spring
- /revery
- /manjaro
- /quarkus
- /julia
- /lua
- /diversity
- /laravel









