# How OkCredit Android App boosted Network Performance by 30%

DevFeed: [How OkCredit Android App boosted Network Performance by 30%](<https://devfeed.tech/articles/how-okcredit-android-app-boosted-network-performance-by-30-37400.md>)

Original publisher: [Read original article](<https://medium.com/okcredit/how-okcredit-android-app-boosted-network-performance-by-30-84109080c065?source=rss----40ea5327aac7---4>)

Author: Shrey Garg

Published: 2022-07-07T11:29:22Z

Content type: tutorial

Language: en

Sources: [OkCredit - Medium](<https://devfeed.tech/sources/okcredit-medium.md>)

Topics: [Mobile](<https://devfeed.tech/topics/mobile.md>), [Android](<https://devfeed.tech/topics/android.md>), [android-apps](<https://devfeed.tech/topics/android-apps.md>), [Instrumentation](<https://devfeed.tech/topics/instrumentation.md>), [Network](<https://devfeed.tech/topics/network.md>), [Latency](<https://devfeed.tech/topics/latency.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [TLS handshake](<https://devfeed.tech/topics/tls-handshake.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [http](<https://devfeed.tech/tags/http.md>), [instrumentation](<https://devfeed.tech/tags/instrumentation.md>), [latency](<https://devfeed.tech/tags/latency.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [network](<https://devfeed.tech/tags/network.md>), [okcredit](<https://devfeed.tech/tags/okcredit.md>), [performance](<https://devfeed.tech/tags/performance.md>), [tls-handshake](<https://devfeed.tech/tags/tls-handshake.md>), [user-experience](<https://devfeed.tech/tags/user-experience.md>)

## AI overview

This tutorial explains how to analyze and optimize each stage of network calls in Android apps, including call start, DNS resolution, TLS connection setup, request and response transfer, connection reuse, and call completion. It describes using OkHttp connection pooling and the EventListener class to instrument HTTP-call metrics such as quantity, size, and duration.

## Source excerpt

Fast and reliable network communication is crucial for OkCredit mobile apps. Since the majority of our users belong to Tier-2/3 cities in India, flaky and unreliable network connection is one of the biggest challenges for us. In order to deliver a good user experience, our mobile apps need to have reliable and low-latency network connectivity. While most resources we found describe how we can improve the overall time (start-end) of a network call, this article attempts to take a deep dive and talk about each step and how we can instrument and optimise each step of a network call in android apps. Steps involved in a network callFig. Steps of a Network call. Ref -- https://square.github.io/okhttp/features/events1. Call start Called as soon as a call is enqueued or executed by a client. Ideally, this step should not consume any time unless there are any custom Interceptors added. 2. DNS Involves the DNS Resolver translating the domain name into the corresponding identifier (the IP address). 3. Connection Start Tries to acquire a secure connection (TLS handshake) between the client and the server. 4. Connection End / Acquired Invoked after a connection has been acquired for the call. After this, the communication of request and response payloads is started. 5. Request / Response / Headers This is the step in which the actual communication of data happens. The HTTP method, size of request / response payload, server latency / response time, etc. can greatly impact the time taken by this step. 6. Connection released Invoked after a connection has been released for the call. 7. Call end Invoked immediately after a call has completely ended. Pooled connection OkHttp has the capability to pool connections with which it can skip various steps of a network call mentioned above, which in turn can greatly improve the application's network performance, as existing connections can be reused. Fig. Steps of a Network call with pooled connectionInstrumentation of each step To determine