Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
PREMATURE
OPTIMIZATION
The Root of ALL Evil
@akitaonrails
@akitaonrails
Rubyconf Brasil 2016 – September 23 - 24
Rubyconf Brasil 2016 – September 23 - 24
September
23 - 24
@rubyconfbr
PREMATURE
OPTIMIZATION
The Root of ALL Evil
@akitaonrails
“Premature Optimization
is the Root of All Evil”
- Don Knuth
SPA e-commerce
SPA e-commerce
http://www.loja.com.br/#!/produtos/item-001
SPA e-commerce
http://www.loja.com.br/#!/produtos/item-001
http://www.loja.com.br/?_escaped_fragment_=/produtos/item-001
High Level
Numbers
Client #1
$ 4,000
$ 4,000
($ 7 MI/yr revenue - 0.68%)
Client #2
$ 100,000+
$ 100,000+
($ 800 MI/yr revenue - 0.15%)
• Minimum IT Cost:
• Minimum IT Cost:
• USD 1000 - Cloud Services
• Minimum IT Cost:
• USD 1000 - Cloud Services
• USD 3000 - 1 Developer
• Minimum IT Cost:
• USD 1000 - Cloud Services
• USD 3000 - 1 Developer
• USD 4000 - 1“Responsible”(Manager, Marketing, et...
• Minimum IT Cost:
• USD 1000 - Cloud Services
• USD 3000 - 1 Developer
• USD 4000 - 1“Responsible”(Manager, Marketing, et...
• Minimum IT Cost:
• USD 1000 - Cloud Services
• USD 3000 - 1 Developer
• USD 4000 - 1“Responsible”(Manager, Marketing, et...
• Minimum IT Cost:
• USD 1000 - Cloud Services
• USD 3000 - 1 Developer
• USD 4000 - 1“Responsible”(Manager, Marketing, et...
• Minimum IT Cost:
• USD 1000 - Cloud Services
• USD 3000 - 1 Developer
• USD 4000 - 1“Responsible”(Manager, Marketing, et...
Increase Revenue
>
Lower Costs
Open > Proprietary
(prefer“Best of Breed”)
Cloud > On-Premise
(Infrastructure/Platform as a Service)
SaaS > IaaS
(avoid doing yourself)
Databases
E-mail
Performance
Search
Async
Jobs
Monitoring
SEO & SEM
(should not be Astrology!)
• /do/you/have/friendly/urls?
• /do/you/have/friendly/urls?
• sitemap.xml?
• /do/you/have/friendly/urls?
• sitemap.xml?
• Proper HTTP 301 Redirections?
• /do/you/have/friendly/urls?
• sitemap.xml?
• Proper HTTP 301 Redirections?
• Social Network buttons?
• /do/you/have/friendly/urls?
• sitemap.xml?
• Proper HTTP 301 Redirections?
• Social Network buttons?
• Periodic ORIGINAL...
• /do/you/have/friendly/urls?
• sitemap.xml?
• Proper HTTP 301 Redirections?
• Social Network buttons?
• Periodic ORIGINAL...
• /do/you/have/friendly/urls?
• sitemap.xml?
• Proper HTTP 301 Redirections?
• Social Network buttons?
• Periodic ORIGINAL...
I.
II.
III.
IV.
V.
VI.
VII.
VIII.
IX.
X.
XI.
XII.
Codebase One codebase tracked in revision control, many deploys
Dependen...
y = x * 320
y = x * 320
y = (x << 8) + (x << 6)
• NO Test Suite with below 70% coverage
• NO Test Suite with below 70% coverage
• NO CodeClimate below 3.0 rating
• NO Test Suite with below 70% coverage
• NO CodeClimate below 3.0 rating
• NO source code file with hundreds of LOC
• NO Test Suite with below 70% coverage
• NO CodeClimate below 3.0 rating
• NO source code file with hundreds of LOC
• NO ...
• NO Test Suite with below 70% coverage
• NO CodeClimate below 3.0 rating
• NO source code file with hundreds of LOC
• NO ...
• NO Test Suite with below 70% coverage
• NO CodeClimate below 3.0 rating
• NO source code file with hundreds of LOC
• NO ...
• NO Test Suite with below 70% coverage
• NO CodeClimate below 3.0 rating
• NO source code file with hundreds of LOC
• NO ...
Spree: 68k LOC
40k are Specs! (60%)
Magento2: 300k LOC
127k are Specs! (< 30%)
Maintainability
>
Performance
PRIORITIES!
• SQL N+1 Queries
• SQL N+1 Queries
• Too much SQL
• SQL N+1 Queries
• Too much SQL
• Too much SQL LIKE instead of Elastic
• SQL N+1 Queries
• Too much SQL
• Too much SQL LIKE instead of Elastic
• Lack of proper SQL indexes
• SQL N+1 Queries
• Too much SQL
• Too much SQL LIKE instead of Elastic
• Lack of proper SQL indexes
• Too much unused cod...
• SQL N+1 Queries
• Too much SQL
• Too much SQL LIKE instead of Elastic
• Lack of proper SQL indexes
• Too much unused cod...
• SQL N+1 Queries
• Too much SQL
• Too much SQL LIKE instead of Elastic
• Lack of proper SQL indexes
• Too much unused cod...
No Metrics
No Optimization
- Alan Kay
“Make it Work
- Alan Kay
“Make it Work
Make it Correct
- Alan Kay
“Make it Work
Make it Correct
Make it Fast
- Alan Kay
“Make it Work
Make it Correct
Make it Fast
Make it Cheap”
- Alan Kay
You != Unicorn
(nor Facebook, Google, Amazon, etc)
“Casa de Ferreiro, Espeto de FERRO!”
• Increase Revenue > Lower Costs
• Increase Revenue > Lower Costs
• SaaS > PaaS > IaaS > In-House
• Increase Revenue > Lower Costs
• SaaS > PaaS > IaaS > In-House
• Maintainability > Performance
• Increase Revenue > Lower Costs
• SaaS > PaaS > IaaS > In-House
• Maintainability > Performance
• PRIORITIES!!
• Increase Revenue > Lower Costs
• SaaS > PaaS > IaaS > In-House
• Maintainability > Performance
• PRIORITIES!!
• No Metri...
• Increase Revenue > Lower Costs
• SaaS > PaaS > IaaS > In-House
• Maintainability > Performance
• PRIORITIES!!
• No Metri...
PREMATURE
OPTIMIZATION
is the Root of all Evil
THANKS!
www.codeminer42.com
@akitaonrails
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
Upcoming SlideShare
Loading in …5
×

Conexão Kinghost - Otimização Prematura

1,260 views

Published on

Versão atualizada da minha palestra sobre Otimização Prematura que abriu o evento online Conexão Kinghost.

Published in: Technology

Conexão Kinghost - Otimização Prematura

  1. 1. PREMATURE OPTIMIZATION The Root of ALL Evil @akitaonrails
  2. 2. @akitaonrails
  3. 3. Rubyconf Brasil 2016 – September 23 - 24
  4. 4. Rubyconf Brasil 2016 – September 23 - 24
  5. 5. September 23 - 24 @rubyconfbr
  6. 6. PREMATURE OPTIMIZATION The Root of ALL Evil @akitaonrails
  7. 7. “Premature Optimization is the Root of All Evil” - Don Knuth
  8. 8. SPA e-commerce
  9. 9. SPA e-commerce http://www.loja.com.br/#!/produtos/item-001
  10. 10. SPA e-commerce http://www.loja.com.br/#!/produtos/item-001 http://www.loja.com.br/?_escaped_fragment_=/produtos/item-001
  11. 11. High Level Numbers
  12. 12. Client #1
  13. 13. $ 4,000
  14. 14. $ 4,000 ($ 7 MI/yr revenue - 0.68%)
  15. 15. Client #2
  16. 16. $ 100,000+
  17. 17. $ 100,000+ ($ 800 MI/yr revenue - 0.15%)
  18. 18. • Minimum IT Cost:
  19. 19. • Minimum IT Cost: • USD 1000 - Cloud Services
  20. 20. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer
  21. 21. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer • USD 4000 - 1“Responsible”(Manager, Marketing, etc)
  22. 22. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer • USD 4000 - 1“Responsible”(Manager, Marketing, etc) • Total: USD 8.000/month (USD 96.000/year)
  23. 23. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer • USD 4000 - 1“Responsible”(Manager, Marketing, etc) • Total: USD 8.000/month (USD 96.000/year) • Minimum Business Requirement:
  24. 24. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer • USD 4000 - 1“Responsible”(Manager, Marketing, etc) • Total: USD 8.000/month (USD 96.000/year) • Minimum Business Requirement: • Revenue: > USD 2 MI / year
  25. 25. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer • USD 4000 - 1“Responsible”(Manager, Marketing, etc) • Total: USD 8.000/month (USD 96.000/year) • Minimum Business Requirement: • Revenue: > USD 2 MI / year • IT Cost / Revenue ratio: < 5%
  26. 26. Increase Revenue > Lower Costs
  27. 27. Open > Proprietary (prefer“Best of Breed”)
  28. 28. Cloud > On-Premise (Infrastructure/Platform as a Service)
  29. 29. SaaS > IaaS (avoid doing yourself)
  30. 30. Databases
  31. 31. E-mail
  32. 32. Performance
  33. 33. Search
  34. 34. Async Jobs
  35. 35. Monitoring
  36. 36. SEO & SEM (should not be Astrology!)
  37. 37. • /do/you/have/friendly/urls?
  38. 38. • /do/you/have/friendly/urls? • sitemap.xml?
  39. 39. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections?
  40. 40. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons?
  41. 41. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons? • Periodic ORIGINAL CONTENT publishing?
  42. 42. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons? • Periodic ORIGINAL CONTENT publishing? • No duplication duplication of content content?
  43. 43. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons? • Periodic ORIGINAL CONTENT publishing? • No duplication duplication of content content? • THEN OK!
  44. 44. I. II. III. IV. V. VI. VII. VIII. IX. X. XI. XII. Codebase One codebase tracked in revision control, many deploys Dependencies Explicitly declare and isolate dependencies Config Store config in the environment Backing services Treat backing services as attached resources Build, release, run Strictly separate build and run stages Processes Execute the app as one or more stateless processes Port binding Export services via port binding Concurrency Scale out via the process model Disposability Maximize robustness with fast startup and graceful shutdown Dev/prod parity Keep development, staging, and production as similar as possible Logs Treat logs as event streams Admin processes Run admin/management tasks as one-off processes
  45. 45. y = x * 320
  46. 46. y = x * 320 y = (x << 8) + (x << 6)
  47. 47. • NO Test Suite with below 70% coverage
  48. 48. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating
  49. 49. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating • NO source code file with hundreds of LOC
  50. 50. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating • NO source code file with hundreds of LOC • NO COPY AND PASTE EVERYWHERE!!!
  51. 51. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating • NO source code file with hundreds of LOC • NO COPY AND PASTE EVERYWHERE!!! • NO functions with more than 1 page down
  52. 52. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating • NO source code file with hundreds of LOC • NO COPY AND PASTE EVERYWHERE!!! • NO functions with more than 1 page down • NO table with dozens of fields
  53. 53. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating • NO source code file with hundreds of LOC • NO COPY AND PASTE EVERYWHERE!!! • NO functions with more than 1 page down • NO table with dozens of fields • NO hours to clone, setup and deploy!!
  54. 54. Spree: 68k LOC 40k are Specs! (60%)
  55. 55. Magento2: 300k LOC 127k are Specs! (< 30%)
  56. 56. Maintainability > Performance
  57. 57. PRIORITIES!
  58. 58. • SQL N+1 Queries
  59. 59. • SQL N+1 Queries • Too much SQL
  60. 60. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic
  61. 61. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic • Lack of proper SQL indexes
  62. 62. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic • Lack of proper SQL indexes • Too much unused code that was not removed
  63. 63. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic • Lack of proper SQL indexes • Too much unused code that was not removed • No CDN or proper HTTP Cache invalidation headers
  64. 64. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic • Lack of proper SQL indexes • Too much unused code that was not removed • No CDN or proper HTTP Cache invalidation headers • Too much synchronous work that should be async jobs
  65. 65. No Metrics No Optimization
  66. 66. - Alan Kay
  67. 67. “Make it Work - Alan Kay
  68. 68. “Make it Work Make it Correct - Alan Kay
  69. 69. “Make it Work Make it Correct Make it Fast - Alan Kay
  70. 70. “Make it Work Make it Correct Make it Fast Make it Cheap” - Alan Kay
  71. 71. You != Unicorn (nor Facebook, Google, Amazon, etc)
  72. 72. “Casa de Ferreiro, Espeto de FERRO!”
  73. 73. • Increase Revenue > Lower Costs
  74. 74. • Increase Revenue > Lower Costs • SaaS > PaaS > IaaS > In-House
  75. 75. • Increase Revenue > Lower Costs • SaaS > PaaS > IaaS > In-House • Maintainability > Performance
  76. 76. • Increase Revenue > Lower Costs • SaaS > PaaS > IaaS > In-House • Maintainability > Performance • PRIORITIES!!
  77. 77. • Increase Revenue > Lower Costs • SaaS > PaaS > IaaS > In-House • Maintainability > Performance • PRIORITIES!! • No Metrics, No Optimization
  78. 78. • Increase Revenue > Lower Costs • SaaS > PaaS > IaaS > In-House • Maintainability > Performance • PRIORITIES!! • No Metrics, No Optimization • You != Unicorn
  79. 79. PREMATURE OPTIMIZATION is the Root of all Evil
  80. 80. THANKS! www.codeminer42.com @akitaonrails

×