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:
- Client connects to RTTP Proxy via the RTTP protocol.
- After receiving the connection, RTTP Proxy immediately initiates a TCP connection to the application server.
- 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
libuvasynchronous 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
| Parameter | Description | Example |
|---|---|---|
local_host_ip | Local IP address where RTTP service listens. | 0.0.0.0 |
local_port | UDP port where RTTP service listens. | 9000 |
forward_host_ip | TCP IP address of the backend application server. | 127.0.0.1 |
forward_port | TCP port of the backend application server. | 8080 |
max_connections | Maximum 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
| Path | Description | Return Format |
|---|---|---|
/ | Monitoring home page, containing links to various features. | HTML |
/health | Health check interface, returns uptime. | JSON |
/ready | Readiness check interface, confirms if it is receiving connections. | JSON |
/metrics | Metric data in standard Prometheus format. | Plain Text |
/stats | Statistical information of current active connections (RTT, loss rate distribution). | HTML |
/connections | Detailed list of all currently active connections. | HTML |
/stats-history | Historical 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.