Upload
vandien
View
223
Download
0
Embed Size (px)
Citation preview
Distributed Denial of Service VS Caching & Loadbalancing Stefan Behte
Armin Pech
Babiel GmbH
curl [email protected]/2016/02/23?no=2
talk@
Vorzeichen Politische Geschehnisse Social Media Twitter-Meldungen
Pastebin
Verteilung vk.com
6
Angriff: Web-LOIC GET /?id=1300380622178&msg=We%20Are%20Legion! HTTP/1.1
Host: www.bundestag.de
User-Agent: Mozilla/5.0 (X11; Linux x86_64) Firefox/8.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Referer: http://pastebin.com/RrsXbQ.html
14
Gegenmaßnahmen - Maybe Null-Routing BGP-Community Deaktivieren
Wirtschaftlichkeit
SLA
DNS Fast-Flux
22
Gegenmaßnahmen - Do On-Premise 1GE/10GE Performance erhöhen Appliance
Horizontal skalieren Mehr Hardware, VMs
Frühstmöglich blockieren Loadbalancer Meldung an vorgeschaltete Firewall 23
Gegenmaßnahmen - Do Transitprovider Transit ACL Separieren DDoS-Appliance Prävention
Proxy-Provider CloudFlare Akamai
25
Gegenmaßnahmen - Do L7 Üblich
Redirect Javascript Captcha
Möglich geoip Proof-of-Work
Präventiv POST WordPress Pingback XMLRPC
28
HTTP: Protokoll Zustandslos Requests On-Demand Latenz + Verfügbarkeit
Gleiche Ressourcen in mehreren Seiten Optimierungen Pipelining + Keep-Alive
Caching, Seiten aufteilen 37
HTTP: Request Header GET /homepage HTTP/1.1
Host: www.babiel.com
User-Agent: Mozilla/5.0 (X11; Linux)
Accept: text/html;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Connection: keep-alive
38
HTTP: Response Header HTTP/1.1 200 OK
Date: Sat, 20 Feb 2016 15:21:18 GMT
Content-Type: text/html;charset=UTF-8
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4142
39
Skalierung Caching Statische Inhalte HTML, JS, CSS Images, Blobs
Loadbalancing Backend-Server bündeln Dynamische Inhalte Formulare, Login
40
Caching: Warum + wie? Backend Hits & Last reduzieren Latenz verringern Verfügbarkeit bei Ausfall Puffer statischer Ressourcen (RAM, HDD) Reverse Proxys (Shared Cache) CDNs Browser Cache (Private Cache)
43
Caching: Matching Wann darf ein Cache ausliefern? – Matching:
Effektive URI http:// www.babiel.com /sites/home.html
HTTP Methode Caching Header Request Header (Vary) Response Freshness / Revalidierung
44
Caching: Header Cache-Control Feinkontrolle
Pragma: no-cache Caching bei HTTP/1.0 verhindern
Expires Ablaufdatum eines Objekts
Age Alter eines Objekts im Cache
45
Caching: Setup
47
fresh stale
Backend Client
Cache
Zeit -60 Zeit +60
Request
Response
Objekt im Cache
NOW
Caching: Response Timings
48
s-maxage=100 [Prio 1]
max-age=80 [Prio 2]
Expires: +110 [Prio 3]
no-store
fresh stale
no-store
max-age
max-age
Expires
Backend Client
Cache
Zeit -60 Zeit +60 NOW
Caching: Response Timings
49
Backend Client
Cache
Zeit -60 Zeit +60
no-cache
Revalidation
proxy|must-revalidate
200 304
public
private
no-cache
must-revalidate
public
private
weitere Requests
NOW
Caching: Request Timings
50
Backend Client
Cache
Zeit -60 Zeit +60
Age=90
Age=40
Age=70
min-fresh=60 30
max-age=60
max-age=60
NOW
Caching: Request Timings
51
Backend Client
Cache
Zeit -60 Zeit +60
504 only-if-cached
no-store
no-cache no-cache
no-store
If-Modified-Since
If-Match ETag
Last-Modified
Revalidation
NOW
Caching: Stopper POST-Request GET-Parameter: Variationen HTTP Authentication Hostnames ([www.] domain.de) HTTP Header Cache-Control, Pragma
Set-Cookies
52
Caching: Beispiele /page/start.html /search/query.php?string=squid /Formular.html?list_id=16
/news/status?_ts=1455134349 /sid_3B01823B471E7BD/news/index.html /render.css;jsessionid=24C2DABA15F?v=3 POST-Requests (Suche, Polling)
53
Caching: Response Debugging X-Cache: MISS from squid
X-Cache-Lookup: MISS from squid:80
Via: 1.1 varnish
Date: Sat, 20 Feb 2016 17:21:00 GMT
Last-Modified: Sat, 20 Feb 2016 17:20:00 GMT
Age: 60 54
Caching: Browser-Verhalten Browser: F5 Keine Caching Request Header Daten ggf. aus Cache
Browser: Strg + F5 Cache-Control / Pragma: no-cache Daten vom Backend
55
Caching: Angriffe POST statt GET Variation GET-Parameter Vary ausnutzen 400er HTTP Codes Zufälliger Request-Inhalt
56
Loadbalancing: Setup Backends optimal nutzen Ausfälle / Lastspitzen Backend-Anbindung HTTP / internes Protokoll Healthchecks
Verteilung der Client-Anfragen
58
Loadbalancing: Setup
61
Loadbalancer Loadbalancer Loadbalancer
NET
A A B A
Loadbalancing & Netzwerk Hardware
DNS
Loadbalancing: Dispatcher Verteilung der Requests über Backends:
Round Robin / Random Cookies / Session IDs (App) Client IP Backend Performance Redispatching bei Fehlern
62
Cache & LB: Ausblick Komplexität Abstimmung mit Entwicklern Verhalten der Anwendung kennen Request Auswertung / Tracking Caching oder Loadbalancing tunen?
64
Cache & LB: Ausblick Source-IP vs. X-Forwarded-For HTTP Codes 3XX, 4XX, 5XX cachen? Vary & User-Agent = Response Variation Fehlerseite mit Code 200 ;-( HTTPS & Caching?
65
Links und Referenzen https://tools.ietf.org/html/rfc7230 https://tools.ietf.org/html/rfc7232 https://tools.ietf.org/html/rfc7234
66
Vielen Dank für euer Interesse! talk.babiel.com/2/lb-ddos (Folien)
Verbunden bleiben: [email protected] twitter.com/Babiel facebook.com/babiel.gmbh
68