How to route a user to a specific machine using NGINX?

╄→гoц情女王★ 提交于 2019-12-11 15:52:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!