Load balancer for internal API requests
global network private network
Multimedia Corporate
data center
Traditional
server
Mobile Client
Example:
Requester
Workers
SPDY/HTTP2
mercari API
HTTP
subsystems
subsystems
HTTP
HTTP
Slide 7
Slide 7 text
Load balancer for Search
app
app
app
OpenResty
Latest Indices
All Indices
Contents cache
&
Dynamic Balancing
HTTP
HTTP
Slide 8
Slide 8 text
Load balancer for Push
Gaurun
Gaurun
Gaurun
Slide 9
Slide 9 text
in
• Service discovery
• Load balancer, SMTP, etc…
• Configuration deployment
• TLS Session Tickets, IP black list
• Distributed lock
• Ensure running only 1 process always in clusters
Slide 10
Slide 10 text
Service discovery
Slide 11
Slide 11 text
Service discovery with
• Use case in
• Internal DNS as
• Endpoint of internal API, DNS-RR
• Via HTTP APIs
• Listing nodes in service
Listing all nodes in api-internal service
$ curl -s \
consul-server:8500/v1/catalog/service/api-internal \
jq ‘.[].Address’
“10.0.1.1”
“10.0.1.2”
“10.0.1.3”
“10.0.1.4”
“10.0.1.5”
“10.0.1.6”
Slide 14
Slide 14 text
DNS-RR in api-internal service
$ dig production.api-internal.service.consul | egrep ‘^production’
production.api-internal.service.consul. 0 IN A 10.0.1.6
production.api-internal.service.consul. 0 IN A 10.0.1.4
production.api-internal.service.consul. 0 IN A 10.0.1.1
$ dig production.api-internal.service.consul | egrep ‘^production’
production.api-internal.service.consul. 0 IN A 10.0.1.2
production.api-internal.service.consul. 0 IN A 10.0.1.3
production.api-internal.service.consul. 0 IN A 10.0.1.5
$ dig production.api-internal.service.consul | egrep ‘^production’
production.api-internal.service.consul. 0 IN A 10.0.1.3
production.api-internal.service.consul. 0 IN A 10.0.1.2
production.api-internal.service.consul. 0 IN A 10.0.1.1
$
Slide 15
Slide 15 text
Endpoint of internal API requests
• There are subsystems in
• Admin tool, Batch, Worker, Web, …
• Each subsystem calls Mercari API via HTTP
• e.g. production.api-internal.service.consul
Slide 16
Slide 16 text
Load balancer for internal API requests
global network private network
Multimedia Corporate
data center
Traditional
server
Mobile Client
Example:
Requester
Workers
SPDY/HTTP2
mercari API
HTTP
subsystems
subsystems
HTTP
HTTP
Slide 17
Slide 17 text
Load balancer for internal API requests
private network
Multimedia Corporate
data center
Traditional
server
Mobile Client
Example:
Requester
Workers
SPDY/HTTP2
mercari API
HTTP
subsystems
subsystems
HTTP
HTTP
production.api-internal.service.consul
production.api-internal.service.consul
global network
Slide 18
Slide 18 text
Listing nodes in service
• Use case in
• Gathering load balancer nodes in
application deployment
ChatOps with Slack
yes
EFQMPZCPU
※rsync
※ rsync ——rsync-path=mercari_app_rsync(↓)
#!/bin/sh
mercari_app_ctl down # deactivate server on nginx upstream
rsync $* # deploy
mercari_app_ctl up # activate server on nginx upstream
Mercari deployment
App
App
App
nginx
nginx
nginx
Slide 21
Slide 21 text
ChatOps with Slack
yes
EFQMPZCPU
※ rsync ——rsync-path=mercari_app_rsync(↓)
#!/bin/sh
mercari_app_ctl down # deactivate server on nginx upstream
rsync $* # deploy
mercari_app_ctl up # activate server on nginx upstream
down
Mercari deployment
App
App
App
nginx
nginx
nginx
Slide 22
Slide 22 text
ChatOps with Slack
yes
EFQMPZCPU
rsync
※ rsync ——rsync-path=mercari_app_rsync(↓)
#!/bin/sh
mercari_app_ctl down # deactivate server on nginx upstream
rsync $* # deploy
mercari_app_ctl up # activate server on nginx upstream
Mercari deployment
App
App
App
nginx
nginx
nginx
Slide 23
Slide 23 text
ChatOps with Slack
yes
EFQMPZCPU
※ rsync ——rsync-path=mercari_app_rsync(↓)
#!/bin/sh
mercari_app_ctl down # deactivate server on nginx upstream
rsync $* # deploy
mercari_app_ctl up # activate server on nginx upstream
up
Mercari deployment
App
App
App
nginx
nginx
nginx
Slide 24
Slide 24 text
Repeat…
Slide 25
Slide 25 text
ChatOps with Slack
yes
EFQMPZCPU
※ rsync ——rsync-path=mercari_app_rsync(↓)
#!/bin/sh
mercari_app_ctl down # deactivate server on nginx upstream
rsync $* # deploy
mercari_app_ctl up # activate server on nginx upstream
down or up
Turn of
App
App
App
nginx
nginx
nginx
Slide 26
Slide 26 text
Listing all nodes in api-internal service
$ curl -s \
consul-server:8500/v1/catalog/service/api-internal \
jq ‘.[].Address’
“10.0.1.1”
“10.0.1.2”
“10.0.1.3”
“10.0.1.4”
“10.0.1.5”
“10.0.1.6”
Configuration deployment with
• Via
• consul event
• consul-template
• Stretcher
• Now uses consul event & Stretcher
Slide 30
Slide 30 text
Load balancer configuration with
• Dynamic upstream with consul-template
• Instead uses ngx_dynamic_upstream
• External files
• TLS Session Tickets
• IP black list
Slide 31
Slide 31 text
TLS Session Tickets
# TLS Session Tickets
# openssl rand 48 > ssl_session_ticket
ssl_session_tickets on;
ssl_session_ticket_key /etc/nginx/ssl/ssl_session_ticket;
• Client side session cache for TLS
• nginx loads from local file on startup
• Periodic update is required for forward secrecy
• updates automatically with consul event