Growing X20 without
spending an extra
penny on hosting
Dor Kalev, CTO @ FTBpro
Largest fan-generated media platform in
global football
130m pageviews / month
a Football fan #musthave
1M+ mobile installs
Content is king
Single Page Application
Phantom.js renders pages on the server-side for SEO,
crawlers and mobile web performance
Load Bala...
How do we scale
post pages?
Each Render Server can return
1 client request at a time
1:1
Client
Server

Render
Linear correlation between
clients and servers
1:1
Client
Server

Render
Client
Server

Render
A cache server can handle
over x10 more traffic
10:1:1
Cache
Server
Render
Client
Client
Client
Client
Client
Client
Client...
Cache server still consumes CPU and
with more traffic, more servers are needed
20:2:1
Cache
Server
Render
Cache
Client
Clie...
Accelerator like NGINX+MemCached or
Varnish can be x100 more efficient than
plain App Server Cache
100:1:1
Server
Render
Ac...
200:2:1
Server
Render
Accelerator
Accelerator
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client...
Enter CDN
∞:1
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Cli...
Client
Client
My
Tiny
Server
PoP
CDN
SERVER
CDN
SERVER
CDN
SERVER
PoP
CDN
SERVER
CDN
SERVER
CDN
SERVER
PoP
CDN
SERVER
CDN
...
What’s a CDN?
• Content Delivery Network
• A set of autonomic distributed cache servers
• Serve cache from a location geog...
Enter Trouble
∞:1
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client
Client...
Fixing minor Typo?

Need to Refresh Cache??
TTL vs. ON CHANGE
Cache Policy
Purge by URL can take over an
hour on classic CDNs
Z
Z
Z
Purge by TTL - isn’t realtime &
causes redundant server hits
CPULOAD
0
7.5
15
22.5
30
TIME
1 2 3 4 5 (TTL) 6 7 8 9 (TTL) 1...
multiply by all articles
CPULOAD
0
7.5
15
22.5
30
TIME
1 2 3 4 5 (TTL) 6 7 8 9 (TTL) 10 11 12
TTL = Constant waste of CPU
CPULOAD
0
7.5
15
22.5
30
TIME
1 2 3 4 5 6 7 8 9 10 11 12
Better Solution?
abuse new CDN
technologies
Super Fast Purge + Smart API!
!
!
!
!
!
e.g. Fastly, EdgeCast
cache forever +

purge on demand
0
7.5
15
22.5
30
1 (release) 2 3 4 5 6 7 8 9 (purge) 10 11 12
fast purge at ~10-45 seconds
Advantages
• ∞ scaling
• cheap
• fast
• keep the stack simple
Caveats
• Purging everything can lead to downtime, e.g.
when deploying
• User Specific content can’t be cached with the
ent...
Massive Push Notification + cold CDN
Cache = traffic goes to app servers
CPULOAD
0
250
500
750
1000
TIME
1 (PN) 2 3 4 5 6 7 ...
Client
Client
My
Tiny
Server
PoP
CDN
SERVER
CDN
SERVER
CDN
SERVER
PoP
CDN
SERVER
CDN
SERVER
CDN
SERVER
PoP
CDN
SERVER
CDN
...
Client
Client
CACHE
PoP
CDN
SERVER
CDN
SERVER
CDN
SERVER
PoP
CDN
SERVER
CDN
SERVER
CDN
SERVER
PoP
CDN
SERVER
CDN
SERVER
CD...
CPU vs TRAFFIC
• 13:53 preloaded post to CDN
• 13:55 PN sent
• 13:57+ traffic stops @ CDN servers, no CPU throughput
• 14:0...
14:00 Laugh a maniacal laugh of satisfaction
Summary
• CDN allows massive scale
• Smart CDN usage allows even more scale
• Scale + fresh content + low hosting prices i...
Read More…
• Growing X20 without spending an extra penny on
hosting (The original blog post)

http://tech.ftbpro.com/post/...
Prochain SlideShare
Chargement dans…5
×

Growing X20 without spending an extra penny on hosting

337 vues

Publié le

A year ago we started a big change in FTBpro. We completely changed the visual design, moved to a single page architecture and started exploring new ways to minimise load on our servers - both when serving our actual website, and mobile API responses.We'll focus on how scaling considerations are now an integral part of our architecture, which enabled us to serve 20x more traffic than we did 1 year ago, with the same setup and with no additional costs.

Publié dans : Technologie
0 commentaire
1 j’aime
Statistiques
Remarques
  • Soyez le premier à commenter

Aucun téléchargement
Vues
Nombre de vues
337
Sur SlideShare
0
Issues des intégrations
0
Intégrations
3
Actions
Partages
0
Téléchargements
2
Commentaires
0
J’aime
1
Intégrations 0
Aucune incorporation

Aucune remarque pour cette diapositive

