Swift.org Blog Konrad 'ktoso' Malawski Oct 28, 2021

Introducing Swift Distributed Actors

Article Summary

Swift is taking on distributed systems with the same elegance it brought to concurrency. The Swift team just open-sourced a complete cluster library for building distributed actor systems.

Apple's Swift team announced Swift Distributed Actors, an experimental open-source package that extends Swift's actor model from local concurrency to distributed systems. Built on SwiftNIO, it provides a complete server-oriented cluster library with membership services, remote procedure calls, and actor discovery patterns.

Key Takeaways

Critical Insight

Swift Distributed Actors brings type-safe, compiler-checked distributed programming to server-side Swift, eliminating typical RPC boilerplate while maintaining the familiar actor syntax.

The library's approach to handling node failures and actor lifecycle management across clusters deserves a closer look.

About This Article

Problem

Swift developers kept writing the same networking, serialization, and RPC code over and over for different projects. There was no shared framework for actors to talk across multiple nodes.

Solution

Konrad Malawski's team built Swift Distributed Actors, which includes an ActorTransport protocol and a reference cluster implementation using SwiftNIO. Developers can now declare distributed functions that handle async and throwing automatically, with Codable serialization built in.

Impact

Writing distributed systems in Swift got simpler. Developers use the same actor syntax they know to build worker pools, presence systems, and game lobbies without touching low-level networking code. You can test in a single process, across multiple nodes in one process, or on separate machines in production.