Weitere ähnliche Inhalte
Ähnlich wie Design a scalable site: Problem and solutions (20)
Kürzlich hochgeladen (20)
Design a scalable site: Problem and solutions
- 1. Design a scalable site:
Problems and Solutions
Châu Nguyễn Nhật Thanh
Head of Game Backend and Cloud
VNG Corp.
- 3. How to scale
● Optimize at node
– Maximize the performances at node
● Scale to multiples nodes
– How to scale ?
● Scale UP
● Scale OUT
- 5. 1. Client Problems
● Web browser (HTTP)
– Static contents: js, css , image, video
– JS, CSS, image:
● minify, merge
● Compress header
– Caching:
● Expires header
● Local storage
● JS caching
- 7. 2. Client to ISP
Client Internet
1
2
3
4
Server
Kernel
App
Server
6
7
8
5
9
- 8. 2. Client to ISP
● CDN (Content Delivery Network)
– Redirect (302)
– DNS server
● Content in ISP DC
● Return IP of ISP near your devices
- 12. 3.ISP Problem
● Routing
– Internal ISP
– Cross ISP
● Capacity of lease line between 2 ISPs
● Traffic monitoring
– 3G/4G users
● Telco routing
- 13. 4.ISP to DC Problem
Client Internet
1
2
3
4
Server
Kernel
App
Server
6
7
8
5
9
- 14. 4.ISP to DC Problem
● Routing
– DC to ISP
– Internal DC
● FW
● Network hardware capability
● Cross product routing
– Bandwidth
– FW
– SDN ????
- 19. 5.Server Problems
● HA Proxy config sample
backend web-backend
balance roundrobin
server web1 web1.yourdomain.com:80 check
server web2 web2.yourdomain.com:80 check
backend blog-backend
balance roundrobin
mode http
server blog1 blog1.yourdomain.com:80 check
- 20. ● HA Proxy config sample
frontend http
bind *:80
mode http
acl url_blog path_beg /blog
use_backend blog-backend if url_blog
default_backend web-backend
- 22. 6. Kernel Problems
● Drivers for HW optimization
● Max fd
● IP forwarder
● Local FW
– Iptables
● Network IO multiplexing support ???
– EPOLL
● https://code.facebook.com/posts/938078729581886/impro
ving-the-linux-kernel-with-upstream-contributions/
- 26. 7. Application Problems
● Caching
– Local Cache
● Use Data structure
– External Cache
● Memcache
● Redis
– Caching algorithm
● LRU
● FIFO
● ….
- 27. 7. Application Problems
● Data serialize
– Text Protocol
● Json, XML
– Binary
● Thrift, Protobuff …
– Compression
● Snapy, ZIP, GZIP
- 28. 8. Application to kernel problems
Client Internet
1
2
3
4
Server
Kernel
App
Server
6
7
8
5
9
- 29. 8. Application to kernel problems
● Memory copy overhead
– Share mem
– Zero copy buffer
● IO multiplexing
– Blocking
● Process base
● Thread base
– Nonblocking
● EPOLL
● KQUEUE
● Use libevent