Live data from Hacker News

What happens when you make a move in lichess.org?

davidreis.me

81–90 of 162 posts

Re: What happens when you make a move in lichess.org?

#81

how would you protect your websocket server? I am building a game, but when I put the domain behind (free plan) cloudflare, I get latency delay (3x slower) on the players events. Saw CF had some paying solution, but was wondering about a free solution

I've been managing game servers that get attacked on a daily basis for almost a decade. I've tried Cloudflare a few times (on their business plan) and seen poor results every time.

Cloudflare has a lower latency product called Argo Smart Routing [1]. When we tried Argo in 2020, we still saw 10+ ms increased latency across the board, which is unacceptable for competitive multiplayer games. That said, Discord voice still (or used to) uses Argo for voice, so there are certainly less latency-sensitive games where it would work well.

The other issue with sockets over Cloudflare (circa 2020 on business plan) is they get terminate liberally with the assumption you have a reconnection mechanism in place. I'd imagine this is acceptable for traditional WebSocket use cases, but not for games.

Services like OVH & Vultr also advertise "DDoS protection for games," but I've found these to be pretty useless in practice. We can only measure traffic that reaches our game servers, so I have no way of knowing if they're actually helping at all.

Your best bet is getting familiar with iptables and fine-tuning rules to match your game's traffic patterns. Thankfully, LLMs are pretty good at generating these rules for you nowadays if you're not already familiar with these tools. Make sure to set up something like node-exporter to be able to monitor attacks and understand where things go wrong. There have been a few other posts on HN in the past that go into more depth about game server DoS mitigation [2] [3].

I built something in the same vein for my startup (Apache 2.0 OSS, steal our code!) [4] that runs a series of load balancers in front of game servers in order to act like a mini-Cloudflare. In addition to the basics I already listed, we also have logic under the hood that (a) dynamically routes traffic to load balancers and (b) autoscales hardware based on traffic in order to absorb attacks. We're rolling out a dynamic bot attack & mitigation mechanism soon to handle more complex patterns.

[1] https://www.cloudflare.com/application-services/products/arg...

[2] https://news.ycombinator.com/item?id=35771466

[3] https://news.ycombinator.com/item?id=28675094

[4] https://github.com/rivet-gg/rivet

Re: What happens when you make a move in lichess.org?

#82

Earlier quoted context omitted.

Embarrassing. I built 99% of Netflix functionality locally with VLC and a subdirectory of mkv files.

Good for you. Now please aim 10,000 requests a second at your file server.

Because I don't use microservices, I don't need 10,000 requests a second to play a video file.

Re: What happens when you make a move in lichess.org?

#83
post #46

Earlier quoted context omitted.

Hello, fellow Patron! Even though nowadays I hardly have time to play, I'm still happy to support such a delightfully honorable and usable(!) open-source project.

People love mentioning that they donate to LiChess. It's a weird trend. Altruism truly does not exist (I donated btw) (Probably more than you) (But who's counting)

You must be fun at parties.

Re: What happens when you make a move in lichess.org?

#84

I wish this discussed the timing arbitration of each move. Based on the packet information (if that is correct & complete) then the timing is done entirely on the clients. However, they show the time in seconds which can't be right so I am curious how accurate this packet schema is (or if those are float values). Regardless, one thing I find maddening about chess.com is the time architecture of the game. I haven't se…

> they show the time in seconds which can't be right Seems right. If you export/download games from lichess, they use the .pgn (Portable Game Notation) format, which is a standard plain-text format circa 1993, used by pretty much everyone for describing a chess game. Lichess follows the specification to the letter, and as it only technically allows one-second accuracy, lichess only record moves with one-second accura…

> lichess only record moves with one-second accuracy

According to this blog post, this doesn't appear to be the case since at least 2017:

https://lichess.org/@/lichess/blog/a-better-game-clock-histo...

"Move times are now stored and displayed with a precision of one tenth of a second. The precision even goes up to one hundredth of a second, for positions where the player had less than 10 seconds left on their clock."

Re: What happens when you make a move in lichess.org?

#86
post #60

I wish this discussed the timing arbitration of each move. Based on the packet information (if that is correct & complete) then the timing is done entirely on the clients. However, they show the time in seconds which can't be right so I am curious how accurate this packet schema is (or if those are float values). Regardless, one thing I find maddening about chess.com is the time architecture of the game. I haven't se…

> it feels like the SERVER is tracking the time TBH this is what I expected for all online chess. How else to reconcile the two players' differing clocks and also prevent client-side cheating?

I guess my naive frustration comes from crazy fps games tracking things so precisely and yet somehow Chess.com can’t handle a turn based game?! Honestly.

I do recognize that fps games utilize predictive algorithms and planning to estimate future player positions but still, turn based networking with 100ms accuracy should be a solved problem

Re: What happens when you make a move in lichess.org?

#87
post #73

Earlier quoted context omitted.

I'm pretty sure freechess.org did.

How is it being done client side?

Well it's a long time since I played there. But it had custom chess clients, which I assume just recorded how much time your move actually took and sent that with the move.

Yes, it's easy to cheat with this, but it's very easy to cheat with chess anyway.

Re: What happens when you make a move in lichess.org?

#88
post #51
post #24

Earlier quoted context omitted.

And what exactly do you think lila, lila-ws, and redis are if not microservices (or as they should be called, “services”)? Lichess could easily be implemented as a single monolithic process but it is not.

They are services, but not micro. lila-ws spun off of Lila for a good reason (fault isolation) and not because "let's make everything a service". And they don't follow any standard microservice pattern - a reverse proxy isn't a microservice.

https://github.com/lichess-org/lila?tab=readme-ov-file#produ...

Re: What happens when you make a move in lichess.org?

#89

I wish this discussed the timing arbitration of each move. Based on the packet information (if that is correct & complete) then the timing is done entirely on the clients. However, they show the time in seconds which can't be right so I am curious how accurate this packet schema is (or if those are float values). Regardless, one thing I find maddening about chess.com is the time architecture of the game. I haven't se…

What I'd love is for my pre-moves to be sent to the server immediately so I don't time out when I pre-moved.

Re: What happens when you make a move in lichess.org?

#90
post #84

Earlier quoted context omitted.

> they show the time in seconds which can't be right Seems right. If you export/download games from lichess, they use the .pgn (Portable Game Notation) format, which is a standard plain-text format circa 1993, used by pretty much everyone for describing a chess game. Lichess follows the specification to the letter, and as it only technically allows one-second accuracy, lichess only record moves with one-second accura…

> lichess only record moves with one-second accuracy According to this blog post, this doesn't appear to be the case since at least 2017: https://lichess.org/@/lichess/blog/a-better-game-clock-histo... "Move times are now stored and displayed with a precision of one tenth of a second. The precision even goes up to one hundredth of a second, for positions where the player had less than 10 seconds left on their clock."

Interesting. Thanks for the correction and link. I'll note though the .pgn downloads still only show 1 second precision, as do the game PGNs in lichess's "open database" archive.
Post reply on HN