
Thanks netgames.io for endless hours of fun - riantogo
Found this hobby project on HN few days back. I had bookmarked it and played with some friends over zoom today well into the night. It was a blast. Really well built project. Thanks!<p>If the author is lurking here, would love to learn about the tech used to build it.
======
lukegt
I'm the creator of netgames.io, very glad to hear you've enjoyed yourself :).
I'd be happy to share a few details, but it's far from a shining beacon of
best practices.

At the moment it's a single node.js server using socket.io for communication
between clients and the server. The server holds the game state completely in
memory, which is updated in response to game state changes sent by each
client. The single-threadedness of node.js serialises all these changes to
form a globally consistent game state, which is pushed wholesale to clients
whenever it changes. Clients are stateless (almost), rendering only what the
game state dictates. There's no database or user accounts, everyone just has a
UUID assigned to them.

I've seen a large increase in traffic due to the current pandemic (142k users
over the last 28 days, about 40x the norm), which has put a lot of stress on
my little AWS micro (sorry about the outages). I've made a lot of performance
fixes but ultimately I'll have to make this scale across multiple servers if
growth continues. Current plan is to start games on whatever server they land
on (load-balanced), and have a master task which knows what games are being
played on what servers for the purpose of game discovery and room code
collisions.

Oh and because I was a thoroughly mislead individual when I first wrote it,
it's largely written in CoffeeScript... slowly migrating to Typescript :)

