You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/concept-docs/pages/compression.adoc
+30-20Lines changed: 30 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
= Compression
2
2
: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.
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.
15
17
====
16
18
17
19
== Overview
18
20
19
21
Documents may already be stored compressed with Snappy on the server.
20
22
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.
22
25
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]).
25
27
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:
29
28
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]
31
36
----
32
37
// 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
34
40
35
41
// ClusterOptions parameters
36
42
var clusterOptions = new ClusterOptions
37
43
{
38
44
Compression = true,
39
45
CompressionMinRatio = 0.82f, // Float value between 1 and 0.
40
46
CompressionMinSize = 512 // Integer value represented in bytes.
@@ -49,26 +55,29 @@ var cluster = await Cluster.ConnectAsync(clusterOptions).ConfigureAwait(false);
49
55
50
56
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`.
51
57
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:
// See Couchbase.Compression.Snappier.Internal.SnappierCompression for details on how Snappier implements the interface.
59
67
----
60
68
61
-
[Note]
69
+
[CAUTION]
62
70
====
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].
64
72
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.
66
74
====
67
75
76
+
68
77
== Limits
69
78
70
79
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.
72
81
73
82
[TIP]
74
83
====
@@ -81,9 +90,10 @@ A compressed doument of just under 20MB, which is greater than 20,971,520 bytes
81
90
Therefore, where necessary, enforce document size limits in your application on _uncompressed_ documents.
82
91
====
83
92
93
+
84
94
== Operating Modes (Server-side)
85
95
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.
87
97
88
98
.Compression Operating Modes
89
99
[#compression-operating-modes]
@@ -123,5 +133,5 @@ https://github.com/brantburnett/Snappier[Snappier] is
123
133
integrated with the https://github.com/couchbaselabs/Couchbase.Extensions[.NET Couchbase.Extensions Library].
124
134
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.
125
135
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.
127
137
// 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