Twitter Finagle Ecosystem

red blue and yellow textile
Reading Time: 4 minutes

In this blog, we will learn about the very basics of the Twitter Finagle Ecosystem and see how it is used in Twitter.

In order to create high-concurrency servers and clients in Scala, developers leverage the open-source, asynchronous, protocol-neutral RPC framework known as Twitter Finagle. Hence, to manage the enormous traffic and size that Twitter required to serve, it was created by Twitter. The entire ecosystem of Finagle’s tools and libraries comes together to form a potent framework for creating distributed systems. In this post, we’ll examine the Finagle ecosystem’s many elements in more detail.

Architecture

Finagle is built on the foundation of Netty, a high-performance network application framework. It uses Netty’s NIO (non-blocking IO) features to provide a scalable and efficient networking stack. Finagle’s architecture is based on service-oriented architecture (SOA) principles. Services are defined as functions that take a request and return a response. Likewise, these services are then composed into complex systems.

The architecture of Twitter Finagle can be broken down into three main components:

  1. Finagle Core: Firstly, this is the core library that provides the basic abstractions for building distributed systems. It includes modules for managing connections, load balancing, service composition, and retry logic.
  2. Protocol Support: Finagle supports a variety of protocols including HTTP, Thrift, Memcached, and Finagle’s own custom protocol. Hence, each protocol has its own set of codecs and serializers that are used to encode and decode data.
  3. Integrations: Finagle integrates with a variety of third-party tools and frameworks such as Zipkin, a distributed tracing system, and Ostrich, a service monitoring system. Finally, these integrations provide additional functionality for building and monitoring distributed systems.

Overall, the architecture of Twitter Finagle is designed to be modular and extensible, allowing developers to build and deploy complex distributed systems with ease.

Components of Twitter Finagle

Finagle is composed of several components that work together to provide a complete ecosystem for building distributed systems.

  1. Finagle Core: Firstly, The core of Finagle provides the basic building blocks for building RPC systems. It includes support for HTTP, Thrift, and other protocols. It also provides a robust set of tools for handling errors and managing network connections.
  2. Finagle Clients: Finagle clients provide a simple API for making remote procedure calls. Clients are protocol-agnostic, which means that they can be used with any protocol that Finagle supports. Clients also include support for load balancing and failover.
  3. Finagle Servers: Finagle servers provide a simple API for building high-concurrency servers. Like clients, servers are protocol-agnostic, which means that they can be used with any protocol that Finagle supports. Servers also include support for load balancing and failover.
  4. Finagle Load Balancers: Finagle includes a set of load balancers that can be used to distribute traffic across multiple servers. Load balancers can be configured to use different load balancing algorithms, such as round-robin or weighted round-robin.
  5. Finagle Filters: Finagle filters provide a way to add functionality to Finagle services. Filters can be used to add metrics, logging, or authentication to a service. Filters can also be composed to create complex functionality.
  6. Finatra: Finatra is a web framework built on top of Finagle. furthermore, it provides a set of tools and libraries for building RESTful APIs. Finatra includes support for features like request routing, JSON serialization, and dependency injection.

Benefits of Twitter Finagle

Finagle provides several benefits for building distributed systems:

  1. Scalability: Finagle’s architecture is designed to provide scalability. Additionally, its NIO-based networking stack allows it to handle large numbers of connections efficiently. Its support for load balancing and failover also makes it easy to scale up and down.
  2. Robustness: Finagle provides a robust set of tools for handling errors and managing network connections. Also, its support for retries and timeouts helps to ensure that requests are processed successfully. Its filters also provide a way to add additional error handling and monitoring.
  3. Flexibility: Finagle’s protocol-agnostic design allows it to be used with any protocol that it supports. This makes it easy to switch between protocols or add new protocols to a system.

Conclusion

Twitter Finagle is a powerful ecosystem for building distributed systems in Scala. Its architecture is designed to provide scalability, robustness, and flexibility. Its components work together to provide a complete set of tools for building high-concurrency servers and clients. Finagle has been battle-tested at Twitter and is used by many other companies to build their distributed systems. If you are building a distributed system in Scala, Finagle is definitely worth considering.

For more information, you can visit Twitter Finagle Official Documentation.

Love reading tech blogs? Visit Knoldus Blogs to get enriched with great tech content.

Reference and creditsTwitter Blogs

Written by 

Sakshi Mittal is a Software Consultant at Knoldus Software. She has completed her MCA from BCIIT and Bachelors in Computer Applications from GGSIPU. Her practice area is Java but she loves to explore machine learning field as well. She likes writing tech blogs and contribute to open source. When not working you will find her watching travel and food vlogs.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading