segurança e performance em serviços web - lamp
DESCRIPTION
Palestra sobre performance e segurança webTRANSCRIPT
![Page 1: Segurança e Performance em Serviços WEB - LAMP](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/1.jpg)
Performance&
Segurança Servidores WEB
Toronto Garcez
![Page 2: Segurança e Performance em Serviços WEB - LAMP](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/5.jpg)
Performance – Varnish x Squid
![Page 6: Segurança e Performance em Serviços WEB - LAMP](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/9.jpg)
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
● Youtube
● WordPress.com
![Page 10: Segurança e Performance em Serviços WEB - LAMP](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/10.jpg)
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->addServer("localhost:11211");
$resp = $mem->get("chave01");
print_r($resp);
![Page 11: Segurança e Performance em Serviços WEB - LAMP](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/12.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/14.jpg)
Segurança – WAF
![Page 15: Segurança e Performance em Serviços WEB - LAMP](https://reader034.vdocuments.pub/reader034/viewer/2022052507/558df12f1a28ab31438b4588/html5/thumbnails/15.jpg)
Perguntas?