0

Let's consider simple case:

services:
  elasticsearch:
    image: elasticsearch:alpine
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    networks:
      - backend
    deploy:
      replicas: 3

networks:
    - backend:
        driver:
            overlay

We have three replicas, each service got some VirtualIP address. Please note also that these adresses are adresses of overlay network. Moreover, service_names are resolved to VirtualIP. Now, tell me please:

  1. If VirtualIP is loadbalanced? I mean following case: nc 10.0.0.4 9200 Behind the scene (using loadbalancing) I am redirected to 10.0.0.2 (another service). What about nc elasticsearch_1 9200 ?

  2. Is it meaningful I create three replices or three seperated services?

n2485883
  • 15
  • 1
  • 3

1 Answers1

0

There are examples of proper elasticsearch setup in Docker Swarm via Google. The designs can vary based on the size and needs you have for the es cluster.

  1. You likely want each node to be its own service with one replica. This is easier to manage in smaller environments because generally, replicas should be interchangeable, and es nodes are specific apps with their own configs and unique data storage each.

  2. When creating the service, disable the VIP so there's one less hop to the service (since each will only be one replica). So add --endpoint-mode dnsrr to your service create, or add it to your stack/compose file.

Bret Fisher
  • 8,164
  • 2
  • 31
  • 36