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

Chanko

 Chanko

This slide I present in RailsConf2012 is describes how COOKPAD safely releases
multiple feature prototypes - in production -
for test segments of their 15 million engaged users.

http://github.com/cookpad/chanko

Kenta Murata

April 26, 2012
Tweet

More Decks by Kenta Murata

Other Decks in Programming

Transcript

  1. Chanko
    How COOKPAD safely releases
    multiple feature prototypes - in production -
    for test segments of their 15 million engaged users
    @mrkn (Kenta Murata), @shingo (Shingo Morita)
    http://www.flickr.com/photos/june29/3396011694/
    1
    12೥4݄26೔໦༵೔

    View Slide

  2. Kenta Murata
    • CRuby committer
    • bigdecimal maintainer
    • OS X platform maintainer
    • Ruby Sapporo
    @mrkn
    http://www.flickr.com/photos/recompile_net/5951998279/
    2
    12೥4݄26೔໦༵೔

    View Slide

  3. 3
    12೥4݄26೔໦༵೔

    View Slide

  4. http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  5. http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  6. Data
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  7. Data
    Monthly unique users: 15 M
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  8. Data
    Monthly unique users: 15 M
    Monthly page views: 500 M
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  9. Data
    Monthly unique users: 15 M
    Monthly page views: 500 M
    Engineers: 40
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  10. Data
    Monthly unique users: 15 M
    Monthly page views: 500 M
    Engineers: 40
    System
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  11. Data
    Monthly unique users: 15 M
    Monthly page views: 500 M
    Engineers: 40
    System
    Ruby: Ruby Enterprise Edition
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  12. Data
    Monthly unique users: 15 M
    Monthly page views: 500 M
    Engineers: 40
    System
    Ruby: Ruby Enterprise Edition
    Rails: 3.0
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  13. Data
    Monthly unique users: 15 M
    Monthly page views: 500 M
    Engineers: 40
    System
    Ruby: Ruby Enterprise Edition
    Rails: 3.0
    Platform: AWS
    http://cookpad.com/
    4
    12೥4݄26೔໦༵೔

    View Slide

  14. Chanko
    http://www.flickr.com/photos/june29/3396011694/
    5
    12೥4݄26೔໦༵೔

    View Slide

  15. •Overview
    •Demonstration
    •Usage
    •Chanko in COOKPAD
    Topics
    6
    12೥4݄26೔໦༵೔

    View Slide

  16. OVERVIEW
    7
    12೥4݄26೔໦༵೔

    View Slide

  17. IDEA
    BUILD
    USER INTERVIEW
    USER TEST
    LEARN
    Public release
    In the office
    Before Chanko
    http://www.flickr.com/photos/13963375@N00/138745886/
    8
    12೥4݄26೔໦༵೔

    View Slide

  18. Persona Method
    User interview
    User test
    9
    12೥4݄26೔໦༵೔

    View Slide

  19. Persona Method
    User interview
    User test
    9
    12೥4݄26೔໦༵೔

    View Slide

  20. After Chanko
    IDEA
    BUILD
    Limited release
    IDEA
    MEASURE
    Public release
    RELEASE
    http://photozou.jp/photo/show/606813/95100763 http://photozou.jp/photo/show/276167/58451178
    BUILD
    LEARN
    10
    12೥4݄26೔໦༵೔

    View Slide

  21. Implement Bomb
    11
    12೥4݄26೔໦༵೔

    View Slide

  22. Three Requirements
    12
    12೥4݄26೔໦༵೔

    View Slide

  23. http://www.flickr.com/photos/ficablok38/5216979355/
    Stability
    13
    12೥4݄26೔໦༵೔

    View Slide

  24. http://www.flickr.com/photos/boojee/29777131/
    14
    12೥4݄26೔໦༵೔

    View Slide

  25. Faster Development
    http://digimaga.net/uploads/2010/02/neet-that-typing-speed-is-the-japans-fastest01.jpg
    15
    12೥4݄26೔໦༵೔

    View Slide

  26. Three Requirements
    Stability
    Quality
    Faster Development
    16
    12೥4݄26೔໦༵೔

    View Slide

  27. Chanko
    https://github.com/cookpad/chanko
    17
    12೥4݄26೔໦༵೔

    View Slide

  28. What can Chanko do?
    18
    12೥4݄26೔໦༵೔

    View Slide

  29. What can Chanko do?
    18
    12೥4݄26೔໦༵೔

    View Slide

  30. What can Chanko do?
    19
    12೥4݄26೔໦༵೔

    View Slide

  31. What can Chanko do?
    NoMethodError:
    private method `sub'
    called for nil:NilClass
    19
    12೥4݄26೔໦༵೔

    View Slide

  32. What can Chanko do?
    NoMethodError:
    private method `sub'
    called for nil:NilClass
    19
    12೥4݄26೔໦༵೔

    View Slide

  33. Generating unit
    RAILS_ROOT:$ rails generate chanko new_search_btn
    create app/units/new_search_btn/new_search_btn.
    create app/units/new_search_btn/views/_show.htm
    create app/units/new_search_btn/specs/controlle
    create app/units/new_search_btn/specs/models/ne
    create app/units/new_search_btn/specs/helpers/n
    create app/units/new_search_btn/stylesheets/new
    create app/units/new_search_btn/javascripts/new
    create app/assets/javascripts/units/new_search_
    create app/units/new_search_btn/images/logo.png
    create app/assets/images/units/new_search_btn
    20
    12೥4݄26೔໦༵೔

    View Slide

  34. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    21
    12೥4݄26೔໦༵೔

    View Slide

  35. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    Chanko Unit
    21
    12೥4݄26೔໦༵೔

    View Slide

  36. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    22
    12೥4݄26೔໦༵೔

    View Slide

  37. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    Unit Script
    22
    12೥4݄26೔໦༵೔

    View Slide

  38. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    Unit Script
    Unit script consists of extensions for:
    • Models
    • Controllers
    • Helpers
    • Views
    22
    12೥4݄26೔໦༵೔

    View Slide

  39. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    23
    12೥4݄26೔໦༵೔

    View Slide

  40. Files and Folders
    app/units/new_search_btn/new_search_btn.rb
    /images/
    /javascripts/
    /specs/
    /stylesheets/
    /views/
    Other stuff
    23
    12೥4݄26೔໦༵೔

    View Slide

  41. Implementing a unit
    # app/units/new_search_btn/new_search_btn.rb
    module NewSearchBtn
    include Chanko::Unit
    active_if do |context, opts|
    context.current_user.staff?
    end
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    end
    24
    12೥4݄26೔໦༵೔

    View Slide

  42. Implementing a unit
    # app/units/new_search_btn/new_search_btn.rb
    module NewSearchBtn
    include Chanko::Unit
    active_if do |context, opts|
    context.current_user.staff?
    end
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    end
    active_if do |context, opts|
    context.current_user.staff?
    end
    25
    12೥4݄26೔໦༵೔

    View Slide

  43. Implementing a unit
    # app/units/new_search_btn/new_search_btn.rb
    module NewSearchBtn
    include Chanko::Unit
    active_if do |context, opts|
    context.current_user.staff?
    end
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    end
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    26
    12೥4݄26೔໦༵೔

    View Slide

  44. Invoking a function
    # app/views/recipes/_header.html.haml
    = render ‘recipes/search’
    27
    12೥4݄26೔໦༵೔

    View Slide

  45. Invoking a function
    # app/views/recipes/_header.html.haml
    = invoke(:new_search_btn, :search_btn) do
    = render ‘recipes/search’
    28
    12೥4݄26೔໦༵೔

    View Slide

  46. Invoking a function
    # app/views/recipes/_header.html.haml
    = invoke(:new_search_btn, :search_btn) do
    = render ‘recipes/search’
    # app/units/new_search_btn/new_search_btn.rb
    module NewSearchBtn
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    end
    28
    12೥4݄26೔໦༵೔

    View Slide

  47. Invoking a function
    # app/views/recipes/_header.html.haml
    = invoke(:new_search_btn, :search_btn) do
    = render ‘recipes/search’
    # app/units/new_search_btn/new_search_btn.rb
    module NewSearchBtn
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    end
    NewSearchBtn
    :search_btn
    :new_search_btn :search_btn
    29
    12೥4݄26೔໦༵೔

    View Slide

  48. Invoking a function
    # app/views/recipes/_header.html.haml
    = invoke(:new_search_btn, :search_btn) do
    = render ‘recipes/search’
    # app/units/new_search_btn/new_search_btn.rb
    module NewSearchBtn
    scope(:view) do
    function(:search_btn) do
    render ‘recipes/new_search’
    end
    end
    end
    NewSearchBtn
    :search_btn
    :new_search_btn :search_btn
    29
    12೥4݄26೔໦༵೔

    View Slide

  49. Staff
    Users
    30
    12೥4݄26೔໦༵೔

    View Slide

  50. Live Demo
    31
    12೥4݄26೔໦༵೔

    View Slide

  51. Chanko Details
    32
    12೥4݄26೔໦༵೔

    View Slide

  52. invoke(:unit_name, :register_name)
    invoke method
    33
    12೥4݄26೔໦༵೔

    View Slide

  53. invoke(:unit_name, :register_name)
    invoke method
    class ApplicationController
    include Chanko::Invoker
    end
    33
    12೥4݄26೔໦༵೔

    View Slide

  54. invoke method
    invoke(:unit_name, :register_name) do
    # default processes
    end
    34
    12೥4݄26೔໦༵೔

    View Slide

  55. invoke method
    A default block is called when
    • The unit is not activated for the current user
    • Errors occur in a function
    invoke(:unit_name, :register_name) do
    # default processes
    end
    34
    12೥4݄26೔໦༵೔

    View Slide

  56. invoke method
    invoke([:unit_name, :function_name],
    [:unit_name2, :function_name2]) do
    # default processes
    end
    35
    12೥4݄26೔໦༵೔

    View Slide

  57. scope for controllers
    scope "UserController" do
    function :function_name do
    # some processes
    end
    end
    36
    12೥4݄26೔໦༵೔

    View Slide

  58. Model
    module ExampleChankoUnit
    include Chanko::Unit
    models do
    expand "User" do
    has_many :comments
    def blacklist!
    # code
    end
    class_methods do
    def rank
    # code
    end
    end
    end
    end
    end
    37
    12೥4݄26೔໦༵೔

    View Slide

  59. user.unit.comments
    user.unit.blacklist!
    User.unit.rank
    38
    12೥4݄26೔໦༵೔

    View Slide

  60. helper
    helpers do
    def hello_world
    'hello world'
    end
    end
    #app/chankos/unit_name/views/top/top.html.haml
    = unit.hello_world
    39
    12೥4݄26೔໦༵೔

    View Slide

  61. Differences from Engine
    Engine
    Chanko
    Objective
    Overwrite existing
    application
    feature
    Provide
    independent
    feature
    Standalone × O
    Reusability × O
    Stability O ×
    40
    12೥4݄26೔໦༵೔

    View Slide

  62. Chanko in COOKPAD
    41
    12೥4݄26೔໦༵೔

    View Slide

  63. PC MOBILE SmartPhone Android app
    Chanko in COOKPAD
    42
    12೥4݄26೔໦༵೔

    View Slide

  64. Developed in a year
    > 200
    Currently active units
    30 ~ 40
    How many units
    43
    12೥4݄26೔໦༵೔

    View Slide

  65. Unit manager
    44
    12೥4݄26೔໦༵೔

    View Slide

  66. Varnish Cache
    Rails Action Cache
    Action
    Bypass Cookie Normal
    Cache
    45
    12೥4݄26೔໦༵೔

    View Slide

  67. Errors
    46
    12೥4݄26೔໦༵೔

    View Slide

  68. 47
    12೥4݄26೔໦༵೔

    View Slide

  69. 47
    12೥4݄26೔໦༵೔

    View Slide

  70. 47
    12೥4݄26೔໦༵೔

    View Slide

  71. Old New
    48
    12೥4݄26೔໦༵೔

    View Slide

  72. Chanko
    https://github.com/cookpad/chanko
    If you have any questions,
    tweet at @mrkn or @shingo.
    49
    12೥4݄26೔໦༵೔

    View Slide