Skip to content

add compression to grpc server (#15939) #16689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: stable-25-1-1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ydb/core/driver_lib/run/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,40 @@ void TKikimrRunner::InitializeGRpc(const TKikimrRunConfig& runConfig) {
opts.SetMaxMessageSize(grpcConfig.HasMaxMessageSize() ? grpcConfig.GetMaxMessageSize() : NYdbGrpc::DEFAULT_GRPC_MESSAGE_SIZE_LIMIT);
opts.SetMaxGlobalRequestInFlight(grpcConfig.GetMaxInFlight());
opts.SetLogger(NYdbGrpc::CreateActorSystemLogger(*ActorSystem.Get(), NKikimrServices::GRPC_SERVER));
switch(grpcConfig.GetDefaultCompressionAlgorithm()) {
case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_NONE: {
opts.SetDefaultCompressionAlgorithm(GRPC_COMPRESS_NONE);
break;
}
case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_DEFLATE: {
opts.SetDefaultCompressionAlgorithm(GRPC_COMPRESS_DEFLATE);
break;
}
case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_GZIP: {
opts.SetDefaultCompressionAlgorithm(GRPC_COMPRESS_GZIP);
break;
}
}

switch(grpcConfig.GetDefaultCompressionLevel()) {
case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_LEVEL_NONE: {
opts.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_NONE);
break;
}

case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_LEVEL_LOW: {
opts.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_LOW);
break;
}
case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_LEVEL_MED: {
opts.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_MED);
break;
}
case NKikimrConfig::TGRpcConfig::YDB_GRPC_COMPRESS_LEVEL_HIGH: {
opts.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_HIGH);
break;
}
}

if (appConfig.HasDomainsConfig() &&
appConfig.GetDomainsConfig().HasSecurityConfig() &&
Expand Down
17 changes: 17 additions & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,23 @@ message TGRpcConfig {
repeated string RatelimiterServicesEnabled = 25;
repeated string RatelimiterServicesDisabled = 26;

enum YdbGrpcCompressionAlgorithm {
YDB_GRPC_COMPRESS_NONE = 0;
YDB_GRPC_COMPRESS_DEFLATE = 1;
YDB_GRPC_COMPRESS_GZIP = 2;
};

optional YdbGrpcCompressionAlgorithm DefaultCompressionAlgorithm = 30 [default = YDB_GRPC_COMPRESS_NONE];

enum YdbGrpcCompressionLevel {
YDB_GRPC_COMPRESS_LEVEL_NONE = 0;
YDB_GRPC_COMPRESS_LEVEL_LOW = 1;
YDB_GRPC_COMPRESS_LEVEL_MED = 2;
YDB_GRPC_COMPRESS_LEVEL_HIGH = 3;
}

optional YdbGrpcCompressionLevel DefaultCompressionLevel = 31 [default = YDB_GRPC_COMPRESS_LEVEL_NONE];

// server socket options
optional bool KeepAliveEnable = 100 [default = true]; // SO_KEEPALIVE
optional uint32 KeepAliveIdleTimeoutTriggerSec = 101 [default = 90]; // TCP_KEEPIDLE
Expand Down
2 changes: 2 additions & 0 deletions ydb/library/grpc/server/grpc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ struct TServerOptions {
// Mapping to particular compression algorithm depends on client.
DECLARE_FIELD(DefaultCompressionLevel, grpc_compression_level, GRPC_COMPRESS_LEVEL_NONE);

DECLARE_FIELD(DefaultCompressionAlgorithm, grpc_compression_algorithm, GRPC_COMPRESS_NONE);

//! Custom configurator for ServerBuilder.
DECLARE_FIELD(ServerBuilderMutator, std::function<void(grpc::ServerBuilder&)>, [](grpc::ServerBuilder&){});

Expand Down
Loading