How HeadSpin and NimbleDroid Helped Flipkart Speed Up App Start Up by 45%
Flipkart is India’s leading e-commerce company based in Bengaluru, India. The company currently offers more than 80 million products in 80+ categories. In August 2018, U.S.-based retail giant Walmart acquired a 77% controlling stake in Flipkart for US$16 billion, valuing it at $22 billion.
2017 Revenue: $2.8 billion
Number of employees: 30,000+
Registered users: 100 million
Millions of users rely on Flipkart’s mobile app to make purchases. Especially in the crowded e-commerce sector, fast app startup time is essential to business success. Slow mobile apps hurt revenue, receive poor rankings in application stores and are frequently abandoned by users.
NimbleDroid, a HeadSpin company, helped Flipkart detect and fix performance bottlenecks in their code base and prevented two serious performance regressions from going live to millions of users. Using NimbleDroid, Flipkart’s app startup time was reduced by 45%. These insights have positioned Flipkart for continued leadership in the e-commerce sector.
How We Did It Flipkart used GSON extensively to parse JSON responses into model objects — which was done using reflection to determine the type of variable or field at runtime. Reflection is relatively slow on Android devices and Flipkart’s JSON response is nested and complex — so NimbleDroid was able to show developers that their app was taking more time than expected to parse JSON network responses.
Flipkart used GSON extensively to parse JSON responses into model objects — which was done using reflection to determine the type of variable or field at runtime.
Reflection is relatively slow on Android devices and Flipkart’s JSON response is nested and complex — so NimbleDroid was able to show developers that their app was taking more time than expected to parse JSON network responses.
~4.0s Cold Startup
~1.3s of this time taken up by GSON
To reduce cold startup time, Flipkart developers needed to find a a way to mitigate reflection.
GSON uses a concept called Type Adapters, which manually map JSON fields to the model object. Using Type Adapters improves performance — as it does not use reflection. But writing Type Adapters for each of the ~350 model classes would have been labor intensive and prone to bugs.
NimbleDroid recommended that Flipkart developers leverage Vimeo’s Stag Library, which uses annotation processing to automatically generate Ureflection-less Type Adapters for model objects. NimbleDroid also helped developers avoid reflection in non-GSON code
When Flipkart developers moved from Volley to Retrofit (done on initialization on the UI thread), app startup time increased — from 2.8 to 3.0 seconds. During code review, developers could not determine what was causing this slowdown. Using NimbleDroid, they were able to identify the issue and resolve it before the change went live. NimbleDroid also identified lazy initialization of data that was not needed for app startup, helping save additional time.
Nimble Droid also benchmarked Flipkart’s app performance against leading competitors.