How Facebook Made Your Mobile Messages Move at Super Speed


facebook-hack-ft


If you’ve noticed your Facebook mobile messages zipping around a little more quickly over the past few months, you can thank a little-known open-source project called Apache Thrift.


Facebook designed Thrift and has long used the tool to send data between computer servers inside the sprawling data centers that underpin its online empire. But in the summer, the company also began using it to connect user smartphones running the Facebook Messenger app to machines inside these data centers. “This is the first time we’ve sent it down to the phone,” says Jason Jenks, a Facebook engineer who worked on the project.


A few months back, Facebook began moving users to the Messenger app, a means of quickly trading text messages that operates separately from the company’s primary smartphone app. The change annoyed some users who wanted to be able to chat inside Facebook proper, but as we pointed out at the time, it was also a necessary move away from the company’s roots on desktop computers. It’s part of a larger “unbundling” trend, where online companies split their services into multiple apps in an effort to keep pace with the way people are using their phones.


But the new Facebook Messenger wasn’t simply a rewrite of the user experience. In a separate project that started last year, engineers redid the back-end software too. They ended up ditching a slow bandwidth-hogging architecture that was a hold-over from Facebook’s early days and replacing it with Iris, a new Thrift-based system that pushes trim little updates to your mobile phone, rather than forcing it to completely sync up with a distant Facebook server.


In technical terms, Facebook dumped a format called JavaScript Object Notation, or JSON, for Thrift. They also rejiggered things on the server side to speed up the way messages are queued up and then delivered to the Messenger client. The server changes were introduced around March, but Facebook started rolling out the improved client to users just this past summer.


When web browsers connect to Facebook, they essentially have to start from scratch, downloading everything and then displaying it in the browser window. But mobile apps don’t work like that. They can download data and then keep it on hand. The new design takes that idea into account and radically cuts down on the amount of traffic your phone now sends to Facebook’s servers. “The phone on its own should never talk to the server. It can just passively receive data,” Jenks says.


The overall results? According to Facebook, they’ve cut error messaging rates by 20 percent, and the new app uses 40 percent less data when it’s sending messages back and forth between users. With media files like photos, the results are less dramatic, but there’s still an improvement, Facebook says.


Jenks and his colleague Jeremy Fein say they knew they were onto something good a few months ago when they started testing Iris in the field. “If you have two phones using the same account,” Jenks says, “you could put them side by side and actually see the differences.”



No comments:

Post a Comment