Falcor for Android

Netflix Technology Blog
8 min readadvanced
--
View Original

Overview

The article discusses the implementation of the Falcor library for Android, focusing on its efficient data fetching and cache coherence capabilities. It outlines the challenges faced in replacing the existing caching layer and the solutions implemented to enhance performance and reduce memory usage.

What You'll Learn

1

How to implement cache coherence using JSON Graph in Falcor

2

Why using custom deserialization improves performance in data fetching

3

How to manage threading for cache and remote operations in Android

Prerequisites & Requirements

  • Basic understanding of caching concepts
  • Familiarity with JSON and REST APIs(optional)
  • Experience with Android development

Key Questions Answered

What is the main benefit of using Falcor for data fetching in Android?
Falcor allows for efficient data fetching by enabling clients to request data using a path query language, which ensures that data is fetched in a coherent manner. This means that clients can request data without needing to translate paths, simplifying the data retrieval process.
How does Falcor improve cache performance compared to previous implementations?
The implementation of Falcor reduced cache memory usage by about 10-15% during typical user sessions, translating to approximately 500kB less memory footprint. This was achieved through cache coherence, which eliminates duplicate objects in memory.
What challenges were faced when implementing Falcor in the Netflix Android client?
The main challenge was to replace the existing data caching layer with the new Falcor component while minimizing impact on app quality. This required extensive testing to validate the new caching component and ensure performance was maintained or improved.
What testing strategies were used to validate the new Falcor cache implementation?
The testing strategy involved using reflection on interfaces to compare results from the old and new cache implementations. This approach allowed for early detection of discrepancies and ensured that the new implementation met the expected standards.

Key Statistics & Figures

Reduction in cache memory usage
10-15%
This reduction was observed during typical user browsing sessions, resulting in approximately 500kB less memory footprint.
Performance improvement in JSON parsing
6x faster
Custom deserialization was benchmarked against reflection-based parsing, showing a significant performance gain.

Technologies & Tools

Backend
Falcor
Used for efficient data fetching and cache coherence in the Netflix Android client.
Data Format
JSON Graph
Utilized by Falcor to define internal references within JSON documents.

Key Actionable Insights

1
Implementing custom deserialization can significantly enhance data parsing performance.
By replacing reflection-based parsing with custom deserialization, the Netflix team found that processing time was reduced by approximately 6 times, leading to faster data retrieval and improved application responsiveness.
2
Utilizing a coherent caching strategy can reduce memory usage and improve application performance.
The transition to Falcor resulted in a 10-15% reduction in cache memory footprint, demonstrating the effectiveness of coherent caching in optimizing resource utilization in Android applications.
3
Isolating cache and remote operations into a single component simplifies performance monitoring.
By consolidating these operations, the team was able to easily add performance metrics to requests, aiding in debugging and ensuring that performance issues could be identified and resolved quickly.

Common Pitfalls

1
Relying on reflection for JSON parsing can lead to performance bottlenecks.
This happens because reflection is inherently slower than direct method calls. Transitioning to custom deserialization can mitigate this issue and improve overall application performance.

Related Concepts

Caching Strategies
Data Fetching Techniques
Performance Optimization In Android