Profile Your Database

Measure the performance of your Firebase Realtime Database with the database profiler tool built into the Firebase CLI. The profiler tool logs all activity in your database over a given period of time, then generates a detailed report. Use the detailed report to troubleshoot issues with your database performance, spot problem areas, and reduce unindexed queries.

Build a profile

  1. Before you start profiling your Firebase Realtime Database, make sure you're using the latest version of the Firebase CLI and have initialized it using the correct database and project.

  2. Start profiling your database with the following command:

    firebase database:profile
    The profiler displays a status message as it records operations from your database and builds the profile.

  3. Press Enter to complete the profile and display the results.

Interpret your results

The profiler tool aggregates the data it's collected about your database's operations and displays the results in three primary categories: speed, bandwidth, and unindexed queries.

Speed

The Speed Report measures the server's response time (in milliseconds) for each operation type. The speed measured in the Speed Report may not actually reflect the speed end-users see, however. Different factors, like network conditions, can add latency on the client side.

The Speed Report includes the following properties:

  • Path: The path in your database tree where the operations occurred. If there are more than 25 child nodes, these are collapsed into a parent path and replaced with a $wildcard marker. You may see your database's root directory in the report, represented by a forward slash /.
  • Count: The number of operations that occurred at the given path.
  • Average: The average time it takes the server to process a particular operation type at that path.
  • Permission Denied: The number of operations at the given path that were blocked by Firebase Database Rules on your database.
Speed Report by Operation Type
Read Speed The server response time for client requests to read data from the database.
Write Speed The server response time for client requests to write data to the database.
Broadcast Speed

The time it takes the server to distribute data to clients that are listening to the given path in realtime.

The Count property in the Broadcast Speed Report aggregates the number of broadcasts that happened, not the number of clients that received the information. For example, if 10 clients were listening at a given path, and an update was broadcast to all 10 clients, the broadcast count would reflect 1 broadcast, despite 10 clients receiving the data.

The Permission Denied property isn't included in the Broadcast Speed report.

Bandwidth

The Bandwidth Report gives you insight into how much data your database is consuming across incoming and outgoing operations. You should not use the Bandwidth Report to estimate billing, however, as it doesn't include bandwidth used for other operational purposes, such as the data used to profile your database. The Bandwidth Report is only intended to roughly estimate the payload size of the data consumed by read, write, and broadcast operations to and from your database to measure performance, not forecast billing.

The Bandwidth Report includes the following properties:

  • Path: The path in your database tree where the operations occurred. If there are more than 25 child nodes, these are collapsed into a parent path.

  • Total: The total outgoing or incoming bytes used across all operations at the given path.

  • Count: The number of operations that occurred at the given path.
  • Average: The average number of downloaded or uploaded bytes across operations at the given path (bytes/write or bytes/read).
Bandwidth Report
Downloaded Bytes Data consumed through read and broadcast operations sent out via the client SDKs and REST API.
Uploaded Bytes Data consumed through write requests coming into the database server. Deletes show up as writes with 0 bytes under incoming.

Unindexed Queries

Unindexed queries can be expensive, because clients download all of the data at a location and then perform queries, which uses up more bandwidth than necessary. Resolve as many unindexed queries as you can to optimize your database's performance.

The Unindexed Queries report displays the following properties:

  • Path: The path in your database tree where the unindexed queries occurred.
  • Index: The rule you should add to resolve the unindexed queries. Learn more about indexing in Index your data.
  • Count: The number of unindexed queries that occurred at the given path.

Advanced profiling

To see all the operations your database is handling, use the --raw flag when you profile your database, as follows:

firebase database:profile --raw

The raw output also includes client information for each operation, such as userAgent strings and IP addresses. Learn more about the different operations profiled in your Firebase Realtime Database in Firebase Realtime Database Operation Types.

Send feedback about...

Need help? Visit our support page.