fisl16 :: escalabilidade - de uma máquina para múltiplos data centers
TRANSCRIPT
2014 FIFA World Cup Brazil
7 x 1 x
580Gbps x
0.5M usuários simultâneos x
~= 1600 anos assistidos (todos jogos)
Não é uma apresentação sobre
Byzantine fault, 2PC, Paxos, RAFT, Threading, Locks, Leader election, ZAB, Consensus problem, CRDTs, CALM, CAP theorem
3º dia :: load balancer
Para qual nó mandar?
E quando um nó está fora?
round-robin, least conn, weighted ...
/health_check.html, tcp:80, upd:8080
3º dia :: exemplos de LBhttp { upstream myapp1 { server srv1.example.com weight=3; server srv2.example.com; } server { listen 80; location / { proxy_pass http://myapp1; health_check uri=/health; } }}
listen appname 0.0.0.0:80 mode http stats enable balance leastconn option httpclose option forwardfor option httpchk HEAD /health HTTP/1.1 server srv1 srv1.example.com:80 check server srv2 srv2.example.com:80 check
NGINX HAProxy
3º dia :: usuário sem sessão
Nginx: sticky cookie srv_id expires=1h domain=.example.com path=/;
HAProxy: cookie srv_id insert indirect nocache
database redis, memcache, mongo…
5º dia :: banco de dados
ABCD C B
D A
B (B,C) C (C,A)
A (A,D) D (D,B)
Particionamento ReplicaçãoOriginal
5º dia :: exemplo de cachingproxy_cache_path /data/nginx/cache keys_zone=one:10m;http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
}
server {
listen 80;
proxy_cache one; location / {
proxy_cache_valid any 1m; proxy_pass http://myapp1;
}
}}
NGINX
lb1 lb2
a1
a2
Cache
c1
c2
5º dia :: + microservices
Várias aplicações (API's)
Vendas
n1
c1 c1
n1
Busca
n1
c1 c1
n1
Recomendação
n1
c1
n1
Social
n1
c1 c1
n1n1
c1
n1
c1
“Monolítica”
app: - Vendas - Busca - Recom. - Social - Transp.
5º dia :: revisando
LB
lb1
lb2
UI Vendas
UI Vendas
DB
Session
db1 db2
db3 db4
s1 s2
Cache
l1
l2
l3
API
API
BigDataBuzz
h a d
Recomendação
Busca
Social
6º dia :: modelo master / backup
● assíncrono● baixa latência● alto throughput● consistência eventual
● escrita só master
6º dia :: modelo master / master
● assíncrono● [média|alta] latência● alto throughput● cons. [eventual|forte]
PaxosRAFT
6º dia :: modelo 2PC
● no merges● síncrono● alta latência● médio throughput● consistência forte
aceite
aceite
proposta
proposta
commit
commit
6º dia :: anycast
NET Oi
TimGlobo
Anúncio: (BGP) res: 1.1.1.0/24
NET Oi
TimGlobo
Anúncio: (BGP) res: 1.1.1.0/24
1.1.1.2
6º dia :: GSLB (Global Server Load Balancing)
banana.com1.1.1.1
1.1.1.2
DNS ISP
ROOT
N th
GSLB
RTT | health check
DNS caching
RTT (latency)
DNS ISP diff. loc.
$$$ & Marketing
BR-DKC101
Resumindo...
lb1
lb2
app1app2app3
appn
DB
Session
db1
db2d
b3
db4
s2
Cachingc
1
c2
c3
s1
US-DKC102
lb1
lb2
app1app2app3
appn
DB
Session
db1
db2d
b3
db4
s2
Cachingc
1
c2
c3
s1
JP-DKC103
lb1
lb2
app1app2app3
appn
DB
Session
db1
db2d
b3
db4
s2
Cachingc
1
c2
c3
s1difíc
il
no silver bullet
sucesso
Links
Perguntas?
slideshare.net/leandro_moreiratwitter.com/lucasmundimleandromoreira.com.br
Obrigado!!!
Referências
● https://f5.com/glossary/load-balancer● http://leandromoreira.com.br/2015/04/26/fifa-2014-world-cup-live-stream-architecture/● http://leandromoreira.com.br/2014/11/20/how-to-start-to-learn-high-scalability/● http://nginx.org/en/docs/http/load_balancing.html● https://www.digitalocean.com/community/tutorials/how-to-use-haproxy-to-set-up-http-load-balancing-on-an-ubuntu-vps● https://academy.datastax.com/courses/● http://en.wikipedia.org/wiki/Single_point_of_failure● http://book.mixu.net/distsys/single-page.html● https://www.howtoforge.com/high-availability-load-balancer-haproxy-heartbeat-debian-etch-p2● http://docs.mongodb.org/manual/core/sharding-introduction/● http://docs.mongodb.org/manual/core/replication-introduction/● http://nginx.com/resources/admin-guide/caching/● https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching?hl=en● http://martinfowler.com/articles/microservices.html● http://www.netflix.com/title/70140358● http://highscalability.com/blog/2009/8/24/how-google-serves-data-from-multiple-datacenters.html● http://techblog.netflix.com/2011/11/benchmarking-cassandra-scalability-on.html● http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/
Referências● https://aphyr.com/tags/Distributed-Systems● http://pbs.cs.berkeley.edu/pbs-vldb2012.pdf● http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/36737.pdf● http://blog.empathybox.com/post/19574936361/getting-real-about-distributed-system-reliability● https://www.usenix.org/legacy/events/nsdi06/tech/full_papers/freedman/freedman.pdf● http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35590.pdf● http://tech.3scale.net/2014/06/18/redis-sentinel-failover-no-downtime-the-hard-way/● http://www.slideshare.net/gear6memcached/implementing-high-availability-services-for-memcached-1911077● http://docs.couchbase.com/moxi-manual-1.8/● http://highscalability.com/blog/2009/8/24/how-google-serves-data-from-multiple-datacenters.html● http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35590.pdf● http://static.googleusercontent.com/media/research.google.com/en//archive/chubby-osdi06.pdf● http://the-paper-trail.org/blog/distributed-systems-theory-for-the-distributed-systems-engineer/● http://nil.csail.mit.edu/6.824/2015/papers/paxos-simple.pdf● http://the-paper-trail.org/blog/consensus-protocols-paxos/● donkeykong.com● zelda.com● http://backreference.org/2010/02/01/geolocation-aware-dns-with-bind/● http://www.tenereillo.com/GSLBPageOfShame.htm● http://backreference.org/2010/02/01/geolocation-aware-dns-with-bind/