How Facebook Sped Up Its iPhone App by Nearly 50%


Photo: Ariel Zambelich/Wired

Photo: Ariel Zambelich/Wired



You weren’t imagining things. The Facebook iPhone app was getting slower.


In 2012, the social networking giant launched its first native iPhone app, and over the next two years, according to Facebook engineer Adam Ernst, its all-important News Feed gradually slowed down as the company beefed up the app with new features. But recently, after a careful investigation of the problem, Ernst and his fellow engineers managed to regain all that lost speed by completely rebuilding part of the app’s underlying infrastructure. “We took this big ambitious project where we wanted to swap out how we stored and managed data,” Ernst says.


Detailed in a company blog post, the project is a great example of how precarious application performance can be—and how engineers must constantly rethink their software code. This is especially true at companies like Facebook, which run such complex online operations.


At first, Ernst and crew didn’t even realize that something was wrong. Each new version of the Facebook iPhone app was a little slower than the last, but the difference was so slight as to be virtually imperceptible. But over the course of two years, they started to see the cumulative effect of these tiny slow-downs. Then they tried to root out the cause, adding tools that could track each step in the process of loading the News Feed.


It turned out the problem lay with the iPhone’s native data storage system, known as Core Data. Each new feature in the app required new tables, rows, and columns in the database, and that was causing a massive—and unnecessary—slow down for the News Feed. “Every new feature would slow down old features,” Ernst says.


“We realized that while Core Data had served us well in the beginning, we needed to go without some of its features to accommodate our scale,” he writes in the company blog post. The team decided to create a new data storage system for the app. That would have been a big project in and of itself, but the real issue was how to replace the data storage system while other Facebook teams were still writing new code for the app. “It’s like changing out the jet engines in the air,” Ernst says. Basically, they separated the code from the data.


Not all iPhone app developers will experience this problem. Facebook’s operation is unusually large and complex. If they do, Facebook can point the way the forward.



No comments:

Post a Comment