nginx - Nginx 加粘性路由方法是否适合基于路由的负载均衡?

标签 nginx load-balancing

我之前已经发布过这个问题: https://stackoverflow.com/questions/34977074/how-to-use-load-balancer-for-sockets

基本上我的要求是通过负载均衡器向特定的应用服务器发送特定的url请求。所以我正在寻找某种可以完成我的要求的负载均衡器。

我正在阅读有关 nginx plus 的内容,并找到了此链接。 https://www.nginx.com/resources/admin-guide/load-balancer/

本文档中有一个粘性路由的概念。我只是想知道它能达到我的目的吗?

最佳答案

我相信您所需要的可以通过 HAProxy 轻松完成,它比 NginX 做了更专业的负载均衡。

它有一个功能,您可以使用 ACL 将基于 URI 的特定请求定向到特定后端服务器。这是一个非常简单的示例(来自默认配置文件):

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend  main *:5000
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
    acl url_static       path_end       -i .jpg .gif .png .css .js

    use_backend static          if url_static
    default_backend             app

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
    balance     roundrobin
    server      static 127.0.0.1:4331 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
    balance     roundrobin
    server  app1 127.0.0.1:5001 check
    server  app2 127.0.0.1:5002 check
    server  app3 127.0.0.1:5003 check
    server  app4 127.0.0.1:5004 check
#---------------------------------------------------------------------

如需更多阅读,请查看official HAProxy Docs

关于nginx - Nginx 加粘性路由方法是否适合基于路由的负载均衡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35161948/

相关文章:

node.js - 使用(socket.io + RedisStore)跨多个服务器进行通信

load-balancing - 缺少 Google 云负载平衡器自定义 http header

Azure 负载均衡器警报规则

nginx - 有没有办法配置 Nginx 同时将传入请求广播到多个上游服务器?

ruby-on-rails - Phusion乘客 :Why passenger still kills rails process after set passenger_min_instances = 1?

ruby-on-rails - Rails 部署 : 4 small servers or 1 big server?

ssl - HAProxy 在 TCP 模式下对 https 404 状态代码进行健康检查

nginx 直播延迟太高 45 秒

jquery - 浏览器和 AJAX 响应 CORS header 不同

docker - Traefik:前端未定义后端