This repository demonstrates the performance differences between TCP sockets and Local Sockets for local communication. It includes a simple server that supports both communication methods and a benchmarking script using curl.
- Supports HTTP over TCP and HTTP over Local Sockets
- Simple benchmarking script to measure latency
- Demonstrates the performance benefits of Unix sockets for local communication
git clone https://github.com/msf37/local-socket.git
cd local-socketStart the server:
go run main.gobash benchmark.shTCP Benchmark Results:
---------------------
Latency Statistics (seconds):
Minimum: 0.002243s
Maximum: 0.002243s
Average: 0.002243s
Unix Domain Socket Benchmark Results:
-----------------------------------
Latency Statistics (seconds):
Minimum: 0.000176s
Maximum: 0.000176s
Average: 0.000176s
- Local Sockets offer significantly lower latency than TCP for local communication (~92.2% faster).
- Ideal for communication between services running on the same machine or container.
- Helps reduce network stack overhead and improve performance.