国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

docker-compose: scale and link

CoreDump / 2192人閱讀

摘要:更多文章訪問的小博客

Learned how to use docker compose to create a scalable web app with nginx.

Month ago, I built my apps with docker and used Nginx outside the docker as a reverse proxy server. Now I have something better to make a change.
In docker"s world, every component of a website should running as a container, include app, db, and Nginx as well.
A docker compose YAML I found online as follows, from a blog:

nginx:
    build: ./nginx
    links:
        - node1:node1
        - node2:node2
        - node3:node3
    ports:
        - "80:80"
node1:
    build: ./node
    links:
        - redis
    ports:
        - "8080"
node2:
    build: ./node
    links:
        - redis
    ports:
        - "8080"
node3:
    build: ./node
    links:
        - redis
    ports:
        - "8080"
redis:
    image: redis
    ports:
        - "6379"

The author made 3 app containers, 1 redis container and 1 nginx container. I find some ugly implement here that each node is hard coded in conf file, so if nodes need to be scaled up, we should add more and more nodes in the conf file.
docker compose scale is a useful command here to let us scale up our app containers elegantly. docker compose scale node=3 nginx=1 redis=1 will automatically create 3 node containers for us.
But there is another dark cloud on the sky. In the previous version, nginx config file is simply as follows:

worker_processes 4;

events { worker_connections 1024; }

http {

        upstream node-app {
              least_conn;
              server node1:8080 weight=10 max_fails=3 fail_timeout=30s;
              server node2:8080 weight=10 max_fails=3 fail_timeout=30s;
              server node3:8080 weight=10 max_fails=3 fail_timeout=30s;
        }
         
        server {
              listen 80;
         
              location / {
                proxy_pass http://node-app;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
              }
        }
}

Can we use node to replace node1,node2,node3 here?
node1 here is not some docker magic, it"s just a hostname which docker generated in /ets/hosts of nginx container, since we linked node1 to nginx.
So if we have 3 node IP which has the same hostname, we can just rewrite conf to a single server:

        upstream node-app {
              least_conn;
              server node:8080 max_fails=3 fail_timeout=30s;
        }

Unfortunately, docker compose v1 seems not support group nodes into the same hostname.
It will generate hosts as follows:

172.17.0.21 node 8a1297a5b3e4 compose_node_1
172.17.0.21 node_1 8a1297a5b3e4 compose_node_1
172.17.0.22 node_2 069dd46836aa compose_node_2

Only one container will get the name node. After searching in Github, I got some interesting facts:

The interaction of scaling with networking (as with links) is unsatisfactory at the moment - you"ll basically get a bunch of entries in /etc/hosts along these lines:

  172.16.0.1 myapp_php_1
  172.16.0.2 myapp_php_2
  172.16.0.3 myapp_php_3

In a future version of Compose (enabled by changes to Engine), the name under which each container joins the network is going to change to just the service name, php. So you"ll get multiple entries with the same name:

172.16.0.1 php
172.16.0.2 php
172.16.0.3 php

This isn"t a real solution either, of course - we"re still working towards one - but in both cases, if you have a load balancer container that needs to keep up-to-date with what"s currently on the network, for the time being it"ll need to periodically read /etc/hosts and parse the entries to determine the IPs of the backends.

@aanand one of the maintainer of docker compose said above in 2015-12-7.

It may already be improved in v2 with docker 1.10, but I have not get the chance to use docker 1.10.

I think this way is better since we can easily scale up and dont need to change the config. DevOps should evolve in this way.

更多文章訪問 kamushin的小博客

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/26685.html

