19. EC2 Instance (1 Virtual Machine)
Container Container Container Container Container
for for for for for
user A user A user B user B user B
Container Container Container Container Container
for for for for for
user C user D user D user E user E
Container Container Container Container Container
for for for for for
user E user F user F user F user F
20. Nginx
Unicorn
sshd
supervisrod
on each container
29. SFTP
Git over SSH HTTP/HTTPS
AWS SSH
Web Proxy
SSH Router
to Containers
File Deploy
Containers
Repositories Servers
30. HTTP/HTTPS
ELB
nginx nginx
Container Container Container Container Container Container
for for for for for for
user A user B user B user C user C user C
32. http://lokka-mizzy.sqale.jp/
Which containers?
Redis nginx
host001:8083, host001:8084
or
host001
nginx port 8081 nginx port 8082 nginx port 8083 nginx port 8084
Container Container Container Container
for for for for
i4pc-mizzy i4pc-mizzy lokka-mizzy lokka-mizzy
34. dynamic-proxy.lua (excerpt)
local reply = ngx.location.capture("/redis")
if reply.status ~= ngx.HTTP_OK then
ngx.exit(503)
end
local containers, type =
parser.parse_reply(reply.body)
35. dynamic-proxy.lua (excerpt)
while #containers > 0 do
tmp = table.remove(
containers,
math.random(#containers))
if ngx.shared.downed_containers:get(tmp) then
ngx.log(ngx.DEBUG, tmp .. " is down")
else
container = tmp
break
end
end
39. failover.lua (excerpt)
local downed_container = ngx.var.container
if downed_container then
ngx.shared.downed_containers:set(
downed_container,
1,
sqale.NEGATIVE_CACHE_SECONDS
)
end
40. failover.lua (excerpt)
while #containers > 0 do
tmp = table.remove(
containers,
math.random(#containers))
if ngx.shared.downed_containers:get(tmp) then
ngx.log(ngx.DEBUG, tmp .. " is down")
else
container = tmp
break
end
end
41. failover.lua (excerpt)
if not container then
ngx.exit(503)
end
ngx.var.container = container
ngx.var.next_containers
= luabins.save(containers)
54. git push
(ssh sqale@gateway.sqale.jp git-recieve-pack
‘/mizzy/lokka.git’)
Run AuthorizedKeys
Script
SSH Router MySQL
Verify the public key
and get the user’s git
server
command=“ssh sqale@git001.sqale.lan
git-recieve-pack
File ‘/var/repos/mizzy/lokka.git’”
Repository
(Git Server)
56. sftp sqale@gateway.sqale.jp
(ssh sqale@gateway.sqale.jp sftp-server)
Run AuthorizedKeys
Script
SSH Router MySQL
Verify the public key
and get the user’s file
server
command=“ssh sqale@file001.sqale.lan
sftp-server”
File git push File
Repository Repository
(File Server) (Git Server)
58. ssh sqale@gateway.sqale.jp
Run AuthorizedKeys
Script
SSH Router MySQL
Verify the public key
and get the user’s
cotainers list
Display the user’s containers list and
wait the user’s selection
command=“ssh sqale@
Container users001.sqale.lan -p 8081”