segurança e performance em serviços web - lamp

16
Performance & Segurança Servidores WEB Toronto Garcez

Upload: torontux-vercosa

Post on 27-Jun-2015

1.998 views

Category:

Technology


1 download

DESCRIPTION

Palestra sobre performance e segurança web

TRANSCRIPT

Page 1: Segurança e Performance em Serviços WEB - LAMP

Performance&

Segurança Servidores WEB

Toronto Garcez

Page 2: Segurança e Performance em Serviços WEB - LAMP

Performance – Load Balance e Cache

Proxy reverso Squid / Varnish Round-robin Peso (weight) Cache Escalabilidade Disponibilidade

Page 3: Segurança e Performance em Serviços WEB - LAMP

Performance – Load Balance e Cache

SQUID Suporte SSL Suporte para Antivirus Cache em disco

Page 4: Segurança e Performance em Serviços WEB - LAMP

Performance – Load Balance e Cache

Varnish Feito para CMS lentos Cache em RAM Round-robin / random Compressão (gzip) Security.VCL(Uma camada a mais, não substitui o modsec!!!!!)

Page 5: Segurança e Performance em Serviços WEB - LAMP

Performance – Varnish x Squid

Page 6: Segurança e Performance em Serviços WEB - LAMP

Performance – Elementos web

Estáticos HTML CSS JavaScript Imagens (jpg, png, gif...) Vídeos XML SWF (Flash)

Dinâmicos PHP, ASP, ...

Não é preciso carregar o PHP e seus módulos para entregar objetos estáticos!Consumo desnecessário de memória

Page 7: Segurança e Performance em Serviços WEB - LAMP

Performance – Separação de requisições

Lighttpd

CSS, JS, PNG, JPEG, HMTL ...

if ( req.http.host && req.request == "GET" && req.url ~ "\.(gif|jpg|jpeg|bmp|png|tiff|tif|ico|img|tga|wmf|html|js|swf|css)$")

{ set req.backend = servidor_lighttpd; }

Page 8: Segurança e Performance em Serviços WEB - LAMP

Performance – Mod_cache Apache

Cache Cache Cache

Mod_cache mod_disk_cache<IfModule mod_disk_cache.c> CacheRoot /var/cache/apache2/mod_disk_cache CacheEnable disk / CacheDirLevels 5 CacheDirLength 3</IfModule>

mod_mem_cache

<IfModule mod_mem_cache.c> CacheEnable mem / MCacheSize 4096 MCacheMaxObjectCount 100 MCacheMinObjectSize 1 MCacheMaxObjectSize 2048</IfModule>

Page 9: Segurança e Performance em Serviços WEB - LAMP

Performance – Memcached

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Users

● Wikipedia

● Flickr

● Twitter

● Youtube

● WordPress.com

Page 10: Segurança e Performance em Serviços WEB - LAMP

Performance – Memcachedbom vamos a um exemplo

$mem = new Memcache;

$mem->addServer("localhost:11211");

$mem->set("chave01", $array, TRUE, 60);

No exemplo acima, eu estou armazenando na chave01 meu array por 60 segundos.

Agora para pegar esse conteúdo, você deve usar a função get. Vamos ao exemplo.

$mem = new Memcache;

$mem-&gt;addServer("localhost:11211");

$resp = $mem->get("chave01");

print_r($resp);

Page 11: Segurança e Performance em Serviços WEB - LAMP

Performance – MySQL

Cache

/etc/my.cnfquery_cache_type=1 # Habilita o cachequery_cache_limit=10M # Tamanho máximo por consultaquery_cache_size=100M # Tamanho do cache

Temporary Tables

/etc/my.cnftmpdir = /disco2 #Disco rápido

Page 12: Segurança e Performance em Serviços WEB - LAMP

Performance – Geração de HTMLs

SCRIPT PHP – Colocar no cronphp -f /scripts/gera_html.php

<?php // Portal $vHtml = file_get_contents('http://www.site.com/index.php?'.rand(0,1000000)); if(!empty($vHtml)) file_put_contents('/var/www/html/index.html', $vHtml); ?>

Apache<VirtualHost *:80> ... DirectoryIndex index.html index.php</VirtualHost>

Page 13: Segurança e Performance em Serviços WEB - LAMP

Performance – CDN

30% tráfego da internet

● Akamai ● Ananke CDN● Azion● CDNetworks● CDN77● EdgeCast Networks● Limelight Networks

Page 14: Segurança e Performance em Serviços WEB - LAMP

Segurança – WAF

Page 15: Segurança e Performance em Serviços WEB - LAMP

Perguntas?

Page 16: Segurança e Performance em Serviços WEB - LAMP

Contato: [email protected]

Obg! :)