Skip to main content

RTTP Proxy

To avoid modifying existing application servers, the RTTP protocol can be integrated by setting up an RTTP Proxy.

RTTP Proxy is a high-performance protocol conversion gateway. It receives RTTP connections (based on UDP) from clients and forwards all received data to the backend application server via TCP. This enables applications to leverage RTTP's network resilience without changing existing TCP service code.

How It Works

RTTP Proxy acts as a bridge between the client and the application server:

  1. Client connects to RTTP Proxy via the RTTP protocol.
  2. After receiving the connection, RTTP Proxy immediately initiates a TCP connection to the application server.
  3. RTTP Proxy performs bidirectional transparent transmission between the two connections:
    • Unpacks data received via RTTP and forwards it to TCP.
    • Packs data received via TCP and sends it to the client via RTTP.
[Client] <---- RTTP (UDP) ----> [RTTP Proxy] <---- TCP ----> [Application Server]

Key Features

  • Protocol Conversion: Transparently converts reliable UDP (RTTP) to standard TCP.
  • High Performance: Built on the libuv asynchronous I/O framework, supporting high concurrency connections.
  • Zero-Code Integration: No need to modify backend application server code; only simple configuration is required for access.
  • Built-in Monitoring: Provides an HTTP monitoring interface to view real-time connection status, RTT distribution, packet loss rate, and other metrics.
  • Prometheus Support: Native support for Prometheus metrics export, making it easy to integrate into existing monitoring systems.

Usage

RTTP Proxy is a command-line tool. When starting, you need to specify the local listening address, the forward destination address, and the maximum number of connections.

Start Command

RttpProxyServer <local_host_ip> <local_port> <forward_host_ip> <forward_port> <max_connections> [http_monitor_port]

Parameter Description

ParameterDescriptionExample
local_host_ipLocal IP address where RTTP service listens.0.0.0.0
local_portUDP port where RTTP service listens.9000
forward_host_ipTCP IP address of the backend application server.127.0.0.1
forward_portTCP port of the backend application server.8080
max_connectionsMaximum number of allowed concurrent connections.3000
http_monitor_port(Optional) Port for the HTTP monitoring service. Defaults to local_port + 1000.10000

Example

Assuming your application server is running at 127.0.0.1:8080, and you want to provide RTTP access on port 9000 with a maximum of 3000 connections:

./RttpProxyServer 0.0.0.0 9000 127.0.0.1 8080 3000 9001

Monitoring and Operations

RTTP Proxy includes a built-in HTTP monitoring server, with the default port being the RTTP port + 1000.

Monitoring Interfaces

PathDescriptionReturn Format
/Monitoring home page, containing links to various features.HTML
/healthHealth check interface, returns uptime.JSON
/readyReadiness check interface, confirms if it is receiving connections.JSON
/metricsMetric data in standard Prometheus format.Plain Text
/statsStatistical information of current active connections (RTT, loss rate distribution).HTML
/connectionsDetailed list of all currently active connections.HTML
/stats-historyHistorical statistical information of closed connections (recent 100).HTML

Prometheus Metrics

Through the /metrics interface, you can obtain the following key metrics:

  • rttp_active_connections: Number of currently active connections.
  • rttp_total_connections: Total number of connections handled since startup.
  • rttp_rtt_distribution_active: RTT distribution of active connections.
  • rttp_loss_rate_distribution_active: Physical network packet loss rate distribution of active connections.

Deployment

RTTP Proxy should be deployed on a server in the same data center as the application server to ensure low latency and high availability.

Performance

The core logic of RTTP Proxy occupies only one thread. For high concurrency scenarios like online game traffic, it can support at least 3000 concurrent connections while maintaining low latency. If you need to fully utilize the performance of multi-core servers, you can start multiple instances.