相關(guān)文章

  • 從docker到istio之二 - 使用compose部署應(yīng)用

    摘要:使用導(dǎo)出端口,使用掛載數(shù)據(jù)卷。清理應(yīng)用使用一鍵清理應(yīng)用總結(jié)已經(jīng)實(shí)現(xiàn)了容器擴(kuò)容自動(dòng)擋更直觀的控制容器啟動(dòng)順序及依賴。從部署到編排,單字面理解,看起來能夠維護(hù)的容器量都增長(zhǎng)了。推薦應(yīng)用包括多個(gè)服務(wù),推薦部署方式就是。前言 容器化,云原生越演越烈,新概念非常之多。信息爆炸的同時(shí),帶來層層迷霧。我嘗試從擴(kuò)容出發(fā)理解其脈路,經(jīng)過實(shí)踐探索,整理形成一個(gè)入門教程,包括下面四篇文章。 容器化實(shí)踐之路-從d...

    yy13818512006 評(píng)論0 收藏0
  • 一步步學(xué)會(huì)用docker部署應(yīng)用(nodejs版)

    摘要:本文將采用技術(shù)部署一個(gè)簡(jiǎn)單的應(yīng)用,它包括一個(gè)簡(jiǎn)單的前置網(wǎng)關(guān)服務(wù)器以及業(yè)務(wù)服務(wù)器。同時(shí)使用配置特定鏡像,采用進(jìn)行容器編排,解決依賴網(wǎng)絡(luò)等問題。服務(wù)器首先搭建一個(gè)單節(jié)點(diǎn)緩存服務(wù),采用官方提供的最新版鏡像,無(wú)需構(gòu)建。 docker是一種虛擬化技術(shù),可以在內(nèi)核層隔離資源。因此對(duì)于上層應(yīng)用而言,采用docker技術(shù)可以達(dá)到類似于虛擬機(jī)的沙盒環(huán)境。這大大簡(jiǎn)化了應(yīng)用部署,讓運(yùn)維人員無(wú)需陷入無(wú)止境繁瑣...

    canger 評(píng)論0 收藏0
  • 一步步學(xué)會(huì)用docker部署應(yīng)用(nodejs版)

    摘要:本文將采用技術(shù)部署一個(gè)簡(jiǎn)單的應(yīng)用,它包括一個(gè)簡(jiǎn)單的前置網(wǎng)關(guān)服務(wù)器以及業(yè)務(wù)服務(wù)器。同時(shí)使用配置特定鏡像,采用進(jìn)行容器編排,解決依賴網(wǎng)絡(luò)等問題。服務(wù)器首先搭建一個(gè)單節(jié)點(diǎn)緩存服務(wù),采用官方提供的最新版鏡像,無(wú)需構(gòu)建。 docker是一種虛擬化技術(shù),可以在內(nèi)核層隔離資源。因此對(duì)于上層應(yīng)用而言,采用docker技術(shù)可以達(dá)到類似于虛擬機(jī)的沙盒環(huán)境。這大大簡(jiǎn)化了應(yīng)用部署,讓運(yùn)維人員無(wú)需陷入無(wú)止境繁瑣...

    BlackMass 評(píng)論0 收藏0
  • Docker Swarm在生產(chǎn)環(huán)境中的進(jìn)階指南

    摘要:應(yīng)該如何解決本文將給出若干提示,如何在生產(chǎn)環(huán)境中使用。路由匹配服務(wù)發(fā)現(xiàn)負(fù)載均衡跨容器通訊非常可靠。在單個(gè)端口上運(yùn)行一個(gè)服務(wù),節(jié)點(diǎn)的任意主機(jī)都可以訪問,負(fù)載均衡完全在后臺(tái)實(shí)現(xiàn)。 上周數(shù)人云給大家分享了——《你可能需要的關(guān)于Docker Swarm的經(jīng)驗(yàn)分享》今天給大家?guī)磉@位作者大大的后續(xù)文章——《Docker Swarm在生產(chǎn)環(huán)境中的進(jìn)階指南》 當(dāng)在本地開發(fā)環(huán)境中使用Docker,或者...

    galaxy_robot 評(píng)論0 收藏0
  • scrapy_redis 和 docker 實(shí)現(xiàn)簡(jiǎn)單分布式爬蟲

    摘要:簡(jiǎn)介在使用爬取桔子公司信息,用來進(jìn)行分析,了解創(chuàng)業(yè)公司的一切情況,之前使用寫了一個(gè)默認(rèn)線程是的單個(gè)實(shí)例,為了防止被設(shè)置了下載的速度,萬(wàn)多個(gè)公司信息爬了天多才完成,現(xiàn)在想到使用分布式爬蟲來提高效率。 簡(jiǎn)介 在使用 scrapy 爬取 IT桔子公司信息,用來進(jìn)行分析,了解 IT 創(chuàng)業(yè)公司的一切情況,之前使用 scrapy 寫了一個(gè)默認(rèn)線程是10的單個(gè)實(shí)例,為了防止被 ban IP 設(shè)置了下...

    _DangJin 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<