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
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)
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)
275k Merchants
$ 72 Mi - Q1 2016
Founded: 2004, with Rails pre-1.0
Rails works because it
didn’t have Facebook,
Google or Microsoft
“Casa de Ferreiro, Espeto de FERRO!”
• Increase Revenue > Lower Costs
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• SaaS > PaaS > IaaS > On-Premise
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• SaaS > PaaS > IaaS > On-Premise
• SEO & SEM =~ Astrology
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• SaaS > PaaS > IaaS > On-Premise
• SEO & SEM =~ Astrology
•...
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• SaaS > PaaS > IaaS > On-Premise
• SEO & SEM =~ Astrology
•...
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• SaaS > PaaS > IaaS > On-Premise
• SEO & SEM =~ Astrology
•...
• Increase Revenue > Lower Costs
• “Best of Breed”Open Source
• SaaS > PaaS > IaaS > On-Premise
• SEO & SEM =~ Astrology
•...
PREMATURE
OPTIMIZATION
is the Root of all Evil
THANKS!
www.codeminer42.com
@akitaonrails
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais
Upcoming SlideShare
Loading in …5
×

DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais

110 views

Published on

Fabio Akita, Co-Founder da Codeminer 42, palestrou sobre "Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais", no DevCommerce Conference 2016.

O DevCommerce Conference 2016 aconteceu nos dias 06 e 07 de junho de 2016, no Hotel Tivoli em São Paulo-SP http://devcommerce2016.imasters.com.br/

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
110
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvolver e-commerce, com cases reais

  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 is the Root of All Evil” - Don Knuth
  7. 7. SPA e-commerce
  8. 8. SPA e-commerce http://www.loja.com.br/#!/produtos/item-001
  9. 9. SPA e-commerce http://www.loja.com.br/#!/produtos/item-001 http://www.loja.com.br/?_escaped_fragment_=/produtos/item-001
  10. 10. High Level Numbers
  11. 11. Client #1
  12. 12. $ 4,000
  13. 13. $ 4,000 ($ 7 MI/yr revenue - 0.68%)
  14. 14. Client #2
  15. 15. $ 100,000+
  16. 16. $ 100,000+ ($ 800 MI/yr revenue - 0.15%)
  17. 17. • Minimum IT Cost:
  18. 18. • Minimum IT Cost: • USD 1000 - Cloud Services
  19. 19. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer
  20. 20. • Minimum IT Cost: • USD 1000 - Cloud Services • USD 3000 - 1 Developer • USD 4000 - 1“Responsible”(Manager, Marketing, etc)
  21. 21. • 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)
  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) • Minimum Business Requirement:
  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: • Revenue: > USD 2 MI / year
  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 • IT Cost / Revenue ratio: < 5%
  25. 25. Increase Revenue > Lower Costs
  26. 26. Open > Proprietary (prefer“Best of Breed”)
  27. 27. Cloud > On-Premise (Infrastructure/Platform as a Service)
  28. 28. SaaS > IaaS (avoid doing yourself)
  29. 29. SEO & SEM (should not be Astrology!)
  30. 30. • /do/you/have/friendly/urls?
  31. 31. • /do/you/have/friendly/urls? • sitemap.xml?
  32. 32. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections?
  33. 33. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons?
  34. 34. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons? • Periodic ORIGINAL CONTENT publishing?
  35. 35. • /do/you/have/friendly/urls? • sitemap.xml? • Proper HTTP 301 Redirections? • Social Network buttons? • Periodic ORIGINAL CONTENT publishing? • No duplication duplication of content content?
  36. 36. • /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!
  37. 37. 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
  38. 38. y = x * 320
  39. 39. y = x * 320 y = (x << 8) + (x << 6)
  40. 40. • NO Test Suite with below 70% coverage
  41. 41. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating
  42. 42. • NO Test Suite with below 70% coverage • NO CodeClimate below 3.0 rating • NO source code file with hundreds of LOC
  43. 43. • 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!!!
  44. 44. • 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
  45. 45. • 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
  46. 46. • 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!!
  47. 47. Spree: 68k LOC 40k are Specs! (60%)
  48. 48. Magento2: 300k LOC 127k are Specs! (< 30%)
  49. 49. Maintainability > Performance
  50. 50. PRIORITIES!
  51. 51. • SQL N+1 Queries
  52. 52. • SQL N+1 Queries • Too much SQL
  53. 53. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic
  54. 54. • SQL N+1 Queries • Too much SQL • Too much SQL LIKE instead of Elastic • Lack of proper SQL indexes
  55. 55. • 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
  56. 56. • 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
  57. 57. • 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
  58. 58. No Metrics No Optimization
  59. 59. - Alan Kay
  60. 60. “Make it Work - Alan Kay
  61. 61. “Make it Work Make it Correct - Alan Kay
  62. 62. “Make it Work Make it Correct Make it Fast - Alan Kay
  63. 63. “Make it Work Make it Correct Make it Fast Make it Cheap” - Alan Kay
  64. 64. You != Unicorn (nor Facebook, Google, Amazon, etc)
  65. 65. 275k Merchants $ 72 Mi - Q1 2016 Founded: 2004, with Rails pre-1.0
  66. 66. Rails works because it didn’t have Facebook, Google or Microsoft
  67. 67. “Casa de Ferreiro, Espeto de FERRO!”
  68. 68. • Increase Revenue > Lower Costs
  69. 69. • Increase Revenue > Lower Costs • “Best of Breed”Open Source
  70. 70. • Increase Revenue > Lower Costs • “Best of Breed”Open Source • SaaS > PaaS > IaaS > On-Premise
  71. 71. • Increase Revenue > Lower Costs • “Best of Breed”Open Source • SaaS > PaaS > IaaS > On-Premise • SEO & SEM =~ Astrology
  72. 72. • Increase Revenue > Lower Costs • “Best of Breed”Open Source • SaaS > PaaS > IaaS > On-Premise • SEO & SEM =~ Astrology • Maintainability > Performance
  73. 73. • Increase Revenue > Lower Costs • “Best of Breed”Open Source • SaaS > PaaS > IaaS > On-Premise • SEO & SEM =~ Astrology • Maintainability > Performance • PRIORITIES!!
  74. 74. • Increase Revenue > Lower Costs • “Best of Breed”Open Source • SaaS > PaaS > IaaS > On-Premise • SEO & SEM =~ Astrology • Maintainability > Performance • PRIORITIES!! • No Metrics, No Optimization
  75. 75. • Increase Revenue > Lower Costs • “Best of Breed”Open Source • SaaS > PaaS > IaaS > On-Premise • SEO & SEM =~ Astrology • Maintainability > Performance • PRIORITIES!! • No Metrics, No Optimization • You != Unicorn
  76. 76. PREMATURE OPTIMIZATION is the Root of all Evil
  77. 77. THANKS! www.codeminer42.com @akitaonrails

×