Hi ,
I have been playing around with the swift-distributed-actors
and swift-cluster-membership
packages a bit and having fun so far, just had a few questions if anyone could give me a poke in the right direction.
Connecting two machines over public IP
I am having trouble getting the clusters to work with public ip addresses. Something like below works for two local address like 192.168.0.69
.
var settings = ClusterSystemSettings(name: systemName, host: "local address?", port: 8080, tls: nil)
settings.autoLeaderElection = .none
settings.logging.logLevel = .debug
let system = await ClusterSystem(systemName, settings: settings)
Task {
// Give the cluster a second.
try? await Task.sleep(for: .seconds(1))
let cluster = Cluster.Endpoint(host: "other ip", port: 8080)
system.cluster.join(endpoint: cluster)
}
let machine = Machine(actorSystem: system, name: "zane")
But after I set up port forwarding on two routers and tried to connect the systems in a cluster, I ran into targetHandshakeAddressMismatch error. If I put the public ip addresses, I get a Cannot assign requested address (errno: 99)
, because my public IP isn't mapped locally, I guess (Still learning a lot about networking). I have tried 0.0.0.0
, 127.0.0.1
, but it looks like it's doing String == to check. Does this problem go away if I put this on AWS or something? I'm trying to avoid the cloud because I'm broke, but I have a couple of ~15-year-old computers I can try and orchestrate. I have some domain names and TLS certificates I can use after this step.
An aside, I noticed that swift-cluster-membership is using UDP, but swift-distributed-actors
is using TCP. How come?
Raft
My only experience with distributed systems/clusters is Raft. I'm about 2 days into implementing Raft using distributed actors
here.
I originally was thinking of hooking into the actorSystem.cluster.events
and publishing the current leader, but it doesn't look like there are any public api's to publish cluster events right now.
For now, I figured I should focus on getting a complete working implementation before trying to mix in Swim. Is an implementation of Raft appropriate to use for distributed actors? Why Swim as the first ActorSystem? I have only taken one class on Distributed Systems, so still learning a lot, but I found it fascinating.
Long term, I was thinking a Swift version of zookeeper or something .
Some context, just graduated and still looking for my first software engineering job, and I have a lot to learn!
Any guidance is greatly appreciated .
Thanks,
Zane