You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于ARR实现双服务器IIS多应用多端口负载均衡配置咨询

Hey there! Let's walk through setting up your two IIS apps with ARR load balancing step by step—this is totally manageable once we break it down into clear tasks:

1. Prep Your Two Application Servers

First, make sure both servers (let's call them Server X and Server Y for clarity) are running a supported Windows Server version (2019 or 2022 works best). Then:

  • Install IIS on each server: Open Server Manager, go to Add Roles and Features, check Web Server (IIS) in the roles list, and follow the wizard. Don't forget to add any app-specific features (like ASP.NET Core if your apps use .NET Core) during setup.
2. Deploy app1 and app2 to Both Servers

On each application server, set up the two apps via IIS Manager:

  • Right-click Sites > Add Website
    • For app1:
      • Name it app1
      • Point the physical path to your app1's code directory
      • Set the port to 789, leave the hostname blank (we'll use port numbers to distinguish apps), then click OK
    • Repeat the process for app2, setting the port to 790
  • Test each app locally first: On the server, open a browser and go to http://localhost:789 and http://localhost:790 to confirm they load. Then test from another machine using http://[Server-IP]:789 to ensure network connectivity.
3. Install ARR on Your Load Balancer Server

You'll need a dedicated load balancer (LB) server (or you can use one of your app servers for testing, but a separate server is better for production). First install IIS on the LB, then:

  • Open IIS Manager, select the server name, and look for Web Platform Installer in the IIS section (if you don't have it, install it first via Windows features or official Microsoft tooling).
  • Search for Application Request Routing 3.0 in the Web Platform Installer, select it, and click Install. Follow the prompts to finish setup.
  • Restart IIS Manager, and you'll see a new Server Farms node—this is where we'll configure load balancing.
4. Configure ARR Server Farms for app1 and app2

We'll create two separate server farms: one for app1 (forwarding to port 789) and one for app2 (forwarding to port 790).

Set Up the app1 Server Farm

  • Right-click Server Farms > Create Server Farm
    • Name it App1-Servers, check Enable proxy, then click Next
    • Add the IP addresses (or hostnames, if DNS resolves them) of your two app servers, then click Next > Finish
  • Now configure the farm to route to port 789:
    1. Select App1-Servers, go to the Proxy tab
    2. Under Forwarding, set the Forward URL to http://{SERVER_ADDRESS}:789 (the {SERVER_ADDRESS} variable will automatically use the backend server IPs you added)
  • Configure load balancing behavior:
    • Go to the Load Balance tab, pick an algorithm (Round Robin is default and works for most cases; Least Connections is better if your apps have long-running requests)
  • Set up health checks (critical for failover):
    • Go to the Health Test tab, set the Test URL to / (or a specific health check endpoint your app has)
    • Adjust the test interval and timeout to match your app's needs—this ensures ARR will stop sending traffic to a server if it's unresponsive

Repeat for the app2 Server Farm

  • Follow the exact same steps as above, but name the farm App2-Servers
  • In the Proxy tab, set the Forward URL to http://{SERVER_ADDRESS}:790
  • Configure the same load balancing algorithm and health checks as app1

Now we need to set up the LB to listen for incoming requests and route them to the right farm:

  • For app1:
    1. On the LB's IIS Manager, right-click Sites > Add Website
    2. Name it App1-LB, set the port to 8080 (you can use any port you prefer), and pick an empty folder for the physical path (we're just forwarding traffic, not hosting files here)
    3. Select the App1-LB site, go to URL Rewrite > Add Rule(s) > Reverse Proxy
    4. Uncheck Enable SSL Offloading (skip this if you're using HTTPS), then click OK
    5. Edit the new rewrite rule: Go to the Action tab, set Action type to Route to Server Farm, and select App1-Servers from the dropdown. Save the rule.
  • For app2:
    1. Add another website named App2-LB, set the port to 8081
    2. Repeat the reverse proxy setup, routing to the App2-Servers farm
5. Test the Load Balancing

Now it's time to verify everything works:

  • From a client machine, visit http://[LB-Server-IP]:8080 and refresh multiple times. To confirm traffic is being distributed, you can add a simple snippet to app1 that displays the server's IP address, or check the IIS logs on both backend servers.
  • Do the same for app2 at http://[LB-Server-IP]:8081
  • Test failover: Shut down app1 on one backend server, then keep refreshing the LB's app1 URL. ARR should automatically route all traffic to the working server.
6. Optional Extras
  • HTTPS Support: Install an SSL certificate on the LB, enable SSL Offloading, and update the rewrite rules to use HTTPS. This lets the LB handle encryption, so your backend servers don't have to.
  • Session Affinity: If your app requires users to stay on the same server (for session data), go to the server farm's Session Affinity tab and select either Client IP or Cookie based on your needs.
  • Timeout Tuning: Adjust connection and response timeouts in the server farm's Proxy tab to match how long your app takes to respond.

内容的提问来源于stack exchange,提问作者bharat Garg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:50:35