top4top showcase
DESCRIPTION
A showcase for higher payloads.TRANSCRIPT
![Page 1: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/1.jpg)
Scaling for Higher Payload
![Page 2: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/2.jpg)
Top4top.ru should be able to sustain
1,000,000 visitors daily, if need be.
But we don’t need to spend money to sustain payload we don’t have.
![Page 3: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/3.jpg)
GoalNormal day Rainy day
A single $70/month Amazon server.
At least 100,000 users with 500,000 pv
daily.
Average pageload time—50 ms.
Lots of Amazon servers.
At least 1,000,000 users with 5,000,000
pv daily.
Average pageload time—50 ms.
![Page 4: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/4.jpg)
Normal Day
![Page 5: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/5.jpg)
Normal Day // Cache
1 day1 day 10 minutes10 minutes
1 day1 day
1 day1 day
5 minutes5 minutes10 10
minmin
Different blocks have different cache renewal intervals. Naturally, any of these blocks is also updated whenever its content is updated.
![Page 6: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/6.jpg)
Normal Day // Cache
![Page 7: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/7.jpg)
Normal Day // Cache
Administrators should be able to edit posts in this block. Thus, no caching for administrators here.
![Page 8: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/8.jpg)
Normal Day // Cache
![Page 9: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/9.jpg)
Let’s Test It!Normal day, 1 server in Ireland, the client is 10 hops away on a 10 Mbit channel
![Page 10: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/10.jpg)
Normal Day // Infrastructure
nginx
apache + passenger
rails
mySQL memcache
Nginx takes clients’ requests & serves static stuff: images, css, js. By default
nginx balances to its own apache
Passenger launches new instances of rails daemons if need be.
![Page 11: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/11.jpg)
Normal Day // Even Faster
nginx is used to serve static stuff, meaning 253 kilobytes of 260 kilobytes for the homepage. Only 7 kilobytes are served deeper than that.
apache + passengerlaunches rails instances to certain limit. After that we switch to the ‘Rainy Day’ mode.
gzip’dAll texts, scripts are gzipped and are served this way to the clients that are able to comply.
exprsAll files and images have their ‘expires’ headers set to distant future.
ETags Whenever a client asks for a not modified page, it gets ‘304 Not Modified’ and the page is being served from cache.
rn Some of the static is served using the same server, but different filenames for a client to be able to download more than two files simultaneously.
![Page 12: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/12.jpg)
Normal Day // Homepage Traffic
![Page 13: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/13.jpg)
Normal Day // nginx config
![Page 14: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/14.jpg)
Normal Day // nginx config
![Page 15: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/15.jpg)
Normal Day // nginx config
![Page 16: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/16.jpg)
Rainy Day
![Page 17: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/17.jpg)
Rainy Day // Infrastructure
After certain limit, the base nginx starts to balance across several servers, each of which runs the very same application,
deployed via cloning.
It’s cloud computing, baby!
![Page 18: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/18.jpg)
Rainy Day // Infrastructure
nginx
apache + passenger
apache + passenger
apache + passenger
apache + passenger
![Page 19: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/19.jpg)
Rainy Day // Infrastructure
If it’s not enough, the main server begins to serve as base only, shutting down its own
apache.
![Page 20: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/20.jpg)
Rainy Day // Infrastructure
nginx apache + passenger
apache + passenger
apache + passenger
![Page 21: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/21.jpg)
Rainy Day // Infrastructure
The final step is to isolate MySQL. Now we’re able to serve millions of pageviews
for $350 per month.
![Page 22: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/22.jpg)
Rainy Day // Infrastructure
nginx apache + passenger
apache + passenger
apache + passenger
MySQL
![Page 23: Top4top Showcase](https://reader035.vdocuments.net/reader035/viewer/2022062513/554bb84db4c90530298b497c/html5/thumbnails/23.jpg)
Rainy Day // Cloning
top4top
top4top-1
top4top-2
top4top-3
3 additional servers
in 5 minutes!