Skip to main content

Overview

In environments with a high density of devices and data traffic, additional optimizations may be necessary:
  • Limit Active Connections: Dozens of devices in a single mesh can lead to congestion in some cases. Strategically limit the number of active connections to balance the load effectively.
  • Avoid Verbose Logging: Verbose logging, especially with large datasets, can significantly slow down the synchronization process. Ensure that logging is kept to a necessary minimum during high-load times to prevent this.
  • Use Routing Hints: When using the Ditto Server optional cloud deployment and managing large document collections, you can group peers with similar data access patterns by assigning specific labels, known as routing hints.
  • Flood-Fill Strategy: For large-scale sync, ensure all peers in the same local mesh share the same subscription for optimal performance.
For additional information, see Troubleshooting and Transports

Routing Hints

Represented as an unsigned integer with 32 bits (uint32), a routing hint is a value you define at the device level that Ditto Server references to optimize connections with peers consuming the same datasets. For example, several restaurants operate on the same Ditto Server instance and devices within each restaurant share the same data. Each restaurant is identified by 32-bit integer, which is used as the routing hint to the server to ensure data is co-located.

When to Use Routing Hints

Routing hints are most important for multi-site or multi-location apps where different groups of devices access different subsets of data. When a routing hint is set, the Ditto Server can co-locate peers that share the same hint, reducing the overhead of initial sync. Without a routing hint, the server must evaluate all active peers when serving an initial sync request, which increases load. Setting a routing hint is especially beneficial when the server is under heavy load or resource-constrained (for example, limited disk IOPS on a shared cloud instance). In these scenarios, the routing hint helps the server prioritize sync traffic for related peers and can significantly reduce initial sync times.
If your app uses sync subscriptions and experiences slow initial sync from the Ditto Server, adding a routing hint is a recommended first step before contacting support for infrastructure scaling.

Code Samples

To set a routing hint in your app’s transport config, from the top-most scope before calling startSync.