Facebook caused an uproar when it forced all of its users to download the messenger app. And now that everyone’s on it, Facebook has unveiled how it updated its infrastructure system to make sure the messages don’t lag. Meet its solution: Iris, a new messaging-queue system.
Although the social network has been improving Messenger’s features over the years, the underlying technology that powers those additions lagged when Messenger became compatible with mobile devices, which became especially important when Facebook forced users to download the Messenger app instead of chatting in the native Facebook app. To revamp its infrastructure, Facebook came up with a faster syncing protocol that has supposedly cut down the amount of traffic on its network and led to a roughly 20 percent decrease in message errors.
Before the revamp, when a user received a chat on the Messenger app on his or her mobile device, the app would get a ping that a new message was available and would then communicate with the Facebook server to retrieve that information. Unfortunately, the messaging app had to download the entire conversation as opposed to only the most recent message, which obviously is not good for performance.
From the Facebook blog post:
[blockquote person=”Facebook” attribution=”Facebook”]Messaging data has traditionally been stored on spinning disks. In the pull-based model, we’d write to disk before sending a trigger to Messenger to read from disk. Thus, this giant storage tier would serve real-time message data as well as the full conversation history. One large storage tier doesn’t scale well to synchronize recent messages to the app in real time.[/blockquote]
Facebook now has a message-queuing system called Iris that can sync the most recent message to a mobile device while allowing that big storage tier to maintain the whole conversation.
Iris acts as a sort of timeline of an entire conversation that tracks recent and old messages as well as what messages have or haven’t been read by a user. It also knows when a mobile device last received a message as well as all messaging data stored in Facebook’s servers.
If a person’s phone goes offline while someone sends him a text, Iris can keep track of that message as it gets stored to the servers and then trigger that message to be sent from the servers once the phone comes online, all without having to send the entire conversation.
From the Facebook blog posting:
[blockquote person=”Facebook” attribution=”Facebook”]We looked at several existing technologies to support the queue’s backing store, but couldn’t find anything that met our needs in terms of scale, reliability, speed, and flexibility. Ultimately, we opted to build the queue storage on top of MySQL and flash. For MySQL we decided to use semi-sync replication, which can give you durability across multiple servers. By leveraging this technology, we can handle database hardware failures in under 30 seconds, and the latency for enqueueing a new message is an order of magnitude less than writing to the traditional disk storage.[/blockquote]
With Iris in place, Facebook claims that it has cut down on delivering excess data by roughly 40 percent.