将动态子域定向到特定服务器
我们正在构建一个多租户 SAAS 应用程序。每个客户都有自己的子域,http://customername.mycompany.com。每个客户都将拥有许多千兆字节的数据,这意味着它们必须被分配到特定的服务器并留在那里。
如果我有一个服务器场,并且某个特定客户收到请求,我如何将该请求定向到正确的服务器?
我的想法是,我必须创建某种自定义的、可编程的负载均衡器,它可以知道每个客户的居住位置并通过其代理请求。
有更简单的方法吗?
如果没有,我在哪里可以找到这样的负载均衡器?我在网上找到的那些更像是设备,而不是可以查询数据库以找到正确的目标服务器的应用程序。
We're building a multitenant SAAS app. Each customer gets its own subdomain, http://customername.mycompany.com. Each customer will have many gigabytes of data, which means that they have to be assigned to a particular server and stay there.
If I have a server farm, and a request comes in for a particular customer, how do I direct the request to the right server?
My thought is that I'll have to create some kind of custom, programmable load balancer that will know where each customer lives and proxy the request through.
Is there an easier way?
If not, where do I find such a load balancer? The ones I've found online act more like appliances than applications which could go query a database to find the right destination server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为答案就在问题中;您提到用户将连接到 username.mycompany.com。因此,请使用 DNS A 记录将它们指向特定的 IP。
将来,如果您想在(例如 2 台)服务器之间对用户进行负载平衡,您可以在负载平衡器设备上创建一个虚拟 IP(例如运行 LVS),然后将 A 记录指向该虚拟 IP 由 LB 创建,并将用户分布在您配置的一组服务器上。
这就是为什么使用子域比基于 URL 的访问(例如 company.com/username)更简单,在这种情况下,您必须检查数据包的内容才能查看请求的 URL。通过使用子域,一切都可以在IP层完成。
I think the answer is in the question; you mention that the user will connect to username.mycompany.com. So use a DNS A record to point them to a particular IP.
In the future, if you wanted to load balance the user across (say 2) servers, you could create a virtual IP on a load balancer appliance (running LVS for example), and then point the A record to the Virtual IP created by the LB, and distribute the user across a group of servers that you have configured.
This is why using subdomains is simpler than having URL based access such as company.com/username, in which case you would have to inspect the content of the packet to see the requested URL. By using subdomains, everything can be done at the IP layer.