summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhor911 <[email protected]>2022-08-07 17:28:22 +0300
committerhor911 <[email protected]>2022-08-07 17:28:22 +0300
commitccc7c68ba2a051861c8d517c87f293368e0b7c7b (patch)
tree7a50f8d370b0f213447af874dfd07fb3b224e9da
parenta18d511fddf3023584cf873456d21c895fd82d7e (diff)
Rename quotas
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/rate_limiter_resources.cpp4
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp28
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_quotas.cpp8
-rw-r--r--ydb/core/yq/libs/init/init.cpp12
-rw-r--r--ydb/core/yq/libs/quota_manager/events/events.h16
5 files changed, 49 insertions, 19 deletions
diff --git a/ydb/core/yq/libs/control_plane_storage/internal/rate_limiter_resources.cpp b/ydb/core/yq/libs/control_plane_storage/internal/rate_limiter_resources.cpp
index 8ce46676219..cc080d2522f 100644
--- a/ydb/core/yq/libs/control_plane_storage/internal/rate_limiter_resources.cpp
+++ b/ydb/core/yq/libs/control_plane_storage/internal/rate_limiter_resources.cpp
@@ -186,8 +186,8 @@ public:
void Handle(TEvQuotaService::TQuotaGetResponse::TPtr& ev) {
CPS_LOG_D("Got response from quota service");
- if (auto quotaIt = ev->Get()->Quotas.find(QUOTA_CPU_LIMIT); quotaIt != ev->Get()->Quotas.end()) {
- CloudLimit = static_cast<double>(quotaIt->second.Limit.Value * 1000);
+ if (auto quotaIt = ev->Get()->Quotas.find(QUOTA_CPU_PERCENT_LIMIT); quotaIt != ev->Get()->Quotas.end()) {
+ CloudLimit = static_cast<double>(quotaIt->second.Limit.Value * 100 * 1000);
Send(RateLimiterControlPlaneServiceId(), new TEvRateLimiter::TEvCreateResource(CloudId, FolderId, QueryId, CloudLimit, QueryLimit));
} else {
ReplyWithError("CPU quota for cloud was not found");
diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp
index ef614066ac6..28ad0d70e66 100644
--- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp
+++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp
@@ -79,10 +79,23 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery
TInstant startTime = TInstant::Now();
const TEvControlPlaneStorage::TEvCreateQueryRequest& event = *ev->Get();
const TString cloudId = event.CloudId;
- auto it = event.Quotas.find(QUOTA_RESULT_LIMIT);
+ const YandexQuery::CreateQueryRequest& request = event.Request;
+ auto it = event.Quotas.find(QUOTA_QUERY_RESULT_LIMIT);
ui64 resultLimit = (it != event.Quotas.end()) ? it->second.Limit.Value : 0;
- auto exec_ttl_it = event.Quotas.find(QUOTA_TIME_LIMIT);
- ui64 executionLimitMills = (exec_ttl_it != event.Quotas.end()) ? exec_ttl_it->second.Limit.Value : 0;
+ auto queryType = request.content().type();
+ ui64 executionLimitMills = 0;
+ if (queryType == YandexQuery::QueryContent::ANALYTICS) {
+ auto exec_ttl_it = event.Quotas.find(QUOTA_ANALYTICS_DURATION_LIMIT);
+ if (exec_ttl_it != event.Quotas.end()) {
+ executionLimitMills = exec_ttl_it->second.Limit.Value * 60 * 1000;
+ }
+ }
+ if (queryType == YandexQuery::QueryContent::STREAMING) {
+ auto exec_ttl_it = event.Quotas.find(QUOTA_STREAMING_DURATION_LIMIT);
+ if (exec_ttl_it != event.Quotas.end()) {
+ executionLimitMills = exec_ttl_it->second.Limit.Value * 60 * 1000;
+ }
+ }
const TString scope = event.Scope;
TRequestCountersPtr requestCounters = Counters.GetScopeCounters(cloudId, scope, RTS_CREATE_QUERY);
requestCounters->InFly->Inc();
@@ -95,7 +108,6 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery
if (IsSuperUser(user)) {
permissions.SetAll();
}
- const YandexQuery::CreateQueryRequest& request = event.Request;
const size_t byteSize = request.ByteSizeLong();
const TString queryId = GetEntityIdAsString(Config.IdsPrefix, EEntityType::QUERY);
CPS_LOG_T("CreateQueryRequest: {" << request.DebugString() << "} " << MakeUserInfo(user, token));
@@ -113,7 +125,13 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery
}
{
- auto it = event.Quotas.find(QUOTA_COUNT_LIMIT);
+ TQuotaMap::const_iterator it = event.Quotas.end();
+ if (queryType == YandexQuery::QueryContent::ANALYTICS) {
+ it = event.Quotas.find(QUOTA_ANALYTICS_COUNT_LIMIT);
+ }
+ if (queryType == YandexQuery::QueryContent::STREAMING) {
+ it = event.Quotas.find(QUOTA_STREAMING_COUNT_LIMIT);
+ }
if (it != event.Quotas.end()) {
auto& quota = it->second;
if (!quota.Usage) {
diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_quotas.cpp b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_quotas.cpp
index 9f0bac16a80..0cfba053b2f 100644
--- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_quotas.cpp
+++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_quotas.cpp
@@ -25,12 +25,13 @@ using TQuotaCountExecuter = TDbExecuter<THashMap<TString, ui32>>;
void TYdbControlPlaneStorageActor::Handle(TEvQuotaService::TQuotaUsageRequest::TPtr& ev) {
- if (ev->Get()->SubjectType != SUBJECT_TYPE_CLOUD || ev->Get()->MetricName != QUOTA_COUNT_LIMIT) {
+ if (ev->Get()->SubjectType != SUBJECT_TYPE_CLOUD
+ || (ev->Get()->MetricName != QUOTA_ANALYTICS_COUNT_LIMIT && ev->Get()->MetricName != QUOTA_STREAMING_COUNT_LIMIT) ) {
Send(ev->Sender, new TEvQuotaService::TQuotaUsageResponse(ev->Get()->SubjectType, ev->Get()->SubjectId, ev->Get()->MetricName, 0));
}
if (QuotasUpdatedAt + Config.QuotaTtl > Now()) {
- Send(ev->Sender, new TEvQuotaService::TQuotaUsageResponse(SUBJECT_TYPE_CLOUD, ev->Get()->SubjectId, QUOTA_COUNT_LIMIT, QueryQuotas.Value(ev->Get()->SubjectId, 0)));
+ Send(ev->Sender, new TEvQuotaService::TQuotaUsageResponse(SUBJECT_TYPE_CLOUD, ev->Get()->SubjectId, ev->Get()->MetricName, QueryQuotas.Value(ev->Get()->SubjectId, 0)));
}
QueryQuotaRequests[ev->Get()->SubjectId] = ev;
@@ -86,7 +87,8 @@ void TYdbControlPlaneStorageActor::Handle(TEvQuotaService::TQuotaUsageRequest::T
this->QueryQuotas.swap(executer.State);
for (auto& it : this->QueryQuotaRequests) {
auto ev = it.second;
- this->Send(ev->Sender, new TEvQuotaService::TQuotaUsageResponse(SUBJECT_TYPE_CLOUD, it.first, QUOTA_COUNT_LIMIT, this->QueryQuotas.Value(it.first, 0)));
+ this->Send(ev->Sender, new TEvQuotaService::TQuotaUsageResponse(SUBJECT_TYPE_CLOUD, it.first, QUOTA_ANALYTICS_COUNT_LIMIT, this->QueryQuotas.Value(it.first, 0)));
+ this->Send(ev->Sender, new TEvQuotaService::TQuotaUsageResponse(SUBJECT_TYPE_CLOUD, it.first, QUOTA_STREAMING_COUNT_LIMIT, this->QueryQuotas.Value(it.first, 0)));
}
this->QueryQuotaRequests.clear();
this->QuotasUpdating = false;
diff --git a/ydb/core/yq/libs/init/init.cpp b/ydb/core/yq/libs/init/init.cpp
index 68bcaece174..2e33bec6258 100644
--- a/ydb/core/yq/libs/init/init.cpp
+++ b/ydb/core/yq/libs/init/init.cpp
@@ -291,10 +291,14 @@ void Init(
credentialsProviderFactory,
serviceCounters.Counters,
{
- TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_RESULT_LIMIT, 20_MB, 2_GB),
- TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_COUNT_LIMIT, 100, 200, NYq::ControlPlaneStorageServiceActorId()),
- TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_TIME_LIMIT, 0),
- TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_CPU_LIMIT, 2, 32)
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_ANALYTICS_COUNT_LIMIT, 100, 1000, NYq::ControlPlaneStorageServiceActorId()),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_STREAMING_COUNT_LIMIT, 3, 100, NYq::ControlPlaneStorageServiceActorId()),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_CPU_PERCENT_LIMIT, 200, 3200),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_MEMORY_LIMIT, 0),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_RESULT_LIMIT, 0),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_ANALYTICS_DURATION_LIMIT, 1440),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_STREAMING_DURATION_LIMIT, 0),
+ TQuotaDescription(SUBJECT_TYPE_CLOUD, QUOTA_QUERY_RESULT_LIMIT, 20_MB, 2_GB)
});
actorRegistrator(NYq::MakeQuotaServiceActorId(nodeId), quotaService);
diff --git a/ydb/core/yq/libs/quota_manager/events/events.h b/ydb/core/yq/libs/quota_manager/events/events.h
index c43204dad5a..d9b72592c62 100644
--- a/ydb/core/yq/libs/quota_manager/events/events.h
+++ b/ydb/core/yq/libs/quota_manager/events/events.h
@@ -18,11 +18,17 @@ namespace NYq {
constexpr auto SUBJECT_TYPE_CLOUD = "cloud";
-constexpr auto QUOTA_CPU_LIMIT = "yq.cpu.count";
-constexpr auto QUOTA_COUNT_LIMIT = "yq.query.count";
-constexpr auto QUOTA_MEMORY_LIMIT = "yq.memory.size";
-constexpr auto QUOTA_TIME_LIMIT = "yq.ttlInSeconds.count";
-constexpr auto QUOTA_RESULT_LIMIT = "yq.result.size";
+// Quota per cloud
+constexpr auto QUOTA_ANALYTICS_COUNT_LIMIT = "yq.analyticsQuery.count";
+constexpr auto QUOTA_STREAMING_COUNT_LIMIT = "yq.streamingQuery.count";
+constexpr auto QUOTA_CPU_PERCENT_LIMIT = "yq.cpuPercent.count";
+constexpr auto QUOTA_MEMORY_LIMIT = "yq.memory.size";
+constexpr auto QUOTA_RESULT_LIMIT = "yq.result.size";
+
+// Quota per query
+constexpr auto QUOTA_ANALYTICS_DURATION_LIMIT = "yq.analyticsQueryDurationMinutes.count";
+constexpr auto QUOTA_STREAMING_DURATION_LIMIT = "yq.streamingQueryDurationMinutes.count"; // internal, for preview purposes
+constexpr auto QUOTA_QUERY_RESULT_LIMIT = "yq.queryResult.size";
struct TQuotaInfo {
ui64 DefaultLimit;