conexão kinghost - otimização prematura

Post on 15-Jan-2017

973 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

PREMATUREOPTIMIZATION

The Root of ALL Evil

@akitaonrails

@akitaonrails

Rubyconf Brasil 2016 – September 23 - 24

Rubyconf Brasil 2016 – September 23 - 24

September

23 - 24 @rubyconfbr

PREMATUREOPTIMIZATION

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, etc)

• 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 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:

• 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

• 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%

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 CONTENT publishing?

• /do/you/have/friendly/urls?

• sitemap.xml?

• Proper HTTP 301 Redirections?

• Social Network buttons?

• Periodic ORIGINAL CONTENT publishing?

• No duplication duplication of content content?

• /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!

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

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 COPY AND PASTE EVERYWHERE!!!

• 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 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 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!!

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 code that was not removed

• 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

• 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

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 Metrics, No Optimization

• Increase Revenue > Lower Costs

• SaaS > PaaS > IaaS > In-House

• Maintainability > Performance

• PRIORITIES!!

• No Metrics, No Optimization

• You != Unicorn

PREMATURE OPTIMIZATION is the Root of all Evil

THANKS!www.codeminer42.com

@akitaonrails

top related