Performance Web com ASP.NET MVC

24
Performance ASP.NET MVC

Transcript of Performance Web com ASP.NET MVC

Page 1: Performance Web com ASP.NET MVC

Performance

ASP.NET MVC

Page 2: Performance Web com ASP.NET MVC

@RodolfoFadino

• MVP em Visual C#

• Especialista em desenvolvimento web

• Tecnologia em Processamento de Dados FATEC-SP

• Portal Minha Vida

Page 3: Performance Web com ASP.NET MVC
Page 4: Performance Web com ASP.NET MVC

! Instantâneo

Page 5: Performance Web com ASP.NET MVC

Soma de fatores

Back-End

• Cache

• Thread

• Debug/Release

• SQL

• IO

• Network

• ...

Front-End

• CSS

• JS

• IMG

• Headers

• Minified

• CDN

• Proxy

• Cookies

• ...

Page 6: Performance Web com ASP.NET MVC

Vamos fazer um projeto para isso

Page 7: Performance Web com ASP.NET MVC

Backlog

Page 8: Performance Web com ASP.NET MVC

Melhorar a performance é uma responsabilidade nossa

(desenvolvedor)

Page 9: Performance Web com ASP.NET MVC

IIS

• ApplicationPool– Isola nossas aplicações promovendo segurança,

confiança, disponibilidade e performance.– Versão de framework– Modo de pipeline– Recycling

• WorkerProcess– Host da aplicação (w3wp.exe)– Pool de Threads

• Número limitado• Bloqueio

Page 10: Performance Web com ASP.NET MVC

Requests e o Thread Pool

Processando Requisições Síncronas (Caixa Correios)

Page 11: Performance Web com ASP.NET MVC

Requests e o Thread Pool

Processando Requisições Assíncronas (Garçom restaurante)

Page 12: Performance Web com ASP.NET MVC

Requests e o Thread Pool

Processando Requisições Assíncronas (Garçom restaurante)

Page 13: Performance Web com ASP.NET MVC

Task-based Asynchronous Pattern (TAP)

Task Parallel Library (TPL)Baseada no conceito de TasksMaior eficiência no uso dos recursos computacionaisMelhor controle programático das Threads

Page 14: Performance Web com ASP.NET MVC
Page 15: Performance Web com ASP.NET MVC

Cache

• “A melhor solução de performance é fazer com que o seu código não seja executado o tempo todo!” Tarifa, Alexandre

Page 16: Performance Web com ASP.NET MVC
Page 17: Performance Web com ASP.NET MVC

• “…only 10-20% of the total end-user response time is spent getting the HTML document to the browser. You need to focus on the other 80-90% if you want to make your pages noticeably faster…”

Page 18: Performance Web com ASP.NET MVC

14 regras

• Rule 1 - Make Fewer HTTP Requests• Rule 2 - Use a Content Delivery Network• Rule 3 - Add an Expires Header• Rule 4 - Gzip Components• Rule 5 - Put Stylesheets at the Top• Rule 6 - Put Scripts at the Bottom• Rule 7 - Avoid CSS Expressions• Rule 8 - Make JavaScript and CSS External• Rule 9 - Reduce DNS Lookups• Rule 10 - Minify JavaScript• Rule 11 - Avoid Redirects• Rule 12 - Remove Duplicate Scripts• Rule 13 - Configure ETags• Rule 14 - Make AJAX Cacheable

Page 19: Performance Web com ASP.NET MVC

Anatomia de uma requisição HTTP

• DNS Lookup

• Initial Connection

– Keep-Alive Header

• Time to First Byte

• Content Download

Page 20: Performance Web com ASP.NET MVC

CSS e JS

• Bundling

• Minification

• CSS

– Header

• JS

– Assíncrono

– Mais próximo do final

Page 21: Performance Web com ASP.NET MVC
Page 22: Performance Web com ASP.NET MVC

Imagens

• Expires

– Handler

– Imagens fisicas

• Lazy Load

– Dependendo do cenário

• Sprites

• Otimizar

– RIOT

Page 23: Performance Web com ASP.NET MVC
Page 24: Performance Web com ASP.NET MVC

Dicas Rápidas

• Debug/Release

• UrlRewrite

• SQL Plano de execução

• SQL gerado ORM

• Glimpse