Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measure local sockets speed?

How to measure the speed of data exchange via AF_UNIX sockets? Is it possible to write some two bash scripts:

  • First creates the socket, bind the socket to the local address, accept the connection and receive all data to /dev/null.
  • The second one creates the socket, establish the connection with the already opened socket and spawn some device in /dev so it will be possible to measure the speed with dd command?

1 Answers

You can use netcat -U to easily communicate over unix domain sockets. The pv command comes in handy when you want to know the speed at which data is moving through a pipe.

receiver:

nc -lU /tmp/socket > /dev/null

sender:

pv /dev/zero | nc -U /tmp/socket

In general, unix sockets are really fast. This clocked in at 170 MB/s on my old laptop, and 400 MB/s on my somewhat newer desktop.

like image 196
A B Avatar answered Mar 19 '26 01:03

A B