Date post: | 08-Jan-2017 |
Category: |
Internet |
Upload: | chau-thanh |
View: | 146 times |
Download: | 0 times |
Design a scalable site:Problems and Solutions
Châu Nguyễn Nhật ThanhHead of Game Backend and CloudVNG Corp.
How to scale
● Optimize at node– Maximize the performances at node
● Scale to multiples nodes– How to scale ?
● Scale UP● Scale OUT
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
2. Client to ISP
● CDN (Content Delivery Network)– Redirect (302)
– DNS server● Content in ISP DC● Return IP of ISP near your devices
3.ISP Problem
● Routing– Internal ISP
– Cross ISP● Capacity of lease line between 2 ISPs● Traffic monitoring
– 3G/4G users● Telco routing
4.ISP to DC Problem
● Routing– DC to ISP
– Internal DC● FW● Network hardware capability● Cross product routing
– Bandwidth– FW
– SDN ????
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
● 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
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/improving-the-linux-kernel-with-upstream-contributions/
7. Application Problems
● Caching– Local Cache
● Use Data structure
– External Cache● Memcache● Redis
– Caching algorithm● LRU● FIFO● ….
7. Application Problems
● Data serialize– Text Protocol
● Json, XML
– Binary● Thrift, Protobuff …
– Compression● Snapy, ZIP, GZIP
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