Nitride.xyz
Engineering · November 17, 2026 · 8 min read

One destination, many bots: fanning shreds out inside your network

One receiver takes the feed and copies every datagram to each internal consumer; here is a tested forwarder and why SO_REUSEPORT is the wrong tool for it.

Nitride.xyz team

Run one receiver on the address the feed is delivered to and have it copy every datagram to each internal consumer with a plain unicast send. SO_REUSEPORT will not do this job: it spreads datagrams across sockets instead of copying them. Multicast on your own LAN also works, at the price of switch configuration.

The shape that works#

If you run more than one program that wants the feed, you are in good company. A quoting engine, an arbitrage bot, a logger that writes everything to disk, a research box that someone is always restarting. The feed arrives at exactly one place: a plan covers one IPv4 address and one UDP port, as your destination IP and port explains. So the question is how to fan out UDP shreds once they land. If the packets themselves are new to you, Solana shreds, explained covers what each one carries.

The answer we keep coming back to is the dullest one. One process owns the socket on the destination port. It does nothing but receive each datagram and send a copy to a short list of internal addresses, either 127.0.0.1 ports on the same machine or 10.0.0.x hosts on the private network. Every consumer then sees the full stream, byte for byte, and owns its own parsing, its own decoding and its own idea of which shreds it cares about.

Three rules keep this shape healthy:

  • The forwarder holds no logic. No parsing, no dedup, no reordering. Every feature you add there is a feature that can stall all your bots at once.
  • Consumers never share a socket. Each one binds its own port and has its own receive buffer, so a slow consumer only hurts itself.
  • The bot that pays for every microsecond reads the destination socket directly, if it can. Everything else hangs off the forwarder.

That last rule is a choice, not a law. Some teams prefer that every consumer, including the fast one, sits behind the forwarder so all of them see identical input. That is fine too; just make the trade knowingly.

SO_REUSEPORT spreads datagrams, it does not copy them#

The first idea many people have is to let several programs bind the same port with SO_REUSEPORT. The socket(7) man page describes what that option is for: better distribution of incoming UDP datagrams across processes or threads. Distribution means each datagram goes to one socket. It is a load balancer, and a shred consumer that receives a random subset of the stream is broken.

It is worse than random for a feed. The kernel picks the socket by hashing the packet's addresses and ports, and a feed arrives from one source address and port. This short test binds two sockets to port 19200 with SO_REUSEPORT and sends 50 datagrams, first from a single sender, then from 50 senders with one datagram each:

output
one sender, 50 datagrams: [0, 50]
50 senders, 1 datagram each: [22, 28]

With one sender, one socket received everything and the other received nothing. With many senders the datagrams were split between the two. Neither case gives you a copy per consumer. SO_REUSEPORT has real uses for a receiver, such as spreading work across threads when traffic comes from many sources, but copying is not one of them.

A forwarder you can read in one sitting#

This is the forwarder we tested. It takes the listening port and a list of targets, and copies every datagram to each target:

fanout.py
1# fanout.py: receive shreds on one UDP port and copy each datagram to every target.
2# usage: python3 fanout.py 9000 127.0.0.1:9101 10.0.0.12:9000
3import socket
4import sys
5import time
6
7listen_port = int(sys.argv[1])
8targets = []
9for arg in sys.argv[2:]:
10 host, port = arg.rsplit(":", 1)
11 targets.append((host, int(port)))
12
13rx = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
14rx.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 8 << 20) # capped by net.core.rmem_max
15rx.bind(("0.0.0.0", listen_port))
16
17tx = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
18tx.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 8 << 20) # capped by net.core.wmem_max
19tx.setblocking(False) # a stuck target must never stall the receive loop
20
21buf = bytearray(2048)
22view = memoryview(buf)
23received = 0
24sent = [0] * len(targets)
25dropped = [0] * len(targets)
26next_report = time.monotonic() + 10
27
28while True:
29 n = rx.recv_into(buf)
30 received += 1
31 for i, target in enumerate(targets):
32 try:
33 tx.sendto(view[:n], target)
34 sent[i] += 1
35 except OSError: # send buffer full, no route, or an ICMP error
36 dropped[i] += 1
37 if time.monotonic() >= next_report:
38 print(f"in={received} sent={sent} dropped={dropped}", file=sys.stderr, flush=True)
39 next_report += 10

To test it, we ran it on port 19100 with two consumers on 127.0.0.1:19101 and 127.0.0.1:19102, and sent 20,000 datagrams of 1,228 bytes, each numbered and filled with random bytes. Each consumer hashed what it received:

