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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size 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 full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size 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 full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide