Skip to content

(feature) Add Unix socket support for GO Feature Flag relay proxy #4244

@thomaspoignant

Description

@thomaspoignant

Motivation

Currently, the GO Feature Flag relay proxy only supports HTTP/HTTPS connections over TCP. In Kubernetes environments, using Unix sockets can provide significant performance benefits by reducing network latency when the relay proxy is deployed as a sidecar container.

Requirements

Expose the relay proxy API through Unix sockets in addition to the existing HTTP/HTTPS endpoints. This would enable:

  1. Reduced Network Latency: Unix sockets provide faster inter-process communication compared to TCP/IP when processes are running on the same host
  2. Simplified Kubernetes Deployments: When using the relay proxy as a sidecar, applications can communicate via Unix sockets without exposing additional network ports
  3. Improved Security: Unix sockets provide better isolation as they operate at the filesystem level rather than network level

Use Case

Primary scenario: Kubernetes deployments with sidecar pattern

  • Deploy GO Feature Flag relay proxy as a sidecar container alongside the main application container
  • Share a volume between containers to expose the Unix socket
  • Application communicates with the relay proxy via Unix socket instead of localhost HTTP
  • Eliminates network stack overhead for feature flag evaluations

Proposed Implementation

The relay proxy should support a new configuration option to listen on a Unix socket in addition to (or instead of) TCP ports:

# Example configuration
listen: 1031 #old option
unixSocket: "/var/run/goff/goff.sock"  # New option

When a Unix socket path is configured:

  • The relay proxy should create and listen on the specified Unix socket
  • All existing API endpoints should be accessible through the Unix socket
  • The socket file should have appropriate permissions (configurable)
  • Proper cleanup of the socket file on shutdown

Technical Considerations

  • Unix sockets are supported by Go's `net` package (via `net.Listen("unix", path)`)
  • The Echo framework (used by the relay proxy) supports Unix socket listeners
  • Socket file permissions and cleanup should be handled properly
  • Documentation should include examples for Kubernetes deployment with shared volumes
  • Consider supporting both TCP and Unix socket simultaneously for migration scenarios

Expected Behavior

Clients should be able to make the same HTTP requests to the Unix socket as they would to the TCP endpoint:

# Current TCP approach
curl http://localhost:1031/health

# New Unix socket approach  
curl --unix-socket /var/run/goff/goff.sock http://localhost/health

Context: This feature was requested by @augustinas on Slack to reduce network latency in Kubernetes environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions