Skip to content

Commit d606426

Browse files
backport of DOC-12922 changes from 3.6
1 parent c8479aa commit d606426

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

modules/concept-docs/pages/compression.adoc

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= Compression
22
:description: In response to increasing volumes of data being sent over the wire, Couchbase Data Platform provides data compression between the SDK and Couchbase Server.
3+
:page-toclevels: 2
34
:page-topic-type: concept
45
:page-edition: Enterprise Edition
56
:page-aliases:ROOT:compression-intro,compression-intro
@@ -9,36 +10,41 @@ include::project-docs:partial$attributes.adoc[]
910
[abstract]
1011
{description}
1112

12-
[Note]
13+
[NOTE]
1314
====
14-
From version 3.5.2, the .NET SDK enables compression by default using https://www.nuget.org/packages/Snappier[Snappier], a performance-focused C# port of https://github.com/google/snappy[Snappy]. This was previously opt-in only via installing the corresponding https://www.nuget.org/packages/Couchbase.Extensions.Compression.Snappier/1.0.0-beta.1[Couchbase.Extensions] package.
15+
From version 3.5.2, the .NET SDK provides compression by using https://www.nuget.org/packages/Snappier[Snappier], a performance-focused C# port of https://github.com/google/snappy[Snappy].
16+
This was previously opt-in only via installing the corresponding https://www.nuget.org/packages/Couchbase.Extensions.Compression.Snappier/1.0.0-beta.1[Couchbase.Extensions] package.
1517
====
1618

1719
== Overview
1820

1921
Documents may already be stored compressed with Snappy on the server.
2022
New documents may be passed from client applications to the server in compressed form, saving around 40% in bandwidth (depending on the document content and size), and also transmission time.
21-
These operations take place automatically, after the SDK negotiates the capability with the server, and do not require any changes on the client side.
23+
Register a Snappy plugin for the SDK to use compression for requests and responses, using the `WithSnappyCompression()` extension method,
24+
then these operations take place automatically after the SDK negotiates the capability with the server.
2225

23-
For SDKs with Snappy compression enabled, documents will be automatically compressed if compression is not turned `Off` in xref:7.1@server:learn:buckets-memory-and-storage/compression.adoc#compression-modes[Couchbase Server] (see xref:#minimum-size[below]).
24-
Instructions to disable compression can be found at xref:#threshold[the bottom of the page].
26+
For SDKs with Snappy compression enabled, documents will be automatically compressed if compression is not turned `Off` in xref:{version-server}@server:learn:buckets-memory-and-storage/compression.adoc#compression-modes[Couchbase Server] (see xref:#minimum-size[below]).
2527

26-
== Usage and customization
27-
Starting with .NET SDK v3.5.2, Snappier compression is enabled by default in the ClusterOptions.
28-
You can disable compression or customize certain settings, both via ClusterOptions or Connection String parameters:
2928

30-
[source,dotnet]
29+
== Usage and Customization
30+
31+
Starting with .NET SDK v3.5.2, Snappier compression is enabled in the `ClusterOptions` using the `WithSnappyCompression()` extension method.
32+
33+
You can disable compression or customize certain settings, both via `ClusterOptions` or Connection String parameters:
34+
35+
[source,csharp]
3136
----
3237
// ConnectionString parameters
33-
var connectionString = "couchbase://localhost:8091?compression=true&compression_min_size=512&compression_min_ratio=0.82";
38+
var connectionString = "couchbases://cb.<your-endpoint>.cloud.couchbase.com:18091?compression=true&compression_min_size=512&compression_min_ratio=0.82";
39+
// for development on local cluster, use: couchbase://localhost:8091
3440
3541
// ClusterOptions parameters
3642
var clusterOptions = new ClusterOptions
3743
{
3844
Compression = true,
3945
CompressionMinRatio = 0.82f, // Float value between 1 and 0.
4046
CompressionMinSize = 512 // Integer value represented in bytes.
41-
};
47+
}.WithSnappyCompression();
4248
4349
// Connect
4450
clusterOptions.WithConnectionString(connectionString);
@@ -49,26 +55,29 @@ var cluster = await Cluster.ConnectAsync(clusterOptions).ConfigureAwait(false);
4955

