Level Up Your App Infrastructure

Four ways to prepare & measure your app for success

John Li
The Startup
6 min readSep 13, 2020

--

by Christina Morillo

Do you have an app out in the wild? Maybe you are working on one right now. Whichever the case may be, you want to be able to measure the performance of your app.

How is your app performing?

This is a deceptively complicated question. There are so many directions you can go with your answer. By the end of this article, there should be a clear path to answering all the following questions:

  • How many users are using your app this month?
  • What is the user retention rate for over 3 days?
  • How much money did the app generate in the last 7 days?
  • How long is the app startup for the 99th percentile of users?
  • Which endpoints are slow?
  • What are the biggest crashes in the app for a specific release?
  • Have any users ended up in an unexpected state?

We will answer these questions through four categories:

  • Use Behavior Analytics
  • Developer-oriented Logging
  • Application Performance Management
  • Feature Toggles

A Quick and Reliable Solution

To help us collect and measure our data, we will rely on third-party services to make our lives easier. Google Firebase provides a set of comprehensive tools and services that will help us achieve better app infrastructure.

Why Choose Firebase?

  • Lots of great features
  • Easy-to-use dashboards
  • Amazing documentation
  • Up-to-date code examples
  • Free-tier plan

There are plenty of alternatives. Firebase is one of the options we can pick. All the code samples in this article will be referring to Firebase in Kotlin.

User Behavior Analytics

Provided by unblast

You won’t be successful if you don’t understand how users are using your app. Good thing there are plenty of solutions for user-behavior analytics tracking. With most services, Firebase included, a few lines of configuration code will provide all the following information:

  • Daily active users
  • Monthly active users
  • Average session times
  • User locality
  • Device information
  • Engagement score

With a little more work, you can integrate additional tracking for things like:

  • User experience funnel
  • Custom user properties
  • Custom metrics
  • Purchases/conversion metrics

Logging Events

Firebase provides a set of common events you can use. The example below represents tracking when a user clicks on an image from a collection view of posts.

If you have use-cases outside of the event types provided by Firebase, you can always send a custom event.

The skies the limits here on what you want to track. Collaborate with your analyst. Be sure to consider your user’s privacy and local regulations.

Developer-oriented Logging

Provided by unblast

On the other end of logging, we have metrics that are more developer-oriented. The distinction becomes a little bit more clear when you think about who the data is for.

Crash and exception reporting are examples of developer-oriented metrics.

Crash Reporting

It is important to have a way of tracking crashes that happen out in production. Crashes lead to poor user experiences that will translate to bad reviews, less revenue, and users leaving the app.

Crashyltics has a very simple setup process and will automatically report crashes & related metrics back to the Firebase dashboard.

Don’t forget to set up alerts so you can stay informed in real-time when things go wrong.

Exception Reporting

Exceptions are thrown when the code reaches a scenario with unexpected behavior. NullPointerException, IllegalStateException, or IllegalArgumentException are examples of such scenarios. Unlike crashes, we can catch exceptions and return the user to a stable state. We want to report these as well as any other thrown exceptions.

Firebase does a great job providing a simple API to record exceptions.

A good place to start logging these scenarios is the networking layer. There are plenty of opportunities with HTTP and connection errors.

Additional Logs

You can add additional logs to give crashes or exceptions more context.
I would add additional logs is if I was going to do something that has a higher likelihood to fail.

If I was going to fetch an 8mb image, I would add this log to give context for any potential HTTP or network errors.

Application Performance Management

Application performance management(APM) provides a set of tools that monitors the performance of your application. One key concept of tracking performance is the use of traces. Traces record the start and stop of an event.

Integrating with Firebase’s Performance Monitoring service will provide a set of automatic traces like…

  • App startup duration
  • App in foreground/background performance
  • Network traces that record success rate, response time, and payload size
  • Screens that have low frames-per-second

Custom Traces

Adding custom traces is key to being data-driven. Here are a few examples of custom traces you should implement.

  • Library initialization times
  • Retrieving data from the disk cache
  • Long-processing tasks

I would say a rule of thumb for when to implement a custom trace is when the duration of any task takes more than 10ms.

Custom Trace Example

If we want to track the duration of retrieving data, we will need to measure the time it takes to get the data as well as how long it will take to map the information into a consumable format.

Firebase provides support for tracking network request durations. We can combine that information with a deserialization trace to understand how long it takes for data to be available to use.

Performance Data

Implementing an APM will help you understand exactly which external service, component, or code block is slow.

  • How fast are the backend requests?
  • Are we doing things we shouldn’t be on the main thread?
  • Does loading an intricate animation cause the device to skip frames?

This is the tip of the iceberg of things we can be data-driven with. Explore the various opportunities in your app.

Feature Toggles

Enable and disable features in real-time with Firebase Remote Config. There are plenty of use cases for this feature such as

  • A/B Testing
  • Launch new features with percentage roll-out
  • Define properties based on platform/locale/user-segment
  • Disabling an unstable feature
  • Locking paid features to free users

The general implementation flow is defining default values, fetching the latest configuration, and responding to the updated configuration.

To support real-time configuration updates, here’s a nifty diagram outlining the steps.

Considerations

One of Firebase’s limitations is that they keep data as far back as 90 days for their dashboards. There is support for exporting the entire history into another data warehouse. There may be a point where keeping historical data of your app’s performance is worth the cost. Keep this in mind as your app grows.

Conclusion

It is no secret that technology does not scale without proper infrastructure. The ability to scale is useless if we do not have the data to guide us in the right direction. The challenge we have now is to invest in infrastructure and be data-driven in our approach.

This isn’t an exhaustive list but it’s a great introduction to various ways of leveling up your app. It will also enable you and your business to be more data-driven.

I wish you all the best in building better apps and better businesses.

--

--