问题
I was recently reading this article from the Figma engineering blog: https://www.figma.com/blog/rust-in-production-at-figma/ and was curious about their NGINX setup for multiplayer routing. This is how it looks:
Where they have M number of servers, and where each server has W number of workers. Figma lets users collaborate on design documents in real-time, and each document (i.e. the logic that takes care of the real-time multiplayer processing for each doc) always lives in one specific worker.
I’m wondering how they manage to always route users to the machine that has the worker for the document being worked on, and then to the specific process that actually has the doc.
They do this with NGINX, but my question is how?
I know that NGINX has round-robin and ip_hash methods to load balance, but that’s not granular enough to achieve what they do.
Related question: Route traffic to multiple node servers based on a condition
回答1:
You should be able to use a cookie to associate a user with the downstream node: https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/#enabling-session-persistence
来源:https://stackoverflow.com/questions/59020580/how-to-route-a-user-to-a-specific-machine-using-nginx