41 ms·
I'm using Google Cloud Platform. There are three servers - Australia, EU and US. The Google Cloud load balancer automatically connects people to the closest one
by BSTRhino 8y ago
I'm using Google Cloud Platform. There are three servers - Australia, EU and US. The Google Cloud load balancer automatically connects people to the closest one. I had to do some special things to make websockets work correctly - configured session affinity (with a cookie) and the HTTP timeout has to be set to a large number. It costs around $150 US a month, which means at some point I will probably stop running the game because that's a lot.
The entire game is simulated on the client. It is a deterministic simulation, so the same sequence of inputs will generate the same state. The server doesn't do any of the simulation at all, it just passes the action sequence to all the clients. Every 32 milliseconds the server wraps up all the messages received and sends them to all clients in the game as the next frame. I used the nanotimer library in NodeJS to get this 32 millisecond interval as accurate as possible. Because the server does none of the computation, it theoretically can support lots of clients. I don't know how many yet, but maybe a thousand? Even at its peak usage of 40 users yesterday it was still only taking about 1-2 milliseconds to do each frame.
- dvh 8y ago$150 for 40 users is quite a lot, is it fixed rate or will it rise when DAU rises?