Samarth Gupta | November 14, 2023 | 4 min read
How we increased our Zomato Restaurant Partner App speed by over 90%

At Zomato, we understand that the success of our platform hinges on delivering outstanding service to our customers, restaurant partners and delivery partners. To achieve this, we embarked on a transformative Android engineering journey with our Zomato Restaurant Partner App, focusing on optimizing performance, enhancing the overall user experience, and bolstering app stability. 

We are deeply committed to providing a seamless experience through our restaurant partner app, that enables our restaurant partners to efficiently handle incoming orders, streamline operations and have an elevated user experience with Zomato.

Here’s everything that we did –

We applied a straightforward rule to examine our overheads. Our assessment of solutions was centered around their return on investment and the level of effort demanded from our engineering team. With these criteria as our guiding principles, we began a significant journey of improvement, categorizing our work into 7 key areas:

1. Initial Load Time of the App:

In the world of Android development, ensuring a swift and seamless initial load time is paramount. Users expect apps to launch quickly and be responsive from the moment they tap the app launch icon. Achieving this requires a deep understanding of the platform and the various components that come into play during the app startup. One crucial element in this process is the Application class. 

The Application class in Android serves as a base class for maintaining global application state and is instantiated before any other component when an app starts. It provides a centralized location for initializing and managing resources and state that need to be accessible throughout the entire app’s lifecycle.

Subclassing an Application is generally unnecessary. However, in the context of a substantial codebase and numerous teams crafting user experiences within the same app, it is not uncommon to overlook this fundamental principle. In such complex environments, maintaining simplicity can be challenging. Nevertheless, adhering to this principle remains crucial for codebase coherence and streamlined development. It ensures that changes and enhancements are implemented efficiently, benefiting the entire team and app ecosystem.

2. Defer initializations:

We removed several non-critical feature configurations/ 3rd party SDKs initializations from the main thread execution and managed to defer them as per the requirements within our app, allowing for dynamic delivery when needed.

3. Making use of the ExecutorService

We assessed ways to prevent other background apps from utilizing a core during our setup process and leveraged the ExecutorService to cache threads within a pool. These threads are assigned maximum priority, ensuring that the device prioritizes tasks related to our startup process, optimizing overall efficiency.

4. Eliminating Unnecessary Delays in Splash Screens:

We examined and optimized the actions performed during this phase. Upon walking through our code, we found multiple delays and time taking configuration operations which could’ve been avoided and/or cached based on our requirements. We eliminated these delays on the splash screen, and achieved a significant reduction in the overall time required for the app to become operational.

5. Enhancing Rendering Performance: 

We knew that optimizing how our app displays lists of items was crucial. To do so, we utilized RecyclerView prefetching, which works by preloading items in a list that are anticipated to become visible soon, enhancing the overall app performance. It involves asynchronous loading of items that are not yet on the screen but are likely to be scrolled into view. 

Since the UI Thread does not do any work in the gap between frames, we were able to use that idle time to get work done that we will need later.

This image has an empty alt attribute; its file name is image3.png

We also made use of ViewStub which is a nifty feature utilized to enhance our app’s performance. It allowed us to delay the inflation of complex or resource-intensive layouts until they were actually needed on the screen. This deferred loading conserved resources and memory, and eventually led to faster initial app launch times and smoother interactions.

6. Profiling:

Android Studio offers profiler, a robust tool for monitoring CPU activity, memory usage, and trace analysis similar to Perfetto. It allowed us to perform a detailed examination of the app’s operations. As we assessed our app, we identified inefficiencies in our views and memory utilization. Consequently, we embarked on enhancing our caching mechanism and maximizing view reuse wherever feasible.

7. Memory Leaks: 

We integrated LeakCanary into our app to tackle all the quirky memory leaks, as they can lead to sluggish rendering and even ANRs (Application Not Responding) in the app, impacting user experience.

By implementing all the optimizations, our cold start times plummeted from 27% in February to an impressive 1.4%. Furthermore, we slashed frozen frame occurrences from 3.72% to 1.99%. With this monumental improvement, restaurant partners now enjoy lightning-fast access to critical information. Orders, menu updates, customer feedback, and other essential data are at their fingertips almost instantly, regardless of their network conditions. 

This reduction in load time has not only benefited restaurant partners but has also translated into an exceptional user experience for customers. Orders are actioned upon more quickly, and delivery times are reduced, all contributing to higher customer satisfaction and loyalty. As a result, in about 4 months, our app rating on the Google Play Store went from 4.1 to 4.8!

The Pursuit of Excellence Continues

Our relentless pursuit of excellence finds its manifestations in the enhancements we’ve achieved for the Zomato Restaurant Partner App so far. Through deep analysis, strategic optimizations, and an unwavering commitment to delivering the best possible experience, we’ve not only achieved tangible improvements but also fortified the app’s technical quality. As we forge ahead, we remain dedicated to refining and enhancing the app, solidifying our position as a trusted partner for the restaurant partners countrywide.
Android Engineering Team (Zomato Restaurant Partner)

facebooklinkedintwitter

More for you to read

Technology

switching-from-tidb-to-dynamodb
Kanica Mandhania | January 11, 2024 | 9 min read
Unlocking performance, scalability, and cost-efficiency of Zomato’s Billing Platform by switching from TiDB to DynamoDB

Zomato accomplished a seamless migration from TiDB to DynamoDB. The transition has empowered Zomato to efficiently serve its growing user base by managing four times more transactions, decreasing latency by 90% and reducing database costs by 50%.

Technology

how-we-improved-our-android-app-startup-time-by-over-20-with-baseline-profile
Dilip Sharma | October 13, 2023 | 4 min read
How we improved our Android app startup time by over 20% with Baseline Profile

Baseline Profiles have boosted our Android app’s startup speed by over 20%. This blog explores our journey from optimization techniques to tackling testing challenges that have resulted in a smoother, faster user experience.

Technology

introducing-vinifera
Security Team | September 13, 2023 | 6 min read
Introducing Vinifera: A guide on how it prevents and mitigates accidental data leaks at scale

Vinifera is an open-source in-house monitoring tool for enhancing digital security. This blog covers its development journey, architectural foundations and challenges it has encountered and overcome along the way.

Technology

building-kimchi-for-hack-a-noodle-2022
Inder Deep Singh | August 16, 2023 | 11 min read
Building Kimchi for hack-a-noodle 2022 – Zomato’s on-the-fly iOS UI rendering engine

Kimchi is an on-the-fly UI rendering engine which allows Zomato to ship new UI to customers in real time, without needing an app release. This blog showcases its journey.