mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
[ADDED] Support for route S2 compression
The new field `compression` in the `cluster{}` block allows to
specify which compression mode to use between servers.
It can be simply specified as a boolean or a string for the
simple modes, or as an object for the "s2_auto" mode where
a list of RTT thresholds can be specified.
By default, if no compression field is specified, the server
will use the s2_auto mode with default RTT thresholds of
10ms, 50ms and 100ms for the "uncompressed", "fast", "better"
and "best" modes.
```
cluster {
..
# Possible values are "disabled", "off", "enabled", "on",
# "accept", "s2_fast", "s2_better", "s2_best" or "s2_auto"
compression: s2_fast
}
```
To specify a different list of thresholds for the s2_auto,
here is how it would look like:
```
cluster {
..
compression: {
mode: s2_auto
# This means that for RTT up to 5ms (included), then
# the compression level will be "uncompressed", then
# from 5ms+ to 15ms, the mode will switch to "s2_fast",
# then from 15ms+ to 50ms, the level will switch to
# "s2_better", and anything above 50ms will result
# in the "s2_best" compression mode.
rtt_thresholds: [5ms, 15ms, 50ms]
}
}
```
Note that the "accept" mode means that a server will accept
compression from a remote and switch to that same compression
mode, but will otherwise not initiate compression. That is,
if 2 servers are configured with "accept", then compression
will actually be "off". If one of the server had say s2_fast
then they would both use this mode.
If a server has compression mode set (other than "off") but
connects to an older server, there will be no compression between
those 2 routes.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -686,11 +686,13 @@ func routeStat(r *client) *RouteStat {
|
||||
return nil
|
||||
}
|
||||
r.mu.Lock()
|
||||
// Note: *client.out[Msgs|Bytes] are not set using atomics,
|
||||
// unlike in[Msgs|Bytes].
|
||||
rs := &RouteStat{
|
||||
ID: r.cid,
|
||||
Sent: DataStats{
|
||||
Msgs: atomic.LoadInt64(&r.outMsgs),
|
||||
Bytes: atomic.LoadInt64(&r.outBytes),
|
||||
Msgs: r.outMsgs,
|
||||
Bytes: r.outBytes,
|
||||
},
|
||||
Received: DataStats{
|
||||
Msgs: atomic.LoadInt64(&r.inMsgs),
|
||||
@@ -732,9 +734,11 @@ func (s *Server) sendStatsz(subj string) {
|
||||
gs := &GatewayStat{Name: name}
|
||||
c.mu.Lock()
|
||||
gs.ID = c.cid
|
||||
// Note that *client.out[Msgs|Bytes] are not set using atomic,
|
||||
// unlike the in[Msgs|bytes].
|
||||
gs.Sent = DataStats{
|
||||
Msgs: atomic.LoadInt64(&c.outMsgs),
|
||||
Bytes: atomic.LoadInt64(&c.outBytes),
|
||||
Msgs: c.outMsgs,
|
||||
Bytes: c.outBytes,
|
||||
}
|
||||
c.mu.Unlock()
|
||||
// Gather matching inbound connections
|
||||
|
||||
Reference in New Issue
Block a user