Skip to content
Merged
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
1 change: 1 addition & 0 deletions ydb/core/http_proxy/http_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace NKikimr::NHttpProxy {
const auto& config = Config.GetHttpConfig();
THolder<NHttp::TEvHttpProxy::TEvAddListeningPort> ev =
MakeHolder<NHttp::TEvHttpProxy::TEvAddListeningPort>(config.GetPort());
ev->MaxRecycledRequestsCount = 0;
ev->Secure = config.GetSecure();
ev->CertificateFile = config.GetCert();
ev->PrivateKeyFile = config.GetKey();
Expand Down
4 changes: 4 additions & 0 deletions ydb/library/actors/http/http_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace NHttp {

const ui32 DEFAULT_MAX_RECYCLED_REQUESTS_COUNT = 1000;

struct TSocketDescriptor : NActors::TSharedDescriptor, THttpConfig {
SocketType Socket;

Expand Down Expand Up @@ -65,6 +67,8 @@ struct TEvHttpProxy {
TString SslCertificatePem;
std::vector<TString> CompressContentTypes;

ui32 MaxRecycledRequestsCount = DEFAULT_MAX_RECYCLED_REQUESTS_COUNT;

TEvAddListeningPort() = default;

TEvAddListeningPort(TIpPort port)
Expand Down
5 changes: 5 additions & 0 deletions ydb/library/actors/http/http_proxy_acceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TAcceptorActor : public NActors::TActor<TAcceptorActor>, public THttpConfi
NActors::TPollerToken::TPtr PollerToken;
THashSet<TActorId> Connections;
TDeque<THttpIncomingRequestPtr> RecycledRequests;
ui32 MaxRecycledRequestsCount = 0;
std::shared_ptr<TPrivateEndpointInfo> Endpoint;

TAcceptorActor(const TActorId& owner, const TActorId& poller)
Expand Down Expand Up @@ -43,6 +44,7 @@ class TAcceptorActor : public NActors::TActor<TAcceptorActor>, public THttpConfi
void HandleInit(TEvHttpProxy::TEvAddListeningPort::TPtr event, const NActors::TActorContext& ctx) {
TString address = event->Get()->Address;
ui16 port = event->Get()->Port;
MaxRecycledRequestsCount = event->Get()->MaxRecycledRequestsCount;
Socket = new TSocketDescriptor(SocketType::GuessAddressFamily(address));
// for unit tests :(
SetSockOpt(Socket->Socket, SOL_SOCKET, SO_REUSEADDR, (int)true);
Expand Down Expand Up @@ -141,6 +143,9 @@ class TAcceptorActor : public NActors::TActor<TAcceptorActor>, public THttpConfi
void Handle(TEvHttpProxy::TEvHttpConnectionClosed::TPtr event, const NActors::TActorContext&) {
Connections.erase(event->Get()->ConnectionID);
for (auto& req : event->Get()->RecycledRequests) {
if (RecycledRequests.size() >= MaxRecycledRequestsCount) {
break;
}
req->Clear();
RecycledRequests.push_back(std::move(req));
}
Expand Down