Growing X20 without spending an extra penny on hosting

  1. 1. Growing X20 without spending an extra penny on hosting Dor Kalev, CTO @ FTBpro
  2. 2. Largest fan-generated media platform in global football 130m pageviews / month
  3. 3. a Football fan #musthave 1M+ mobile installs
  4. 4. Content is king
  5. 5. Single Page Application Phantom.js renders pages on the server-side for SEO, crawlers and mobile web performance Load Balancer Memcached Redis Web 1 Web 2 Web 3 MySQL MongoDB ElasticSearch Amazon Web Services NginX + Ruby on Rails PhantomJS Web 4
  6. 6. How do we scale post pages?
  7. 7. Each Render Server can return 1 client request at a time 1:1 Client Server
 Render
  8. 8. Linear correlation between clients and servers 1:1 Client Server
 Render Client Server
 Render
  9. 9. A cache server can handle over x10 more traffic 10:1:1 Cache Server Render Client Client Client Client Client Client Client Client Client Client Client Client
  10. 10. Cache server still consumes CPU and with more traffic, more servers are needed 20:2:1 Cache Server Render Cache Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client
  11. 11. Accelerator like NGINX+MemCached or Varnish can be x100 more efficient than plain App Server Cache 100:1:1 Server Render Accelerator Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client https://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/ https://www.varnish-cache.org
  12. 12. 200:2:1 Server Render Accelerator Accelerator Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Accelerator also runs on limited hardware and needs more CPU in order to scale
  13. 13. Enter CDN ∞:1 Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client CDN Server Render
  14. 14. Client Client My Tiny Server PoP CDN SERVER CDN SERVER CDN SERVER PoP CDN SERVER CDN SERVER CDN SERVER PoP CDN SERVER CDN SERVER CDN SERVER Client Client Client Client Client Client Client What’s a CDN?
  15. 15. What’s a CDN? • Content Delivery Network • A set of autonomic distributed cache servers • Serve cache from a location geographically close to the client • e.g: Akamai, Cloudflare, Fastly, Highwinds, Edgecast, Cloudfront
  16. 16. Enter Trouble ∞:1 Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client Client CDN Server Render
  17. 17. Fixing minor Typo?
 Need to Refresh Cache??
  18. 18. TTL vs. ON CHANGE Cache Policy
  19. 19. Purge by URL can take over an hour on classic CDNs Z Z Z
  20. 20. Purge by TTL - isn’t realtime & causes redundant server hits CPULOAD 0 7.5 15 22.5 30 TIME 1 2 3 4 5 (TTL) 6 7 8 9 (TTL) 10 11 12
  21. 21. multiply by all articles CPULOAD 0 7.5 15 22.5 30 TIME 1 2 3 4 5 (TTL) 6 7 8 9 (TTL) 10 11 12
  22. 22. TTL = Constant waste of CPU CPULOAD 0 7.5 15 22.5 30 TIME 1 2 3 4 5 6 7 8 9 10 11 12
  23. 23. Better Solution?
  24. 24. abuse new CDN technologies Super Fast Purge + Smart API! ! ! ! ! ! e.g. Fastly, EdgeCast
  25. 25. cache forever +
 purge on demand 0 7.5 15 22.5 30 1 (release) 2 3 4 5 6 7 8 9 (purge) 10 11 12
  26. 26. fast purge at ~10-45 seconds
  27. 27. Advantages • ∞ scaling • cheap • fast • keep the stack simple
  28. 28. Caveats • Purging everything can lead to downtime, e.g. when deploying • User Specific content can’t be cached with the entire page • Downtime on massive Push Notifications
  29. 29. Massive Push Notification + cold CDN Cache = traffic goes to app servers CPULOAD 0 250 500 750 1000 TIME 1 (PN) 2 3 4 5 6 7 8 9 10 11 12
  30. 30. Client Client My Tiny Server PoP CDN SERVER CDN SERVER CDN SERVER PoP CDN SERVER CDN SERVER CDN SERVER PoP CDN SERVER CDN SERVER CDN SERVER Client Client Client Client Client Client Client Render (or cache & serve) X number of calls
 in parallel = self-DDoS
  31. 31. Client Client CACHE PoP CDN SERVER CDN SERVER CDN SERVER PoP CDN SERVER CDN SERVER CDN SERVER PoP CDN SERVER CDN SERVER CDN SERVER Client Client Client Client Client Client Client Solution: Another local cache layer & Preload CDN
 (few CDNs have this feature, e.g. EdgeCast) My Tiny Server
  32. 32. CPU vs TRAFFIC • 13:53 preloaded post to CDN • 13:55 PN sent • 13:57+ traffic stops @ CDN servers, no CPU throughput • 14:00 …
  33. 33. 14:00 Laugh a maniacal laugh of satisfaction
  34. 34. Summary • CDN allows massive scale • Smart CDN usage allows even more scale • Scale + fresh content + low hosting prices is a do-able mission ! Questions?
  35. 35. Read More… • Growing X20 without spending an extra penny on hosting (The original blog post)
 http://tech.ftbpro.com/post/78969626647/growing-x20-without-spending-an-extra-penny-on-hosting • Single Page Applications Done Right
 http://tech.ftbpro.com/post/84720180206/single-page-applications-done-right • Count von Count - Real time counting DB
 http://tech.ftbpro.com/post/73212710968/count-von-count-a-real-time-counting-database • The Dark Side of Single Page Applications
 http://tech.ftbpro.com/post/66182501420/the-dark-side-of-single-page-applications-rails OSS: http://github.com/ftbpro
 BLOG: http://tech.ftbpro.com

×