###############################################################################
#  upstream.conf · 后端服务池定义
###############################################################################

# ------- API 后端：3 台 + 1 备用 -------
upstream api_backend {
    least_conn;
    keepalive 64;

    server api1:3000 weight=2 max_fails=3 fail_timeout=30s;
    server api2:3000 weight=2 max_fails=3 fail_timeout=30s;
    server api3:3000 weight=1 max_fails=3 fail_timeout=30s;
    server api4:3000 backup;
}

# ------- WebSocket 后端 -------
upstream ws_backend {
    ip_hash;     # 同一用户固定一台（保证连接粘性）
    keepalive 32;

    server ws1:4000 max_fails=3 fail_timeout=30s;
    server ws2:4000 max_fails=3 fail_timeout=30s;
}
