DEV Community

Envio
Envio

Posted on

Optimizing Indexer Performance

Image description

When building scalable applications, understanding where your time is going is crucial. Performance bottlenecks can hinder your progress, and that's where benchmarking becomes a game-changer. At Envio, we've made capturing and analyzing performance data straightforward, giving you the insights you need to optimize your indexer for peak performance. Here's how it works.

Capturing Benchmark Data

To start, run:

envio start --bench

This command gathers real-time performance metrics, helping you capture key data for analysis.

Important: Avoid using this in production, as the process retains benchmark data in memory and adds overhead when writing to a file.


Summarizing Your Benchmarks

After running your indexer for a while, use:

envio benchmark-summary

Image description

This generates a performance snapshot, including metrics like:

  • Total runtime: 45 seconds
  • Events per second: 3454.18

These numbers provide a baseline understanding of how your indexer performs.


Digging Deeper: Where Is Your Time Going?

A more detailed breakdown can show where time is being spent, such as:

  • Total runtime: 45 seconds
  • Time fetching Chain 1 Partition 0: 44 seconds
  • Processing time: 9 seconds

This clarity helps identify bottlenecks. If most of the time is spent fetching data, improving handlers won’t significantly impact performance—you need to focus on optimizing data fetching.


Breaking Down Fetching Times

Image description

Take a closer look at fetching times to uncover delays:

  • Total time elapsed: 3675 ms (on average)
  • Parsing time: 142 ms
  • Page fetch time: 3481 ms

This level of detail highlights the slowest parts of the process, allowing you to target specific areas for optimization.


Event Processing Metrics

Image description

The Event Processing section is where you can track the efficiency of your handlers. Key metrics include:

  • Batch size: 4163
  • Contract register duration: 0.11 ms
  • Load duration: 80.79 ms
  • DB write duration: 135.92 ms

Image description

Handler performance is also critical:

  • ERC20 Transfer Handler: 0.0021 ms (on average)

Small inefficiencies in handlers can add up over time, so pay attention to these numbers.


Structuring Your Data

Image description

Additional insights include:

  • Number of partitions: 1
  • Batch creation time: 0.66 ms
  • Batch size: 4163

These metrics provide context for how your data flows and where adjustments can improve performance.


What to Prioritize

Your benchmark data tells a clear story:

  • If data fetching dominates runtime, focus on speeding up this process first.
  • If processing is the bottleneck, review the Event Processing metrics to optimize handlers.

Optimizing Handlers

Handlers can slow down for several reasons, such as:

  • Slow async operations
  • Excessive data reads from the database

Refactoring to use more efficient loaders can significantly enhance performance.


Benchmarking for Better Performance

By capturing and analyzing your indexer’s benchmarks, you gain actionable insights into performance bottlenecks. This data empowers you to make targeted improvements, ensuring faster and more efficient indexing.

For a deeper dive into benchmarking, check out our docs.

About Envio

Envio is a modern, dev-friendly, speed-optimized blockchain indexing solution that addresses the limitations of traditional blockchain indexing approaches and gives developers peace of mind. Blockchain developers and data analysts can harness the power of Envio to overcome the challenges posed by latency, reliability, infrastructure management, and costs across various sources.

If you're a blockchain developer looking to enhance your development process and unlock the true potential of Web3 infrastructure, look no further.

Join our growing community of Web3 developers, check out our docs, and let's work together to revolutionize the blockchain world and propel your project to the next level.

Website | X | Discord | Farcaster| YouTube | Reddit

Top comments (0)