vitess.io/vitess@v0.16.2/doc/design-docs/ReplicationLagBasedThrottlingOfTransactions.md (about)

     1  # Replication Lag Based Throttling of Transactions 
     2  Vitess supports throttling of transactions based on replication lag. When this
     3  feature is turned on, each VTTablet primary monitors the replication lag from
     4  the replicas, and based on the observed replication lag tries to rate-limit the
     5  received transactions to keep the replication lag under a configured limit.
     6  
     7  The decision of whether to throttle a transaction is done in the `BEGIN`
     8  statement rather than in the `COMMIT` statement to avoid having a transaction
     9  perform a lot of work just to eventually be throttled and potentially 
    10  rolled-back if the open-transaction timeout is exceeded.
    11  
    12  If a BEGIN statement is throttled the client receives the gRPC UNAVAILABLE
    13  error code.
    14  
    15  The following VTTablet command line flags control the replication-lag based 
    16  throttler:
    17  
    18  * *enable-tx-throttler*
    19  
    20  A boolean flag controlling whether the replication-lag-based throttling is enabled.
    21  
    22  * *tx-throttler-config*
    23  
    24  A text-format representation of the  [throttlerdata.Configuration](https://github.com/vitessio/vitess/blob/main/proto/throttlerdata.proto) protocol buffer 
    25  that contains configuration options for the throttler. 
    26  The most important fields in that message are *target_replication_lag_sec* and 
    27  *max_replication_lag_sec* that specify the desired limits on the replication lag. See the comments in the protocol definition file for more details.
    28  If this is not specified a [default](https://github.com/vitessio/vitess/tree/main/go/vt/vttablet/tabletserver/tabletenv/config.go) configuration will be used.
    29  
    30  * *tx-throttler-healthcheck-cells*
    31  
    32  A comma separated list of datacenter cells. The throttler will only monitor
    33  the non-RDONLY replicas found in these cells for replication lag.
    34  
    35  # Caveats and Known Issues
    36  * The throttler keeps trying to explore the maximum rate possible while keeping
    37  the replication lag under the desired limit; as such the desired replication 
    38  lag limit may occasionally be slightly violated.
    39  
    40  * Transactions are considered homogeneous. There is currently no support
    41  for specifying how `expensive` a transaction is.
    42