5056
Please refer to the https://docs.couchbase.com/sdk-api/couchbase-net-client/api/Couchbase.ClusterOptions.html#Couchbase_ClusterOptions_Compression[API Documentation] for details on `CompressionMinRatio` and `CompressionMinSize`.
5157

52-
== **Advanced**: Bring Your Own Compression
53-
You can provide the SDK with your own implementation of Snappy compression/decompression by implementing the `ICompressionAlgorithm` interface, and passing it through your ClusterOptions with:
54-
[source,dotnet]
58+
=== Advanced: Bring Your Own Compression
59+
60+
You can provide the SDK with your own implementation of Snappy compression/decompression by implementing the `ICompressionAlgorithm` interface, and passing it through your `ClusterOptions` with:
61+
62+
[source,csharp]
5563
----
5664
clusterOptions.WithCompressionAlgorithm(myCompressionImplementation);
5765
5866
// See Couchbase.Compression.Snappier.Internal.SnappierCompression for details on how Snappier implements the interface.
5967
----
6068

61-
[Note]
69+
[CAUTION]
6270
====
63-
Even when compression is turned `Off` server-side, Couchbase Server will decompress documents in memory, and store them recompressed on disk (using Snappy) xref:7.1@server:learn:buckets-memory-and-storage/compression.adoc#compression-modes[see server compression docs].
71+
Even when compression is turned `Off` server-side, Couchbase Server will decompress documents in memory, and store them recompressed on disk (using Snappy) xref:{version-server}@server:learn:buckets-memory-and-storage/compression.adoc#compression-modes[see server compression docs].
6472
65-
It is therefore not recommended to implement a different compression algorithm than Snappy as this may very well cause data corruption.
73+
It is therefore not recommended to implement a different compression algorithm from Snappy as this may very well cause data corruption.
6674
====
6775

76+
6877
== Limits
6978

7079
The document must be below 20MiB in size in both compressed and uncompressed form.
71-
Compression is only available in the Enterprise Edition of Couchbase Data Platform.
80+
Compression is available in Couchbase Capella, and in the Enterprise Edition of self-managed Couchbase Server.
7281

7382
[TIP]
7483
====
@@ -81,9 +90,10 @@ A compressed doument of just under 20MB, which is greater than 20,971,520 bytes
8190
Therefore, where necessary, enforce document size limits in your application on _uncompressed_ documents.
8291
====
8392

93+
8494
== Operating Modes (Server-side)
8595

86-
The three modes in which compression can be used, "off", "passive" and "active", are configured per bucket in the configuration settings on the cluster.
96+
The three modes in which compression can be used -- "off", "passive", and "active" -- are configured per bucket in the configuration settings on the cluster.
8797

8898
.Compression Operating Modes
8999
[#compression-operating-modes]
@@ -123,5 +133,5 @@ https://github.com/brantburnett/Snappier[Snappier] is
123133
integrated with the https://github.com/couchbaselabs/Couchbase.Extensions[.NET Couchbase.Extensions Library].
124134
Since xref:project-docs:sdk-release-notes.adoc#version-3-4-10[.NET SDK 3.4.10], the .NET SDK has been able to work with external Snappy libraries as the setting for the Server flag `SnappyEverywhere` is now supported.
125135

126-
Install Snappier with the https://github.com/couchbaselabs/Couchbase.Extensions[.NET Couchbase.Extensions] Library,
136+
Install Snappier with the https://github.com/couchbaselabs/Couchbase.Extensions[.NET Couchbase.Extensions] Library.
127137
// See the https://github.com/brantburnett/Snappier[Snappier GitHub page] for information on installing the external Snappier library, or get it from https://www.nuget.org/packages/Snappier[NuGet].

0 commit comments

Comments
 (0)