Ask HN: The C10M Problem
Well, what if we could serve a website to 1 million users from one single machine? Here’s how:
1. Sign the sessionIds / capabilities / JWTs with a fast HMAC so requests with improperly signed tokens are dropped without doing any I/O. This can be done at the edge with CloudFlare workers.
2. Serve static HTML files that make use of Javascript that loads WebRTC. Can be cached with a CDN which uses your server as an origin
3. Use the other computers which are accessing the site at that very moment, to send each other the resources, using WebRTC!
That last part is what makes things so powerful. Rather than YOU paying for the infrastructure the most popular your site gets, the downloaders also become seeders, a la bittorrent. You can even use WebTorrent for this.
4. Keep as much of the database dencetralized among the visitors as possible. Visitors can use IndexedDB and speak to each other.
5. When you do need to persist data for offline visitors, you make sure not to use autoincrementing IDs, to prevent any bottlenecks. Instead, generate random 20-byte IDs and check if they weren’t already taken.