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

A Healthy Monolith

A Healthy Monolith

Supporting an overgrown monstrous project, a so-called Monolith that was shaped according to the tenets of the "Rails way", is a usual problem for our community. Many developers blame Rails for the fact that it allows, and even promotes, this way of project building, and that there are no tools available out of the box to make this growth healthier. I'll tell you how Evil Martians live with their own Monolith and demonstrate the that the Monolith is not in fact a problem — it's an opportunity

Ee8543e8f5554aaeabb6d140fa07b919?s=128

Nikolay Sverchkov

June 10, 2018
Tweet

Transcript

  1. Monolithic Problems

  2. None
  3. EVIL MARTIANS

  4. EVIL MARTIANS

  5. Nikolay Sverchkov @ssnickolay Math Elixir

  6. My name is potato

  7. What is a Monolith?

  8. https://en.wikipedia.org/wiki/Monolithic_application

  9. Monolithic Application is one git repo with 99% code base

    of project
  10. What is a Huge Monolith?

  11. How I can understand my Monolith is Huge or no?

  12. Let’s Estimate it!

  13. Monolith Estimation: by commits count

  14. Monolith Estimation: by commits count

  15. Cons: Strategy: merge or rebase? Monolith Estimation: by commits count

  16. Cons: Strategy: merge or rebase? Atomic commits or one commit

    per feature (Pull request)? Monolith Estimation: by commits count
  17. None
  18. None
  19. Monolith Estimation: by count lines of code

  20. None
  21. Monolith Estimation: by count lines of code Pros: Amount of

    commits does not influence on count of code lines
  22. Monolith Estimation: by count lines of code Pros: Amount of

    commits does not influence on count of code lines Cons: There is no connection to REAL production
  23. None
  24. What is it in real and what it seems to

    be
  25. Monolith Estimation: by DataBase size?

  26. None
  27. What does "Large Database” mean?

  28. The size of the database for a regular web application

    can be considered as “Web Big Data” when the backup of this database cannot be restored to the developer computer. Funny Law of “Web BigData”
  29. None
  30. Huge Monolith: A lot of commits + A lot of

    code lines + Deep Production
  31. Your Project Team

  32. Rails Project Architecture Shark Head

  33. Rails Project Architecture Shark Head Elephant Body +

  34. Rails Project Architecture Shark Head Elephant Body + Tiger and

    Rhino Legs +
  35. Rails Project Architecture Shark Head Elephant Body + Tiger and

    Rhino Legs + AND BLASTERS
  36. None
  37. EVIL MARTIANS

  38. None
  39. cloc —exclude- dir=log,node_modules, public,tmp,vendor,lurker, .idea ./ https://github.com/ AlDanial/cloc

  40. ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- Ruby 3671 30458

    3106 145366 JSX 571 5759 43 52618 YAML 182 90 20 33753 JavaScript 492 3247 144 22763 ERB 617 1569 58 18599 Sass 480 3552 194 18024 CoffeeScript 150 874 92 5227 …… …… ------------------------------------------------------------------------------- SUM: 6231 52012 7778 306167 ------------------------------------------------------------------------------- Fountain. 30/05/2018 25.5k commits SUM: 306,167 LOC
  41. Is it big enough?

  42. Is it big enough?

  43. None
  44. None
  45. None
  46. None
  47. None
  48. Shopify 30/05/2018 ? commits SUM: ? LOC

  49. -------------------------------------------------------------------------------- Language files blank comment code -------------------------------------------------------------------------------- Ruby 13995 271122

    19124 1290867 YAML 1791 8962 1166 559395 JSON 332 77 0 303475 Sass 484 39191 4968 185032 ERB 2584 7208 83 111490 JavaScript 1065 22635 5956 109023 CoffeeScript 667 12130 1003 45734 SQL 4 14 0 28300 TypeScript 455 3794 190 23939 liquid 64 4391 28 21809 …… …… -------------------------------------------------------------------------------- SUM: 21742 376631 38507 2705978 -------------------------------------------------------------------------------- Shopify 30/05/2018 306k commits SUM: 2.7M LOC
  50. Teaser for @isleofruby @eljojo

  51. Monolithic Project Health Level

  52. Monolith Health Levels Healthy

  53. Monolith Health Levels Normal Healthy

  54. Monolith Health Levels Normal Healthy Legacy

  55. Monolith Health Levels Normal Healthy Legacy

  56. Normal • Rails 4 Healthy • Rails 5+ • Rails

    4 -> Rails 5 in process Legacy • Rails 3 and lower Monolith Healthy Level: by Rails version
  57. Normal • 2.3+ Healthy • Last stable Legacy • 1.9*

    - What wrong with you, guys? >_< Monolith Healthy Level: by Ruby version
  58. Why we should update Ruby?

  59. Because yield_self is powerful feature?

  60. Security Vulnerabilities

  61. Healthy • Use bundler-audit Legacy • Don’t use bundler-audit Monolith

    Healthy Level: by gems version
  62. All Evil Martians projects use “bundler-audit”

  63. All Evil Martians projects use “bundler-audit” and “nsp check”

  64. Monolith Healthy Level: by Architecture

  65. Healthy • It is easy to make changes • You

    have permanent refactor for an old code Legacy • You use Rails way (sorry, DHH) • You have a bunch of different patterns Monolith Healthy Level: by Architecture
  66. Houston, we have a problem (c)

  67. Problem = 
 Cause + Solution

  68. Solution Cause I need to use some framework… e.g. Trailblazer!

    Rails MVC is sucks
  69. #TODO My opinion about Trailblaizer

  70. None
  71. None
  72. None
  73. None
  74. Saint P NickConf

  75. Solution Cause Rails MVC is sucks Use MCC! M -

    Model C - Cells C - Controller
  76. class UsersController < ApplicationController def show user = User.find(params[:id]) render_app_cell(Users::Cell::Show,

    user: user) end end MC(ells)C Example
  77. class UsersController < ApplicationController def show user = User.find(params[:id]) render_app_cell(Users::Cell::Show,

    user: user) end end class ApplicationController < ActionController::Base def render_app_cell(*args) render html: cell(*args), layout: 'application' end end MC(ells)C Example
  78. HANAMI

  79. Talk about Elixir at the Ruby Conference

  80. Solution Cause I can use ROM! ActiveRecord is sucks

  81. I

  82. I ROM

  83. Talk twice about Elixir at the Ruby Conference ROM.rb ~

    Ecto
  84. Solution Cause I can use ROM! If you can work

    with complex solutions ActiveRecord is sucks
  85. Solution Cause Microservices! Monolithic architecture It’s all sucks

  86. Monolithic Microservices vs

  87. Monolithic Microservices !=

  88. Monolithic Microservices >

  89. Monolithic Microservices >

  90. Solution Cause Microservices! Good choice! Monolithic architecture It’s all sucks

  91. And Last but not to least

  92. Opportunity for what?

  93. None
  94. https:// github.com/ palkan/ test-prof

  95. https://github.com/palkan/ clowne

  96. https://github.com/marshall- lee/sidekiq-postpone

  97. https://github.com/marshall- lee/sidekiq-postpone

  98. Blood Contracts

  99. Next: Blood Contracts @ssnickolay