Apple rewrote a key cloud service in Swift on Linux and the performance gains are shocking

Apple made a major change behind the scenes, and believe it or not, most people have no idea. The company quietly rewrote its Password Monitoring service in Swift, replacing the old Java version entirely. The outcome is impressive. Apple says the updated service is about 40 percent faster and uses far less memory.

The Password Monitoring feature lives inside Apple’s Passwords app, which launched in the fall of 2024. This app helps users manage passwords, passkeys, and verification codes. It also alerts users if one of their saved passwords shows up in a known data breach. The service works without exposing any personal data to Apple, using a private set intersection protocol to preserve privacy.

Behind the scenes, the service checks billions of passwords each day across a global user base. It runs on a Linux-based backend maintained by Apple. Originally built in Java, the service had trouble scaling efficiently. Even after tuning the Java Virtual Machine and trying various garbage collection tweaks, Apple engineers still ran into performance bottlenecks. Java’s memory usage became too much of a burden, especially when the service needed to scale up and down quickly depending on global traffic.

Apple did not rush into rewriting the service. Engineers explored their options and found Swift to be a surprisingly good fit. While it might seem like a natural choice given Apple’s history with Swift, the team evaluated several languages before moving forward. In the end, Swift offered strong performance, better safety, and faster startup times. The team built the new backend using Vapor, a Swift web framework, and wrote custom packages to handle cryptography, auditing, configuration, and other tasks.

The experience of switching from Java to Swift also improved code quality. Apple developers moved away from complex class hierarchies and embraced Swift’s protocol-based approach. This allowed for better modularity and less coupling between components. Swift’s handling of optional values helped eliminate null pointer errors, and its async and await support made asynchronous programming more readable and easier to maintain.

Apple says the Swift version of the service has about 85 percent fewer lines of code than the Java version. It also performs better. Requests are now handled in under one millisecond for almost all users, and memory use per instance dropped from tens of gigabytes to just hundreds of megabytes. These gains allowed Apple to free up nearly half of its server capacity for other services.

The Swift backend is currently running in production and performing well under real-world loads. For Apple, the decision to move to Swift was not just about performance. It also made the codebase more maintainable and reduced the risk of bugs. This project shows that Swift can handle serious cloud workloads and is not just a language for building iPhone apps.

This rewrite might be just the beginning. Apple’s quiet shift to Swift in the cloud could hint at bigger changes ahead for its backend systems.

Author

  • Brian Fagioli, journalist at NERDS.xyz

    Brian Fagioli is a technology journalist and founder of NERDS.xyz. Known for covering Linux, open source software, AI, and cybersecurity, he delivers no-nonsense tech news for real nerds.

Leave a Comment