Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Feature Flags

Feature Flags

A 15 minute presentation given at PyCon 2014 as part of the Advanced Django Patterns workshop http://lanyrd.com/2014/pycon/scxqhp/ describing feature flags, how we rolled our own at Lanyrd and how Eventbrite use Gargoyle.

Simon Willison

April 10, 2014
Tweet

More Decks by Simon Willison

Other Decks in Programming

Transcript

  1. class FeatureFlag(Model):! slug = SlugField(unique = True)! description = CharField(max_length

    = 140)! enabled_for_all = BooleanField(default = False)! users = ManyToManyField(User)!
  2. class FeatureFlag(Model):! slug = SlugField(unique = True)! description = CharField(max_length

    = 140)! enabled_for_all = BooleanField(default = False)! users = ManyToManyField(User)! groups = ManyToManyField(Group)
  3. In read_only_mode • Prevent logged-in user actions • Auth middleware

    ignores user cookie • Mobile app APIs ignore user token • Shows the banner and hide the “sign in” link
  4. • User / Staff • Event • Organizer • API

    key • Country • IP address (or range) • eventbrite.com v.s. .de v.s. .fr
  5. class RequestCountry(ConditionSet):! country = String(label='Country')! def can_execute(self, instance):! return isinstance(instance,

    (HttpRequest,))! ! def get_field_value(self, request, field_name):! if field_name == 'country':! return getattr(request, 'country')! ! gargoyle.register(RequestCountry())
  6. Gargoyle performance • Switch = DB row with JSON blob

    of conditions • Caches switches in local memory AND remote cache • At Eventbrite, we run memcached on every frontend server to reduce network traffic
  7. • Use feature flags, not long-lived branches! • The ROI

    on feature flags is ridiculous • Try Gargoyle (or Gutter), or roll your own