Skip to content

Rapid Development of Threads: Meta's Monolithic Architecture Success Story

  • 8 min read

Zahan Malkani, a key figure at Meta, recounts the incredible journey of developing Threads, a microblogging service designed to rival Twitter, from scratch to launch in just five months. In January 2023, Meta embarked on a mission to create a new social networking application that would stand toe-to-toe with Twitter. By July, a lean and agile team successfully launched Threads, a new social media app. This article is a summary of Malkani's 2024 QCon London presentation, "From 0 to 1—Delivering the Threads App in 5 Months."

Value and Milestones

The new Threads app aimed to deliver four fundamental values to its users. Firstly, Threads emphasized textual content, a departure from Instagram's media-centric approach, where every post on Threads begins with text. Secondly, the app sought to continue Instagram's design language and essence, recognized for its simplicity and product quality. Thirdly, Threads aimed to embrace the openness that Twitter established early in its history, allowing the community to freely use APIs to create personalized experiences and making public content widely accessible through web embeds. Lastly, Threads prioritized the needs of creators, recognizing that a small percentage of users generate the majority of content consumed by others, a phenomenon that follows a Zipfian distribution, especially pronounced in text-heavy social networks.

Based on these value propositions, the team outlined a Minimum Viable Product (MVP) and began construction with a key goal of delivering a product as quickly as possible to have options. They set four milestones to achieve, each designed as a potential completion state, allowing for the possibility of releasing the product at any milestone. The first milestone focused on building the most basic app, allowing users to log in and post plain text messages associated with their accounts. The second milestone added basic elements to the app, including familiar styles for browsing feeds, viewing notifications, and accessing profiles, as well as enabling user verification, blocking, and reporting features.

The third milestone, dubbed the "lean launch candidate" phase, focused on refining service functions that may have been overlooked, such as person search features and introducing a full-screen viewer for better photo and video viewing. The team began to delve into managing conversation content, the core of the app, questioning how to sort them as units and copying Instagram's follow content for quick profile setup. The fourth milestone was achieving interoperability with the Fediverse, signaling the product's near-final release candidate state. Although ambitious, this milestone was not fully realized even today, but it was a testament to the optimism and commitment of the team.

Accelerating Development Speed

Title: Rapid Development of Threads: Meta's Monolithic Architecture Success Story

Developing Threads from scratch in just five months was an ambitious challenge. The project officially started in February, with a commitment to leadership to be ready by summer. Confidence stemmed from the knowledge that they could leverage existing Instagram elements effectively. Instagram's sharing features were intuitive, allowing users to follow profiles, browse posts, and interact to build communities around shared interests. These were the functionalities the Threads project aimed to replicate in its early stages, leading to the clever reuse of Instagram's existing functionalities.

The first prototype introduced a module within Instagram's existing feed to display text-only posts, reusing the existing ranking mechanism. The layout was jokingly referred to as a simple rearrangement, with the title at the top and the content below, leaving the rest unchanged. This significantly reduced the technical complexity of implementation. The team successfully transformed the complex problem of building a new text-based social network into a specific question of how to customize Instagram's feed to display new text posts.

As engineers, they were aware of the potential drawbacks of this approach, such as accumulating technical debt when building new features on an existing codebase not designed for the new service, leading to a series of small issues. Additionally, a deep understanding of a vast legacy codebase, potentially millions of lines of code, was required for customization, with the saying, "Reading someone else's code is much harder than writing your own," often cited.

The Threads team was grateful for Instagram's design and infrastructure,始终坚持精准复用,只在必要时进行重构。This approach meant Threads benefited significantly from Instagram's solid foundation, laid by years of infrastructure and product team work at Meta. Without these foundations, their achievements would not have been possible. The pursuit of simplicity was rewarded, with many accolades received at launch due to the app's clarity and functionality without feeling feature-lacking.

Threads' Technical Stack

Threads' technical stack is a robust overview of Meta's priorities. Meta places significant emphasis on monolithic binaries and codebases, with Instagram's business logic centralized in a Python binary called Distillery, communicating with Meta's larger monolith, a massive PHP or Hack binary called WWW. Distillery may be one of the largest Django deployments in the world, running a customized version. User data is stored across multiple systems, with TAO, a graph data model-based write cache system, and UDB, a sharded MySQL deployment containing almost all data, being the most critical. TAO excels in handling node-to-node links with optimized operations for querying these links' details. An indexing system allows marking specific links and how they should be queried, with these indexes stored in memory for rapid query support. This model is a culmination of Meta's years of social product building experience and is highly beneficial.

The architecture also involves other significant systems, such as a large Haskell service handling many rules in the decision-making process, including identifying异常模式 in user behavior, a key-value store called ZippyDB for storing large amounts of transient data with high write frequencies beyond MySQL's capacity, a serverless computing platform supporting asynchronous operations, and a Kubernetes-like system for managing, deploying, and scaling all these services. All these systems must work in concert to ensure the platform's efficient operation.

Launch

On July 5th, non-engineering teams interacted with early celebrity users of the product, possibly a rare opportunity for intimate conversations with stars like Shakira. Meanwhile, engineers prepared for the product launch the following day: scaling the system, meticulously planning pre-launch demonstrations, and ensuring readiness. A data engineer noted异常登录尝试, all from East Asia, which was strange as理论上 no one should have accessed the app yet. The team quickly ruled out data errors and noticed the attempts were from a time zone issue related to the App Store's pre-order feature, allowing users to register for download when the app officially releases. The app was set to be available after midnight on July 6th, but due to access restrictions, users in those regions couldn't log in. This尴尬时刻 led to a swift shift in direction, with an emergency war room set up and a Zoom call召集了近 100 名专家 from various systems mentioned earlier. Considering it was深夜 in those countries, the team realized that once the service went live, demand would far exceed expectations.

With a large number of pre-order users expected to access the app after midnight local time, the team rescheduled the target launch time to UK midnight, buying precious hours to scale all Threads services involved. The ZippyDB caching system, vital for the feed function, needed to be re-sharded to handle the expected traffic surge—100 times the current capacity. This urgent task was completed minutes before Mark announced Threads' open registration. The challenge of replicating Instagram's follower network on Threads was another issue, with users wanting to follow those not yet registered on Threads, leading to a massive queue of followers for high-profile accounts like former President Obama. The initial system was clearly inadequate for this scale, leading to a rapid redesign to horizontally scale and form a working node cluster to handle the massive follow queues behind these accounts.

The experience was unforgettable, and the valuable lessons learned about staying calm and graceful under pressure will be cherished assets for the future.

Conclusion

Overall, launching this project was a unique experience. The most significant takeaway was the importance of keeping things simple, which is not easy. The adage about spending more time writing a shorter letter applies to any creative work. If you know the value you want to provide, it guides you in making tough decisions on what to streamline and focus on. Another profound lesson was that cleaner, newer code is not always better. All these insights are integrated into a battle-tested legacy codebase. If possible, don't discard these things lightly. Complementing this is the mantra, "Code speaks louder than words." Building products to solve actual problems often answers questions more effectively than abstract analysis. Many tricky problems were solved faster through prototypes rather than slides.

Of course, the success achieved cannot be generalized, as the把握机会 and market response post-launch could be attributed to luck. This cannot be guaranteed in advance. The community's acceptance of the product is greatly appreciated. There's a saying dating back to Facebook's early days that the journey is only 1% complete. This feels particularly true for Threads.

Title: Rapid Development of Threads: Meta's Monolithic Architecture Success Story

Leave a Reply

Your email address will not be published. Required fields are marked *