Interconnecting containers at
scale with NGINX
.
@sarahnovotny
#dockercon
Building a great application

is only half the battle,
delivering the application 

is the other half.
MORE INFORMATION AT NGINX.COM
Microservices
1)
The good things
MORE INFORMATION AT NGINX.COM
Microservices + containers
The Microservices Architecture:
Enables continuous delivery,
rapid deployment and elasticity
MORE INFORMATION AT NGINX.COM
The Microservices Architecture:
To scale, you can scale each
service independently
MORE INFORMATION AT NGINX.COM
The Microservices Architecture:
Services can be written in
different languages using
different frameworks
MORE INFORMATION AT NGINX.COM
Making Changes:
Each service can be changed,
tested and built independently
MORE INFORMATION AT NGINX.COM
Making Changes:
Release cycles can be
dramatically shortened
MORE INFORMATION AT NGINX.COM
Deploying Microservices:
To unlock the potential of
microservices you must
embrace containers, cloud and
DevOps
2)
The bad things
The Microservices Architecture:
Services can be written in
different languages using
different frameworks
Making Changes:
Release cycles can be
dramatically shortened
Complexity:
To unlock the potential of
microservices you must
embrace containers, cloud and
DevOps
MORE INFORMATION AT NGINX.COM
Here be dragons
3)
How can NGINX
help?
NGINX as your stevedores:
Acts as a HTTP router
inspecting requests and
deciding how each one should
be satisfied
ste·ve·dore
ˈstēvəˌdôr/
noun
noun: stevedore; plural noun: stevedores
a person employed, or a contractor engaged, at a dock to load and unload
cargo from ships.

