Beautiful architecture. Startups and companies like Netflix should learn from this instead of cargo culting microservices.
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.
What happens when you make a move in lichess.org?
51–60 of 162 posts
Re: What happens when you make a move in lichess.org?
#52nit: fen only encodes board state, not game state Edit: also includes move count but not repetition.
How is the game state not just the board state? Move history doesn’t matter in chess (FEN encodes the 50 move rule)
https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notati...
Re: What happens when you make a move in lichess.org?
#53Earlier quoted context omitted.
> Unfortunately, I'm afraid, drawing something like that during interview may not land a job at faang =( Yet another reason to be skeptical of the quality of hiring in faang if anything.
Why feel anything about it at all? You work at FAANG: be glad for the money or quit if there isn't any. You don't work at FAANG: bad hiring makes it easier for you to get hired and make money.
My criticism was mostly towards the very poor metrics these companies have introduced behind hiring, albeit I can understand that given the gigantic amount of applications they get a mechanism for removing false positives is acceptable even if missing on false negatives.
And even more that it spread to companies that do not have their problems and can't afford false negatives.
Re: What happens when you make a move in lichess.org?
#54Re: What happens when you make a move in lichess.org?
#55nit: fen only encodes board state, not game state Edit: also includes move count but not repetition.
How is the game state not just the board state? Move history doesn’t matter in chess (FEN encodes the 50 move rule)
Re: What happens when you make a move in lichess.org?
#56I 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…
Vladimir Kramnik agrees with your observations about chesscom.
Re: What happens when you make a move in lichess.org?
#57Earlier quoted context omitted.
Overly complicated with microservices. Can be made 10x simpler.
Sometimes simplicity is not the best goal. Redundancy, scalability, decoupling, resilience, best possible handling of errors, cost optimization, etc. may be more important at the scale Netflix operates at.
Re: What happens when you make a move in lichess.org?
#58- "While these moves could be calculated client-side, providing them server-side ensures consistency - especially for complex or esoteric chess variants - and optimizes performance on clients with limited processing capabilities or energy restrictions." Just a wild guess: might be intended to lower the implementation barrier for new open-source software clients on new platforms, and/or preempt them from implementing…
For those curious about the illegal move, it seems like it's allowing queen side castling through the king side rook (or vice versa). eg. if this is the first rank, R _ _ R K _ _ _, then you could make the move O-O-O and end up with _ _ _ R K _ _ _ Naturally, it's not possible to view this move anymore, but this game ( https://lichess.org/XDQeUk6j#48 ) has everything up until the last legal move right before the ille…
Re: What happens when you make a move in lichess.org?
#59I don't understand why the author didn't just look this up in the source code. Lichess is open source and we can see exactly what this field is here, it's the average lag:
https://github.com/lichess-org/lila/blob/45b5f0cfbbf6c045ad7...
send = (t: string, d: any, o: any = {}, noRetry = false): void => {
const msg: Partial = { t };
if (d !== undefined) {
if (o.withLag) d.l = Math.round(this.averageLag);
if (o.millis >= 0) d.s = Math.round(o.millis * 0.1).toString(36);
msg.d = d;
}
if (o.ackable) {
msg.d = msg.d || {}; // can't ack message without data
this.ackable.register(t, msg.d); // adds d.a, the ack ID we expect to get back
}
const message = JSON.stringify(msg);
...
Which is calculated from how long the server takes to respond to ping messages that the client sends: private schedulePing = (delay: number): void => {
clearTimeout(this.pingSchedule);
this.pingSchedule = setTimeout(this.pingNow, delay);
};
private pingNow = (): void => {
clearTimeout(this.pingSchedule);
clearTimeout(this.connectSchedule);
const pingData =
this.options.isAuth && this.pongCount % 10 == 2
? JSON.stringify({
t: 'p',
l: Math.round(0.1 * this.averageLag),
})
: 'null';
try {
this.ws!.send(pingData);
this.lastPingTime = performance.now();
} catch (e) {
this.debug(e, true);
}
this.scheduleConnect();
};
private computePingDelay = (): number => this.options.pingDelay + (this.options.idle ? 1000 : 0);
private pong = (): void => {
clearTimeout(this.connectSchedule);
this.schedulePing(this.computePingDelay());
const currentLag = Math.min(performance.now() - this.lastPingTime, 10000);
this.pongCount++;
// Average first 4 pings, then switch to decaying average.
const mix = this.pongCount > 4 ? 0.1 : 1 / this.pongCount;
this.averageLag += mix * (currentLag - this.averageLag);
pubsub.emit('socket.lag', this.averageLag);
this.updateStats(currentLag);
};Re: What happens when you make a move in lichess.org?
#60I 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…
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?