Using Haproxy as a MongoDB shard cluster MONGOs load Balancing

Source: Internet
Author: User
Tags failover haproxy

The ingress MONGOs of a MongoDB shard cluster itself has no failover mechanism. The official recommendation is to deploy MONGOs and application servers together, and multiple application servers will deploy multiple MONGOs instances, which is inconvenient. You can also use LVS or haproxy to implement multiple mongos failover mechanisms, but be aware that client-side affinity features are used in affinity.

    chroot      /data/app_platform/haproxy/share/ 
    log local3 info
    user        haproxy
    group       haproxy
    pidfile     /var/run/
    nbproc      1                       
    stats socket  /tmp/haproxy level admin
    stats maxconn 20                    
    node        master_loadbalance1
    description lb1
    maxconn     65536
    spread-checks 3                     

    log         global                  
    mode tcp
    option abortonclose         
    option allbackups            
    option tcpka                        
    option redispatch
    retries 3   
    timeout check 60s                   
    timeout connect 600s                            
    timeout queue 600s                   
    timeout server 600s                  
    timeout tarpit 60s
    timeout client 600s   
frontend  mongos_pool
    mode tcp
    maxconn 32768
    no option dontlognull
    option tcplog     
    log         global
    option log-separate-errors
    default_backend mongos_pool

backend mongos_pool
    mode tcp
    balance     source
    default-server inter 2s fastinter 1s downinter 5s slowstart 60s rise 2 fall 5 weight 30

    server  gintama-xxx-mongos1    check  maxconn 2000
    server  gintama-xxx-mongos2    check  maxconn 2000

Note Use

Balance Source

This article is from the Linux SA John blog, so be sure to keep this source

Using Haproxy as a MongoDB shard cluster MONGOs load Balancing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.