haproxy 如何选择后端

haproxy 如何选择后端

后端server状态

  1. DOWN
    1. 设置了check,检查不通过
  2. UP
    1. 设置了check,检查通过;或者不设置check
  3. MAINT
    1. 设置了disbled,效果等同于DOWN

后端状态

  1. UP
    1. 有至少一个weight > 0且UP的后端
  2. DOWN
    1. 无weight > 0或者UP的后端

选择

  1. 启用cookie session persistent

    1. 根据cookie转发,即使后端的weight=0
    2. 如果设置了option persist 或者force persist,则转发给DOWN或者MAINT的后端
    3. 如果设置option redispatch,则后端响应失败后,会转发给其他后端,即使配置了option persist or force-persist
  2. 未启用cookie session persistent

    1. 转发给weight > 0且UP的后端
原文地址:https://www.cnblogs.com/zhedan/p/14247018.html