output
sent 20000 3decbfaf2db2905a
19101 20000 3decbfaf2db2905a
19102 20000 3decbfaf2db2905a

Both consumers got all 20,000 datagrams with a hash identical to the sender's. A second run pointed one target at a port with nothing listening. The forwarder kept going and reported dropped=[0, 0]: on an unconnected UDP socket, a send to a dead port on loopback still succeeds. That is the lesson we would underline. The forwarder's counters tell you what it sent, not what anyone received. Each consumer has to watch its own socket drops, with the counters described in Linux sockets and buffers.

Two details in the code matter more than they look. The send socket is non-blocking, so one target with a full send buffer costs a counted drop instead of freezing the loop for everyone. And the receive buffer request is silently capped by net.core.rmem_max, so raise that first, on the host, as the sockets page shows.

Python makes the logic easy to read, but it pays one system call per datagram per target. Measure it against your own traffic before trusting it. If it falls behind, the same design in C or Rust can read batches with recvmmsg and send them with sendmmsg, which has been in Linux since 3.0.

Multicast on your own LAN#

If you have many consumers on many hosts, multicast lets the network do the copying. The forwarder sends each datagram once to a group address, and every host that joined the group with IP_ADD_MEMBERSHIP gets a copy. RFC 2365 sets aside 239.0.0.0/8 for administratively scoped groups, with 239.192.0.0/14 as the organization-local scope, so a group such as 239.192.10.1 stays yours.

It is a good tool with real costs:

  • Switches. A switch that does not snoop IGMP forwards multicast out of every port in the segment. RFC 4541 describes exactly that: packets flooded into segments where no node wants them. If you go this way, confirm IGMP snooping and a querier on the switch.
  • Reach. The default multicast TTL is 1, so groups stay on the local network unless you raise it and route it. Many virtual networks in hosted environments do not carry multicast at all; ask your provider before you design around it.
  • Debugging. When one host stops receiving, the cause can be the group join, the switch, the firewall or the reverse path check. Unicast to a list of addresses has fewer places to hide.

As a starting point: for two to five consumers, unicast copies from a forwarder are simpler and easy to reason about. Multicast starts to pay when the consumer list is long and changes often, and someone on the team already runs the switches.

What the extra hop costs#

Fanning out is not free, and pretending it is leads to bad comparisons later.

  • A hop. Every consumer behind the forwarder sees a datagram only after the forwarder has woken up, read it and sent it. That adds scheduling delay and jitter, and it grows when the forwarder shares a busy CPU. Pin it to a core of its own if you can.
  • A copy per consumer. Each target costs a send and a kernel copy, and on a LAN it multiplies the feed's bandwidth by the number of remote consumers. Check the internal links, not just the uplink.
  • A second place to lose packets. The forwarder's socket can drop, and so can each consumer's. What causes packet loss and jitter walks through where loss hides, and the same counters apply at both stages.
  • A dependency. If the forwarder dies, every consumer goes quiet. Run it under a supervisor that restarts it, and alert on its input counter going flat.

None of this argues against the forwarder. It argues for measuring arrival at the consumer, not at the destination socket, when you compare setups. The difference between the two is the cost of your fan-out.

If the receiver runs in a container, the hop count can grow without you noticing. Running a shred receiver in Docker covers the NAT path and the userland proxy, which add their own copies.

When a consumer lives outside your network#

Fan-out is for your own machines on your own network. A server in another data center, or a second network path you want for resilience, is a different case: it needs its own feed, at its own address. Each extra destination is a separate purchase, at its plan's price, for 30 days. If the far consumer is less sensitive to timing, it can run on Standard while the main box runs on Ultra; Ultra vs Standard lays out the one difference between them, which is the delivery path.

Forwarding across the public internet also gives up what you paid for. The stream would take a longer, less predictable path and arrive later and with more loss than a direct feed to that server. Why serious Solana feeds still use plain UDP explains why nothing upstream will resend what gets lost on the way.

You can pass the stream on to any number of your own machines; sending it to anyone else needs a written agreement with us. Our acceptable use policy states the rule in full. For a team running several strategies, such as the setups in shreds for market makers, one destination and a small forwarder usually cover everything on one site.

Each plan has a free 2-hour trial, once per person. Email support@nitride.xyz with the IPv4 address and UDP port you want to test. We verify you receive on that address, then your 2 hours start.

Sources#

Read nextCan a cloud VPS keep up with a Solana shred feed?