Вопрос про production ML
Multiple clients send pixel updates to a central server over the internet. What transport/protocol would you use and what tradeoffs matter?
Ответить самому
Сначала сформулируйте ответ как на собеседовании, затем откройте разбор и оцените себя.
Короткий ответ
For reliable ordered UI state, WebSocket over TCP is the default. For lossy high-rate rendering, UDP/WebRTC-style transport can work if updates are idempotent or sequence-numbered.
Полный разбор
For a browser or app that sends small pixel-update messages to a central server, a WebSocket over TCP is a practical default. It gives a persistent bidirectional connection, reliable delivery and in-order messages. The payload can be compact JSON at low volume or a binary format when update rate matters.
The tradeoff is latency under packet loss. TCP preserves order, so a lost packet can block later updates. If the screen is a real-time stream where stale updates can be dropped, UDP or WebRTC data channels may be better, but then the application needs sequence numbers, idempotent commands, snapshots or reconciliation.
The server should also define conflict semantics: last-write-wins by server timestamp, client sequence numbers, per-client authority or command batching. Transport alone does not solve state consistency.
Теория
Protocol choice follows the state semantics: reliable ordered commands and lossy real-time streams need different guarantees.
Типичные ошибки
- Say TCP without explaining ordering and head-of-line blocking.
- Say UDP without explaining loss, reordering and recovery.
- Ignore conflict resolution when several clients update the same pixel.
Как отвечать на собеседовании
- Start with WebSocket for product simplicity.
- Mention binary payloads only after correctness semantics are clear.