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

Feature Flagを利用したリリース戦略

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Feature Flagを利用したリリース戦略

Avatar for kokuyouwind

kokuyouwind

August 08, 2019
Tweet

More Decks by kokuyouwind

Other Decks in Programming

Transcript

  1. FeatureFlag if feature_enabled? process_with_feature else process_without_feature end 1 2 3

    4 5 機能を動的にOn/Off する仕組み 真偽値を返す関数とif ⽂の組み合わせ
  2. FeatureFlag の分類 Feature Toggles (aka Feature Flags) / Pete Hodgson

    https://martinfowler.com/articles/feature-toggles.html
  3. FeatureFlag の分類 Feature Toggles (aka Feature Flags) / Pete Hodgson

    https://martinfowler.com/articles/feature-toggles.html
  4. FeatureFlag の分類 Feature Toggles (aka Feature Flags) / Pete Hodgson

    https://martinfowler.com/articles/feature-toggles.html
  5. FeatureFlag の分類 Feature Toggles (aka Feature Flags) / Pete Hodgson

    https://martinfowler.com/articles/feature-toggles.html
  6. FeatureFlag の分類 Feature Toggles (aka Feature Flags) / Pete Hodgson

    https://martinfowler.com/articles/feature-toggles.html
  7. Misoca でのFeatureFlag Feature Toggles (aka Feature Flags) / Pete Hodgson

    https://martinfowler.com/articles/feature-toggles.html 主にこのへん
  8. 設定と分岐 # initialize Misoca.feature_flag = Misoca::FeatureFlag.new Misoca.feature_flag.add_target( :new_feature, ' なんかすごい新機能'

    ) # use if Misoca.feature_flag.enabled?(:new_feature, curren Misoca::UseCase::NewFeature.new.call else Misoca::UseCase::CurrentFeature.new.call end 1 2 3 4 5 6 7 8 9 10 11 12 13
  9. ユーザごとの有効化 class Misoca::FeatureFlag::Target def enable_for_user(user) redis.sadd(user_key, user.id) end end Misoca.feature_flag.enable_for_user(user)

    1 2 3 4 5 6 7 feature_flag:new_feature:users ( 有効化したユーザid の集合) 42 123456 114514 user id: 123456 redis.sadd 123456
  10. ⽐率での有効化 feature_flag:new_feature:segments ( 有効化したユーザid 下2 桁の集合) 00 12 33 redis.sadd

    04 87 04 87 例: 有効化率を3% から 5% に 元々含まれない 2 桁の数を2 つ選ぶ (3% から5% なので+2) 04 87
  11. ⽐率での有効化 class Misoca::FeatureFlag::Target def enable_percentage(percent) current_segments = redis.smembers(segment_ke unused_segments =

    ALL_SEGMENTS - current_seg diff_percent = percent - current_segments.co diff_percent.positive? ? redis.sadd(segment_key, unused_segments.sample(diff_percent)) : redis.spop(segment_key, diff_percent.abs end end Misoca.feature_flag.enable_percentage(50) 1 2 3 4 5 6 7 8 9 10 11 12 13 14
  12. 有効判定 有効化したユーザid の集合 42 123456 114514 user id: 123456 redis.sismember

    123456 有効化したユーザid 下2 桁の集合 00 12 33 redis.sismember 56 04 87
  13. PDF のS3 キャッシュ PDF ⽣成が重いため、S3 に2 次キャッシュ 初回PDF ⽣成時にS3 へ書き込み

    1 次キャッシュがない場合、S3 から取得 どの程度改善するか⾒積りづらい S3 へのwrite 処理が増える S3 Read の重さによっては改善しない可能性も
  14. PDF のS3 キャッシュ 10% のユーザにリリース→APM で効果測定 PDF Render: 800ms S3

    PUT: 94ms S3 GET(miss): 40ms S3 GET(hit): 72ms ⽣成時に+134ms, 読み込み時に728ms 改善 いける!