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.
To share a quote directly taken from their website:
> By taking advantage of various well-designed Nginx modules (most of which are developed by the OpenResty team themselves), OpenResty® effectively turns the nginx server into a powerful web app server, in which the web developers can use the Lua programming language to script various existing nginx C modules and Lua modules and construct extremely high-performance web applications that are capable to handle 10K ~ 1000K+ connections in a single box.