Hi! 👋 We are doing a big documentation refresh. Help us improve — what's missing or could be better? Let us know! Simply send an email or start a conversation in Google Groups!

Fast Forward Traffic Observer (FFTO)

Overview

ProxySQL’s Fast Forward mode routes traffic directly between clients and backend servers, bypassing the query processing pipeline to maximize throughput. While this delivers significant performance gains, it historically came at the cost of query observability — Fast Forward sessions did not populate query digest tables, making it impossible to monitor or profile traffic flowing through those sessions.

FFTO (Fast Forward Traffic Observer), introduced in ProxySQL 3.1.6, solves this by passively inspecting Fast Forward traffic without modifying it. It captures SQL digests, execution latency, rows sent/affected, and error information, feeding these metrics into the same stats_mysql_query_digest and stats_pgsql_query_digest tables used by standard proxy sessions. This gives operators full query observability across all sessions regardless of whether Fast Forward is enabled.

FFTO is enabled by default for both MySQL and PostgreSQL. It requires no changes to application code or backend configuration, and is designed to have a negligible impact on throughput. All official ProxySQL packages include FFTO support.


How It Works

FFTO operates as a passive traffic observer attached to Fast Forward sessions. It inspects protocol packets in transit and extracts query metadata — including normalized query text, execution timing, row counts, and error codes — without altering the data path or adding synchronous overhead to packet forwarding.

The observer runs alongside the Fast Forward data path rather than within it. If observation itself causes latency or memory pressure (for example, if a connection generates packets faster than the buffer can be flushed), FFTO gracefully degrades by disabling observation for that session. Traffic continues unaffected; only the observability for that session is suspended. This ensures that FFTO never degrades the throughput guarantees that Fast Forward mode provides.


Protocol Support

MySQL

FFTO supports both text and binary protocol communication in MySQL Fast Forward sessions:

  • Text protocol (COM_QUERY): queries sent as plain text strings
  • Binary protocol (COM_STMT_PREPARE, COM_STMT_EXECUTE): prepared statement execution, including tracking across the full prepare/execute lifecycle

Statement handles are tracked so that digest information is correctly attributed to the original query text even when the execution uses a binary protocol statement ID.

PostgreSQL

FFTO supports both the simple and extended query protocols for PostgreSQL Fast Forward sessions:

  • Simple query protocol: single-round-trip queries sent as plain text
  • Extended query protocol: Parse, Bind, and Execute message sequences, with digest attribution tied to the parsed query text
  • Pipelined queries: multiple queries sent without waiting for individual responses between them

Configuration Variables

FFTO behavior is controlled by the following global variables. Changes take effect after loading the relevant variables to runtime.

VariableDefaultDescription
mysql-ffto_enabledtrueEnable or disable FFTO for MySQL Fast Forward sessions
mysql-ffto_max_buffer_size1048576 (1 MB)Maximum buffer size per connection for packet capture
pgsql-ffto_enabledtrueEnable or disable FFTO for PostgreSQL Fast Forward sessions
pgsql-ffto_max_buffer_size1048576 (1 MB)Maximum buffer size per connection for packet capture
Info

FFTO requires ProxySQL to be compiled with the PROXYSQLFFTO=1 build flag. This flag is included in all official ProxySQL packages.


Metrics Captured

FFTO feeds metrics into the standard query digest tables, making Fast Forward traffic visible alongside standard session traffic in the same views:

  • stats_mysql_query_digest (MySQL)
  • stats_pgsql_query_digest (PostgreSQL)

The following per-query metrics are captured for each observed Fast Forward session:

MetricDescription
SQL digestNormalized query text and its hash
Execution latencyTime from query send to response received, in microseconds
Rows sentNumber of rows returned (applicable to SELECT queries)
Rows affectedNumber of rows modified (applicable to INSERT, UPDATE, DELETE)
Error codesBackend error codes returned in response packets
Execution countNumber of times the digest has been executed

Performance

FFTO is designed to add less than 5% throughput overhead compared to uninstrumented Fast Forward mode. The observer runs outside the critical forwarding path and uses buffered packet inspection to minimize synchronous work during packet relay.

If the per-connection buffer limit (mysql-ffto_max_buffer_size or pgsql-ffto_max_buffer_size) is reached — for example, due to a large result set or a burst of pipelined queries — observation is disabled for that connection for the remainder of its current request cycle. Traffic continues to flow normally; the buffer limit prevents observation from consuming unbounded memory.


Example: Enabling and Verifying FFTO

-- Check FFTO is enabled (default)
SELECT * FROM global_variables WHERE variable_name LIKE '%ffto%';

-- Configure a user for fast forward
UPDATE mysql_users SET fast_forward=1 WHERE username='app_user';
LOAD MYSQL USERS TO RUNTIME;

-- After some traffic, check query digests from fast forward sessions
SELECT hostgroup, digest_text, count_star, sum_time
FROM stats_mysql_query_digest
ORDER BY sum_time DESC LIMIT 10;