Skip to content

Commit 06a98bd

Browse files
committed
Concurrency now per project, use env vars
1 parent f9ce7c7 commit 06a98bd

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

apps/webapp/app/env.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,10 @@ const EnvironmentSchema = z
12121212

12131213
// Query page concurrency limits
12141214
QUERY_DEFAULT_ORG_CONCURRENCY_LIMIT: z.coerce.number().int().default(3),
1215-
QUERY_GLOBAL_CONCURRENCY_LIMIT: z.coerce.number().int().default(50),
1215+
QUERY_GLOBAL_CONCURRENCY_LIMIT: z.coerce.number().int().default(100),
1216+
1217+
// Metric widget concurrency limits
1218+
METRIC_WIDGET_DEFAULT_ORG_CONCURRENCY_LIMIT: z.coerce.number().int().default(30),
12161219

12171220
EVENTS_CLICKHOUSE_URL: z
12181221
.string()

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { redirect, type ActionFunctionArgs, type LoaderFunctionArgs } from "@remix-run/server-runtime";
1+
import {
2+
redirect,
3+
type ActionFunctionArgs,
4+
type LoaderFunctionArgs,
5+
} from "@remix-run/server-runtime";
26
import { typedjson, useTypedLoaderData } from "remix-typedjson";
37
import { z } from "zod";
48
import { QueryEditor } from "~/components/query/QueryEditor";
@@ -89,6 +93,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
8993
isImpersonating: user.isImpersonating,
9094
organizationSlug,
9195
});
96+
9297
if (!canAccess) {
9398
return typedjson(
9499
{

apps/webapp/app/routes/resources.metric.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "~/components/metrics/QueryWidget";
1313
import { useElementVisibility } from "~/hooks/useElementVisibility";
1414
import { useInterval } from "~/hooks/useInterval";
15+
import { env } from "~/env.server";
1516

1617
const Scope = z.union([z.literal("environment"), z.literal("organization"), z.literal("project")]);
1718

@@ -107,7 +108,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
107108
taskIdentifiers,
108109
queues,
109110
// Set higher concurrency if many widgets are on screen at once
110-
customOrgConcurrencyLimit: 15,
111+
customOrgConcurrencyLimit: env.METRIC_WIDGET_DEFAULT_ORG_CONCURRENCY_LIMIT,
111112
});
112113

113114
if (!queryResult.success) {

apps/webapp/app/services/queryService.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function executeQuery<TOut extends z.ZodSchema>(
138138

139139
// Acquire concurrency slot
140140
const acquireResult = await queryConcurrencyLimiter.acquire({
141-
key: organizationId,
141+
key: projectId,
142142
requestId,
143143
keyLimit: orgLimit,
144144
globalLimit: GLOBAL_CONCURRENCY_LIMIT,

0 commit comments

Comments
 (0)