✅ Best Practices

Follow these recommendations to get the most reliable, lowest-latency shred delivery from ShredStream.com.

Using our SDK? The SDK configures the socket receive buffer automatically (25 MB by default) and handles packet validation. You still need to configure the OS-level sysctl settings below and can benefit from the monitoring and redundancy recommendations.


📐 UDP Buffer Sizing

The single most impactful configuration change is increasing your UDP receive buffer. ShredStream.com can deliver thousands of shreds per second, and the default OS buffer is far too small.

Set a minimum of 25 MB:

bash
# Apply immediately (Linux)
sudo sysctl -w net.core.rmem_max=26214400
sudo sysctl -w net.core.rmem_default=26214400
# Persist across reboots — add to /etc/sysctl.conf
net.core.rmem_max=26214400
net.core.rmem_default=26214400

Then request the buffer size in your application code:

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 25 * 1024 * 1024)
sock.bind(("0.0.0.0", 8001))

Note on Linux buffer doubling: Linux internally doubles the buffer value you pass to setsockopt(). When you request 25 MB, the kernel allocates 50 MB (half for data, half for kernel bookkeeping). The rmem_max sysctl must be at least 25 MB for the request to succeed.


🔄 Redundancy and Failover

For production systems where uptime is critical, plan for redundancy.

  • Multi-region streams -- Create streams in two or more regions. If one region experiences an issue, the other continues delivering. Deduplicate incoming shreds using the (slot, index) pair to avoid processing the same data twice.
  • Hot standby servers -- Run a second receiver on a different machine. Both can listen simultaneously; your processing pipeline deduplicates downstream.
  • IP failover -- Use a floating IP or Elastic IP that can be reassigned quickly. Update the stream destination from the dashboard when you move traffic to a standby server.

✅ Summary Checklist

  • UDP receive buffer set to 25 MB or higher
  • Socket bound to 0.0.0.0, not 127.0.0.1
  • Receive thread isolated from processing logic
  • Redundant streams in multiple regions (for production workloads)