The Microservices Architecture
The Microservices Architecture
Docker orchestration
- many options vying
- (and then there’s service
discovery)
MORE INFORMATION AT NGINX.COM
docker-compose
MORE INFORMATION AT NGINX.COM
This .yml file builds –
Consul for service
discovery
Registrator
tutum/hello-world
Google/golang-hello
& NGINX Plus
MORE INFORMATION AT NGINX.COM
$ sarah@ubuntu:~/service-discovery$ more docker-compose.yml
nginx:
build: ./nginxplus
links:
- consul
ports:
- "9050:80"
- "8080:8080"
consul:
command: -server -bootstrap -advertise 10.0.2.15
image: progrium/consul:latest
ports:
- "8300:8300"
- "8400:8400"
- "8500:8500"
- "8600:53/udp”
MORE INFORMATION AT NGINX.COM
registrator:
command: consul://consul:8500
image: progrium/registrator:latest
links:
- consul
volumes:
- "/var/run/docker.sock:/tmp/docker.sock"
service1:
image: tutum/hello-world:latest
environment:
SERVICE_80_NAME: http
SERVICE_NAME: service1
SERVICE_TAGS: production
ports:
- "80"
MORE INFORMATION AT NGINX.COM
service2:
image: google/golang-hello:latest
environment:
SERVICE_80_NAME: http
SERVICE_NAME: service2
SERVICE_TAGS: production
ports:
- "8080"
sarah@ubuntu:~/service-discovery$
MORE INFORMATION AT NGINX.COM
sarah@ubuntu:~/service-discovery$ docker-compose build
consul uses an image, skipping
Building nginx...
Step 0 : FROM ubuntu:14.04
---> 6d4946999d4f
Step 1 : MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com"
---> Using cache
---> 339d0f20dc6e
…
sarah@ubuntu:~/service-discovery$ docker-compose up -d
Recreating servicediscovery_consul_1...
Recreating servicediscovery_nginx_1...
Recreating servicediscovery_registrator_1...
Recreating servicediscovery_service1_6...
Recreating servicediscovery_service2_1...
sarah@ubuntu:~/service-discovery$
MORE INFORMATION AT NGINX.COM
MORE INFORMATION AT NGINX.COM
sarah@ubuntu:~/service-discovery/nginxplus$ more nginx.conf
{{range services}} {{$name := .Name}} {{range $tag, $service := service .Name |
byTag}} {{if eq $tag "production"}}
upstream {{$name}} {
zone upstream-{{$name}} 64k;
least_conn;
{{range $service}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60
weight=1 slow_start=60;
{{else}}server 127.0.0.1:65535; # force a 502{{end}}
} {{end}} {{end}} {{end}}
<snip>
MORE INFORMATION AT NGINX.COM
sarah@ubuntu:~/service-discovery$ docker-compose scale service1=5
Creating servicediscovery_service1_2...
Creating servicediscovery_service1_3...
Creating servicediscovery_service1_4...
Creating servicediscovery_service1_5...
Starting servicediscovery_service1_2...
Starting servicediscovery_service1_3...
Starting servicediscovery_service1_4...
Starting servicediscovery_service1_5...
MORE INFORMATION AT NGINX.COM
Visit our table to go
through this demo
and request a
developer license for
NGINX Plus
Thank you
@sarahnovotny
#dockercon

DockerCon SF 2015: Interconnecting Containers at Scale w/ NGINX

  • 1.
  • 2.
  • 3.
    Building a greatapplication
 is only half the battle, delivering the application 
 is the other half.
  • 4.
    MORE INFORMATION ATNGINX.COM Microservices
  • 5.
  • 6.
    MORE INFORMATION ATNGINX.COM Microservices + containers
  • 7.
    The Microservices Architecture: Enablescontinuous delivery, rapid deployment and elasticity
  • 8.
    MORE INFORMATION ATNGINX.COM The Microservices Architecture: To scale, you can scale each service independently
  • 9.
    MORE INFORMATION ATNGINX.COM The Microservices Architecture: Services can be written in different languages using different frameworks
  • 10.
    MORE INFORMATION ATNGINX.COM Making Changes: Each service can be changed, tested and built independently
  • 11.
    MORE INFORMATION ATNGINX.COM Making Changes: Release cycles can be dramatically shortened
  • 12.
    MORE INFORMATION ATNGINX.COM Deploying Microservices: To unlock the potential of microservices you must embrace containers, cloud and DevOps
  • 13.
  • 14.
    The Microservices Architecture: Servicescan be written in different languages using different frameworks
  • 15.
    Making Changes: Release cyclescan be dramatically shortened
  • 16.
    Complexity: To unlock thepotential of microservices you must embrace containers, cloud and DevOps
  • 17.
    MORE INFORMATION ATNGINX.COM Here be dragons
  • 18.
  • 19.
    NGINX as yourstevedores: Acts as a HTTP router inspecting requests and deciding how each one should be satisfied
  • 20.
    ste·ve·dore ˈstēvəˌdôr/ noun noun: stevedore; pluralnoun: stevedores a person employed, or a contractor engaged, at a dock to load and unload cargo from ships.

  • 21.
  • 22.
  • 23.
    Docker orchestration - manyoptions vying - (and then there’s service discovery)
  • 24.
    MORE INFORMATION ATNGINX.COM docker-compose
  • 25.
    MORE INFORMATION ATNGINX.COM This .yml file builds – Consul for service discovery Registrator tutum/hello-world Google/golang-hello & NGINX Plus
  • 26.
    MORE INFORMATION ATNGINX.COM $ sarah@ubuntu:~/service-discovery$ more docker-compose.yml nginx: build: ./nginxplus links: - consul ports: - "9050:80" - "8080:8080" consul: command: -server -bootstrap -advertise 10.0.2.15 image: progrium/consul:latest ports: - "8300:8300" - "8400:8400" - "8500:8500" - "8600:53/udp”
  • 27.
    MORE INFORMATION ATNGINX.COM registrator: command: consul://consul:8500 image: progrium/registrator:latest links: - consul volumes: - "/var/run/docker.sock:/tmp/docker.sock" service1: image: tutum/hello-world:latest environment: SERVICE_80_NAME: http SERVICE_NAME: service1 SERVICE_TAGS: production ports: - "80"
  • 28.
    MORE INFORMATION ATNGINX.COM service2: image: google/golang-hello:latest environment: SERVICE_80_NAME: http SERVICE_NAME: service2 SERVICE_TAGS: production ports: - "8080" sarah@ubuntu:~/service-discovery$
  • 29.
    MORE INFORMATION ATNGINX.COM sarah@ubuntu:~/service-discovery$ docker-compose build consul uses an image, skipping Building nginx... Step 0 : FROM ubuntu:14.04 ---> 6d4946999d4f Step 1 : MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com" ---> Using cache ---> 339d0f20dc6e … sarah@ubuntu:~/service-discovery$ docker-compose up -d Recreating servicediscovery_consul_1... Recreating servicediscovery_nginx_1... Recreating servicediscovery_registrator_1... Recreating servicediscovery_service1_6... Recreating servicediscovery_service2_1... sarah@ubuntu:~/service-discovery$
  • 30.
  • 31.
    MORE INFORMATION ATNGINX.COM sarah@ubuntu:~/service-discovery/nginxplus$ more nginx.conf {{range services}} {{$name := .Name}} {{range $tag, $service := service .Name | byTag}} {{if eq $tag "production"}} upstream {{$name}} { zone upstream-{{$name}} 64k; least_conn; {{range $service}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1 slow_start=60; {{else}}server 127.0.0.1:65535; # force a 502{{end}} } {{end}} {{end}} {{end}} <snip>
  • 32.
    MORE INFORMATION ATNGINX.COM sarah@ubuntu:~/service-discovery$ docker-compose scale service1=5 Creating servicediscovery_service1_2... Creating servicediscovery_service1_3... Creating servicediscovery_service1_4... Creating servicediscovery_service1_5... Starting servicediscovery_service1_2... Starting servicediscovery_service1_3... Starting servicediscovery_service1_4... Starting servicediscovery_service1_5...
  • 34.
    MORE INFORMATION ATNGINX.COM Visit our table to go through this demo and request a developer license for NGINX Plus
  • 35.