Performance Optimization
Tune LiteP2P for reliability, battery life, bandwidth efficiency, and latency. The right defaults depend on your use case.
Baseline recommendations
- Start with conservative peer limits (see PeerConfig).
- Prefer small, structured messages; batch when appropriate.
- Measure before tuning: latency, reconnect rate, CPU, and battery impact.
Connection stability
- Implement retry with exponential backoff.
- On Android, follow OEM guidance (see Battery Optimization and OEM Behavior).
- Use foreground services when continuous connectivity is required.
Bandwidth and payloads
- Compress text payloads; avoid compressing already-compressed formats.
- Use channels to separate latency-sensitive messages from bulk sync.
- For large payloads, prefer file transfer APIs rather than chunking messages manually.
File transfer tuning
- Pick a chunk size that balances throughput and resume granularity (see TransferOptions).
- Enable resumption for unreliable networks.
- Verify integrity for user-visible files.