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

Can Time-Travel Keep You From Blowing Up The Enterprise?

Can Time-Travel Keep You From Blowing Up The Enterprise?

My talk from RailsConf 2016 on scaling rails

David Copeland

May 05, 2016
Tweet

More Decks by David Copeland

Other Decks in Programming

Transcript

  1. CAN TIME-TRAVEL KEEP YOU FROM
    BLOWING UP THE ENTERPRISE?
    @DAVETRON5000

    View full-size slide

  2. SCALING RAILS

    View full-size slide

  3. SCALING RAILS
    ▸ Do stuff Faster?
    ▸ Do more stuff at once?

    View full-size slide

  4. SCALING RAILS
    ▸ Do stuff Faster?
    ▸ Do more stuff at once?
    NO, IT'S ACTUALLY…
    ▸ Growing Team
    ▸ Growing Business
    ▸ Changing Business

    View full-size slide

  5. MONOLITH? OR MICROSERVICES?

    View full-size slide

  6. A FRAMING DEVICE
    CAUSE & EFFECT

    View full-size slide

  7. DON'T BLOW UP THE ENTERPRISE

    View full-size slide

  8. DON'T BLOW UP THE ENTERPRISE

    View full-size slide

  9. DON'T BLOW UP THE ENTERPRISE

    View full-size slide

  10. DON'T BLOW UP THE ENTERPRISE

    View full-size slide

  11. DON'T BLOW UP THE ENTERPRISE

    View full-size slide

  12. FIRST, SOME ASSUMPTIONS

    View full-size slide

  13. FIRST, SOME ASSUMPTIONS
    ▸ Over time, more people will work on the code

    View full-size slide

  14. FIRST, SOME ASSUMPTIONS
    ▸ Over time, more people will work on the code
    ▸ Over time, different people will work on the code

    View full-size slide

  15. FIRST, SOME ASSUMPTIONS
    ▸ Over time, more people will work on the code
    ▸ Over time, different people will work on the code
    ▸ There will be increasing demands on the code

    View full-size slide

  16. FAILURE: BUSINESS/PRODUCT NOT MEETING USER NEEDS
    ▸ Simple changes difficult
    ▸ Difficult changes impossible
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  17. COMMON, BUT NOT UNIVERSAL
    ▸ Start-up
    ▸ New project on a larger company
    ▸ New longer-term consulting gig

    View full-size slide

  18. COMMON, BUT NOT UNIVERSAL
    ▸ Start-up
    ▸ New project on a larger company
    ▸ New longer-term consulting gig
    GROWTH & CHANGE

    View full-size slide

  19. NOTHIN' BEATS
    MONOLITH!
    GOOD 'OLE MONOLITH

    View full-size slide

  20. SHIP EARLY, SHIP
    OFTEN
    INTEGRATED SYSTEM

    View full-size slide

  21. MORE DEVELOPERS!

    View full-size slide

  22. MORE DEVELOPERS!

    View full-size slide

  23. MORE DEVELOPERS!

    View full-size slide

  24. MORE HIDDEN COMPLEXITY
    HOMEPAGE
    ADMIN
    PURCHASING
    SEARCH
    REFERRALS

    View full-size slide

  25. MORE HIDDEN COMPLEXITY
    ADMIN.CSS
    HOMEPAGE
    ADMIN
    PURCHASING
    SEARCH
    REFERRALS

    View full-size slide

  26. MORE HIDDEN COMPLEXITY
    ADMIN.CSS
    HOMEPAGE
    ADMIN
    SEARCH
    REFERRALS

    View full-size slide

  27. MORE HIDDEN COMPLEXITY
    ADMIN.CSS
    HOMEPAGE
    ADMIN
    SEARCH
    CACHE
    REFERRALS

    View full-size slide

  28. MORE HIDDEN COMPLEXITY
    ADMIN.CSS
    HOMEPAGE
    ADMIN
    CACHE
    REFERRALS

    View full-size slide

  29. ENTANGLEMENTS

    View full-size slide

  30. ENTANGLEMENTS
    user.signed_up.chronologically.approved.
    active_orders.in_zip(:east_cost).
    unshipped.first.try(:first_name)

    View full-size slide

  31. ENTANGLEMENTS

    View full-size slide

  32. ENTANGLEMENTS
    after_create do |user|
    end

    View full-size slide

  33. ENTANGLEMENTS
    after_create do |user|
    end
    UserMailer.send_welcome(user.id)

    View full-size slide

  34. ENTANGLEMENTS
    after_create do |user|
    end
    UserMailer.send_welcome(user.id)
    PaymentProcessor.add_customer(user.id)

    View full-size slide

  35. ENTANGLEMENTS
    after_create do |user|
    end
    UserMailer.send_welcome(user.id)
    PaymentProcessor.add_customer(user.id)
    MarketingTrackingSite.event!(user.id)

    View full-size slide

  36. ENTANGLEMENTS
    after_create do |user|
    end
    UserMailer.send_welcome(user.id)
    PaymentProcessor.add_customer(user.id)
    MarketingTrackingSite.event!(user.id)
    OtherTrackingSite.event!(user.id)

    View full-size slide

  37. OH, AND…
    ▸ Test suite is glacial
    ▸ Don't even think about looking in app/assets/javascripts
    ▸ /admin starts acting up -> www is dead, too
    ▸ Etc.

    View full-size slide

  38. REMEMBER WHAT FAILURE LOOKS LIKE?
    ▸ Simple changes difficult
    ▸ Difficult changes impossible
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  39. REMEMBER WHAT FAILURE LOOKS LIKE?
    ▸ Simple changes difficult
    ▸ Difficult changes impossible
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  40. MICROSERVICES
    FROM DAY 1
    NEVER AGAIN

    View full-size slide

  41. BEFORE EVEN STARTING…

    View full-size slide

  42. BEFORE EVEN STARTING…
    ▸ Deploy lots of apps

    View full-size slide

  43. BEFORE EVEN STARTING…
    ▸ Deploy lots of apps
    ▸ Authentication

    View full-size slide

  44. BEFORE EVEN STARTING…
    ▸ Deploy lots of apps
    ▸ Authentication
    ▸ Versioning

    View full-size slide

  45. BEFORE EVEN STARTING…
    ▸ Deploy lots of apps
    ▸ Authentication
    ▸ Versioning
    ▸ JSON format

    View full-size slide

  46. BEFORE EVEN STARTING…
    ▸ Deploy lots of apps
    ▸ Authentication
    ▸ Versioning
    ▸ JSON format
    ▸ Which HTTP library?

    View full-size slide

  47. BEFORE EVEN STARTING…
    ▸ Deploy lots of apps
    ▸ Authentication
    ▸ Versioning
    ▸ JSON format
    ▸ Which HTTP library?
    ▸ Argue about REST and status codes

    View full-size slide

  48. OH, AND WHAT SERVICES
    DO WE ACTUALLY NEED?

    View full-size slide

  49. THREE MONTHS LATER

    View full-size slide

  50. THREE MONTHS LATER
    ▸ React front-end

    View full-size slide

  51. THREE MONTHS LATER
    ▸ React front-end
    ▸ Hits the Backend-for-frontends (BFF)

    View full-size slide

  52. THREE MONTHS LATER
    ▸ React front-end
    ▸ Hits the Backend-for-frontends (BFF)
    ▸ BFF talks to the underlying auth service

    View full-size slide

  53. THREE MONTHS LATER
    ▸ React front-end
    ▸ Hits the Backend-for-frontends (BFF)
    ▸ BFF talks to the underlying auth service
    ▸ Then hits the role service

    View full-size slide

  54. THREE MONTHS LATER
    ▸ React front-end
    ▸ Hits the Backend-for-frontends (BFF)
    ▸ BFF talks to the underlying auth service
    ▸ Then hits the role service
    ▸ Then decorates with the consumer data

    View full-size slide

  55. THREE MONTHS LATER
    ▸ React front-end
    ▸ Hits the Backend-for-frontends (BFF)
    ▸ BFF talks to the underlying auth service
    ▸ Then hits the role service
    ▸ Then decorates with the consumer data
    ▸ To render “Hello, #{first_name}!”

    View full-size slide

  56. THREE MONTHS LATER
    ▸ React front-end
    ▸ Hits the Backend-for-frontends (BFF)
    ▸ BFF talks to the underlying auth service
    ▸ Then hits the role service
    ▸ Then decorates with the consumer data
    ▸ To render “Hello, #{first_name}!”
    ▸ Managed by Docker, Ansible, AWS, Terraform,
    Vault, Bash, and, of course, some Go

    View full-size slide

  57. WHAT HAPPENED?

    View full-size slide

  58. WHAT HAPPENED?
    ▸ Money has been spent

    View full-size slide

  59. WHAT HAPPENED?
    ▸ Money has been spent
    ▸ Blog posts all over Hacker News

    View full-size slide

  60. WHAT HAPPENED?
    ▸ Money has been spent
    ▸ Blog posts all over Hacker News
    ▸ Meetups have been attended

    View full-size slide

  61. WHAT HAPPENED?
    ▸ Money has been spent
    ▸ Blog posts all over Hacker News
    ▸ Meetups have been attended
    ▸ No actual business value

    View full-size slide

  62. WHAT HAPPENED?
    ▸ Money has been spent
    ▸ Blog posts all over Hacker News
    ▸ Meetups have been attended
    ▸ No actual business value
    ▸ Nothing to show

    View full-size slide

  63. WHAT HAPPENED?
    ▸ Money has been spent
    ▸ Blog posts all over Hacker News
    ▸ Meetups have been attended
    ▸ No actual business value
    ▸ Nothing to show
    ▸ Is there any money left?

    View full-size slide

  64. REMEMBER WHAT FAILURE LOOKS LIKE?
    ▸ Simple changes difficult
    ▸ Difficult changes impossible
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  65. REMEMBER WHAT FAILURE LOOKS LIKE?
    ▸ Simple changes difficult
    ▸ Difficult changes impossible
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  66. LET'S DO THIS
    OK MONOLITH

    View full-size slide

  67. AS LONG AS WE
    _NOTICE_ THE MESS,
    WE CAN CLEAN IT UP
    —Pat Agîlecønßultånt

    View full-size slide

  68. MORE DEVELOPERS!

    View full-size slide

  69. MORE DEVELOPERS!

    View full-size slide

  70. MORE HIDDEN COMPLEXITY
    HOMEPAGE
    ADMIN
    PURCHASING
    SEARCH
    REFERRALS

    View full-size slide

  71. MORE HIDDEN COMPLEXITY
    ADMIN.CSS
    HOMEPAGE
    ADMIN
    CACHE
    REFERRALS
    NOW, IT’S
    TOO MESSY!

    View full-size slide

  72. MORE HIDDEN COMPLEXITY
    HOMEPAGE
    ADMIN
    PURCHASING
    SEARCH
    REFERRALS

    View full-size slide

  73. MORE HIDDEN COMPLEXITY
    HOMEPAGE
    ADMIN
    PURCHASING
    REFERRALS
    PROMO CODES

    View full-size slide

  74. CLEANING THE AIRPORT BATHROOM
    ▸ Requires top engineers
    ▸ Grueling
    ▸ Small changes difficult
    ▸ Bigger changes become delayed

    View full-size slide

  75. REMEMBER WHAT FAILURE LOOKS LIKE?
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  76. REMEMBER WHAT FAILURE LOOKS LIKE?
    ▸ Low morale
    ▸ Brain drain

    View full-size slide

  77. THERE _IS_ ANOTHER
    WAY
    NO BLUR,

    View full-size slide

  78. WHILE IT'S IMPOSSIBLE TO PREDICT
    THE FUTURE,
    WE DON'T NEED TO ACT BLIND TO IT.
    Chris Reasonable

    View full-size slide

  79. DON'T BE BLIND TO THE FUTURE
    ▸ More developers, more features, more code, more changes
    ▸ You'll want things decoupled; but not exactly what.
    ▸ Don't make a mess in the first place

    View full-size slide

  80. ENABLE DECOUPLING
    ▸ One rails app per business function
    ▸ No business logic in Active Record models
    ▸ Use the Rule of Three to guide decisions around abstraction, tooling, de-
    coupling, and general pattern identification.

    View full-size slide

  81. RULE OF THREE
    ▸ 1st and 2nd times aren't a pattern.
    ▸ 3rd time is - use that to create needed tooling or
    process changes
    ▸ This is engineering culture
    ▸ Mature teams can graduate to the Rule of Two :)
    Effort
    1ST 2ND 3RD 4TH 5TH 6TH

    View full-size slide

  82. EXAMPLES
    ▸ Third Rails app - create it with a re-usable generator
    ▸ Third Ruby Gem - create it with a re-usable gem scaffold
    ▸ Third mess you make with jQuery - consider a front-end framework
    ▸ Third time customers report an outage - improve monitoring

    View full-size slide

  83. WWW
    SHARED
    DATABASE

    View full-size slide

  84. WWW CUSTOMER
    SERVICE
    SHARED
    DATABASE

    View full-size slide

  85. WWW CUSTOMER
    SERVICE
    MARKETING
    SHARED
    DATABASE

    View full-size slide

  86. WWW CUSTOMER
    SERVICE
    MARKETING
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS

    View full-size slide

  87. WWW CUSTOMER
    SERVICE
    MARKETING
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    PROMO
    CODE LOGIC
    PROMO
    CODE LOGIC

    View full-size slide

  88. WWW CUSTOMER
    SERVICE
    MARKETING
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    PROMO
    CODE LOGIC
    PROMO
    CODE LOGIC
    CACHE

    View full-size slide

  89. WWW CUSTOMER
    SERVICE
    MARKETING
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    PROMO
    CODE LOGIC
    PROMO
    CODE LOGIC
    CACHE

    View full-size slide

  90. WWW CUSTOMER
    SERVICE
    MARKETING
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    ANALYTICS
    PROMO
    CODE LOGIC
    PROMO
    CODE LOGIC
    CACHE

    View full-size slide

  91. WWW CUSTOMER
    SERVICE
    MARKETING FINANCE
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    ANALYTICS
    PROMO
    CODE LOGIC
    PROMO
    CODE LOGIC
    CACHE

    View full-size slide

  92. WWW CUSTOMER
    SERVICE
    MARKETING FINANCE
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    ANALYTICS
    PROMO
    CODES
    HTTP
    CACHE

    View full-size slide

  93. WWW CUSTOMER
    SERVICE
    MARKETING FINANCE
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    ANALYTICS
    PROMO
    CODES
    HTTP
    CACHE

    View full-size slide

  94. WWW CUSTOMER
    SERVICE
    MARKETING FINANCE
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    ANALYTICS
    PROMO
    CODES
    HTTP
    PRIVATE
    DATABASE
    CACHE

    View full-size slide

  95. WWW CUSTOMER
    SERVICE
    MARKETING FINANCE
    SHARED
    DATABASE
    SHARED
    MODELS
    SHARED
    MODELS
    SHARED
    MODELS
    ANALYTICS
    PROMO
    CODES
    HTTP
    PRIVATE
    DATABASE
    PRIVATE
    DATABASE
    CACHE

    View full-size slide

  96. YOUR ARCHITECTURE
    ISN'T EVER "DONE"

    View full-size slide

  97. YOUR ARCHITECTURE PLANS
    SHOULD BE HOW IT CHANGES NOT
    WHAT IT SHOULD BE

    View full-size slide

  98. ENTERPRISE BEGINS

    View full-size slide

  99. WHAT DID WE LEARN EXACTLY?
    ▸ Don't be blind to the future (this is different than predicting it!)
    ▸ Write code to enable change
    ▸ Create a culture of change, based on the Rule of Three
    ▸ Your architecture must evolve and is never "done"
    ▸ Don't make a mess

    View full-size slide

  100. 25% off CODE
    RailsConf16
    FULL-STACK-RAILS.COM SWENG.ME
    NEED RANTS ABOUT BAD UX AND JAVASCRIPT? @DAVETRON5000
    WANT TO WORK THIS WAY? TECH.STITCHFIX.COM/CAREERS/
    FINAL SLIDE OF SELF-PROMOTION

    View full-size slide