Skip to content

An open-source, faster Devin alternative

TypeScript

Raise default org concurrency to 50 (#525)

Mohamed Habib9780a29550ca
diff --git a/cloudflare-workers/api-edge/schema-snapshots/current_schema.sql b/cloudflare-workers/api-edge/schema-snapshots/current_schema.sql
index c9929120..6bebf7ce 100644
--- a/cloudflare-workers/api-edge/schema-snapshots/current_schema.sql
+++ b/cloudflare-workers/api-edge/schema-snapshots/current_schema.sql
@@ -157,7 +157,7 @@ CREATE TABLE orgs (
owner_user_id TEXT,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
-, is_halted INTEGER NOT NULL DEFAULT 0, halted_at INTEGER, custom_domain TEXT, cf_hostname_id TEXT, domain_verification_status TEXT NOT NULL DEFAULT 'none', domain_ssl_status TEXT NOT NULL DEFAULT 'none', verification_txt_name TEXT, verification_txt_value TEXT, ssl_txt_name TEXT, ssl_txt_value TEXT, free_credits_remaining_cents INTEGER NOT NULL DEFAULT 500, credit_balance_cents INTEGER NOT NULL DEFAULT 0, max_concurrent_sandboxes INTEGER NOT NULL DEFAULT 5, max_sandbox_timeout_sec INTEGER NOT NULL DEFAULT 3600, max_disk_mb INTEGER NOT NULL DEFAULT 0, max_memory_gb INTEGER NOT NULL DEFAULT 0, billing_mode TEXT NOT NULL DEFAULT 'unified', last_usage_reported_at INTEGER NOT NULL DEFAULT 0, billing_provider TEXT NOT NULL DEFAULT 'legacy', autumn_usage_watermark INTEGER NOT NULL DEFAULT 0, has_webhooks INTEGER NOT NULL DEFAULT 0, model_billing_status TEXT NOT NULL DEFAULT 'off', model_markup_bps INTEGER NOT NULL DEFAULT 0, autumn_concurrency_override INTEGER);
+, is_halted INTEGER NOT NULL DEFAULT 0, halted_at INTEGER, custom_domain TEXT, cf_hostname_id TEXT, domain_verification_status TEXT NOT NULL DEFAULT 'none', domain_ssl_status TEXT NOT NULL DEFAULT 'none', verification_txt_name TEXT, verification_txt_value TEXT, ssl_txt_name TEXT, ssl_txt_value TEXT, free_credits_remaining_cents INTEGER NOT NULL DEFAULT 500, credit_balance_cents INTEGER NOT NULL DEFAULT 0, max_concurrent_sandboxes INTEGER NOT NULL DEFAULT 50, max_sandbox_timeout_sec INTEGER NOT NULL DEFAULT 3600, max_disk_mb INTEGER NOT NULL DEFAULT 0, max_memory_gb INTEGER NOT NULL DEFAULT 0, billing_mode TEXT NOT NULL DEFAULT 'unified', last_usage_reported_at INTEGER NOT NULL DEFAULT 0, billing_provider TEXT NOT NULL DEFAULT 'legacy', autumn_usage_watermark INTEGER NOT NULL DEFAULT 0, has_webhooks INTEGER NOT NULL DEFAULT 0, model_billing_status TEXT NOT NULL DEFAULT 'off', model_markup_bps INTEGER NOT NULL DEFAULT 0, autumn_concurrency_override INTEGER);
CREATE TABLE sandboxes_index (
id TEXT PRIMARY KEY, -- sandbox_id
diff --git a/cloudflare-workers/api-edge/src/autumn_webhook.ts b/cloudflare-workers/api-edge/src/autumn_webhook.ts
index 22840f40..125277a5 100644
--- a/cloudflare-workers/api-edge/src/autumn_webhook.ts
+++ b/cloudflare-workers/api-edge/src/autumn_webhook.ts
@@ -42,12 +42,12 @@ const SVIX_TOLERANCE_SEC = 300;
// Mirror of internal/billing/autumn.ConcurrencyByPlan — keep in sync.
const CONCURRENCY_BY_PLAN: Record<string, number> = {
- base: 5,
+ base: 50,
concurrency_pro: 100,
concurrency_pro_plus: 600,
concurrency_pro_plus_plus: 1000,
};
-const DEFAULT_CONCURRENCY = 5;
+const DEFAULT_CONCURRENCY = 50;
const HANDLED_EVENTS = new Set([
"billing.updated",
diff --git a/cloudflare-workers/api-edge/src/index.ts b/cloudflare-workers/api-edge/src/index.ts
index e1d932e5..829fc1c4 100644
--- a/cloudflare-workers/api-edge/src/index.ts
+++ b/cloudflare-workers/api-edge/src/index.ts
@@ -71,6 +71,8 @@ export interface Env extends DashboardEnv {
OC_MANAGED_CRED_HMAC_SECRET: string;
}
+const DEFAULT_MAX_CONCURRENT_SANDBOXES = 50;
+
// ── small helpers ────────────────────────────────────────────────────────
function json(body: unknown, status = 200): Response {
@@ -489,7 +491,7 @@ async function enforceCreatePolicy(
// sandboxes live in S3 and don't consume worker capacity. The count spans
// every cell via the global sandboxes_index, which is the whole reason it
// must live at the edge and not on any single cell.
- const limit = org.max_concurrent_sandboxes ?? 5;
+ const limit = org.max_concurrent_sandboxes ?? DEFAULT_MAX_CONCURRENT_SANDBOXES;
const countRow = await env.OPENCOMPUTER_DB.prepare(
"SELECT COUNT(*) AS n FROM sandboxes_index WHERE org_id = ?1 AND status = 'running'",
)
@@ -1287,10 +1289,19 @@ async function authCallback(req: Request, env: Env): Promise<Response> {
}
}
await env.OPENCOMPUTER_DB.prepare(
- `INSERT INTO orgs (id, name, slug, plan, home_cell, is_personal, owner_user_id, billing_provider, created_at, updated_at)
- VALUES (?1, ?2, ?3, 'free', ?4, 1, ?5, ?7, ?6, ?6)`,
+ `INSERT INTO orgs (id, name, slug, plan, home_cell, is_personal, owner_user_id, billing_provider, max_concurrent_sandboxes, created_at, updated_at)
+ VALUES (?1, ?2, ?3, 'free', ?4, 1, ?5, ?7, ?8, ?6, ?6)`,
)
- .bind(orgID, `${profile.email}'s workspace`, slugify(profile.email + "-" + orgID.slice(0, 6)), homeCell, userID, nowSec, provider)
+ .bind(
+ orgID,
+ `${profile.email}'s workspace`,
+ slugify(profile.email + "-" + orgID.slice(0, 6)),
+ homeCell,
+ userID,
+ nowSec,
+ provider,
+ DEFAULT_MAX_CONCURRENT_SANDBOXES,
+ )
.run();
await env.OPENCOMPUTER_DB.prepare(
`INSERT INTO org_memberships (org_id, user_id, role, created_at) VALUES (?1, ?2, 'owner', ?3)`,
diff --git a/internal/db/migrations/053_default_org_concurrency_50.down.sql b/internal/db/migrations/053_default_org_concurrency_50.down.sql
new file mode 100644
index 00000000..610773de
--- /dev/null
+++ b/internal/db/migrations/053_default_org_concurrency_50.down.sql
@@ -0,0 +1 @@
+ALTER TABLE orgs ALTER COLUMN max_concurrent_sandboxes SET DEFAULT 5;
diff --git a/internal/db/migrations/053_default_org_concurrency_50.up.sql b/internal/db/migrations/053_default_org_concurrency_50.up.sql
new file mode 100644
index 00000000..dd04e8ed
--- /dev/null
+++ b/internal/db/migrations/053_default_org_concurrency_50.up.sql
@@ -0,0 +1 @@
+ALTER TABLE orgs ALTER COLUMN max_concurrent_sandboxes SET DEFAULT 50;
diff --git a/internal/db/store.go b/internal/db/store.go
index 8921a20a..b9d76732 100644
--- a/internal/db/store.go
+++ b/internal/db/store.go
@@ -200,6 +200,7 @@ func (s *Store) Migrate(ctx context.Context) error {
{50, "migrations/050_checkpoint_kind.up.sql"},
{51, "migrations/051_image_cache_is_public.up.sql"},
{52, "migrations/052_paused_hibernation_mode.up.sql"},
+ {53, "migrations/053_default_org_concurrency_50.up.sql"},
}
for _, m := range migrations {
diff --git a/web/src/pages/Billing.tsx b/web/src/pages/Billing.tsx
index 01928449..636064fe 100644
--- a/web/src/pages/Billing.tsx
+++ b/web/src/pages/Billing.tsx
@@ -119,7 +119,7 @@ function PlanTab() {
{isPro ? 'Pro' : 'Free'}
</div>
<p className="text-muted-foreground mt-1 text-sm">
- {billing?.maxConcurrentSandboxes ?? 5} concurrent sandboxes ·{' '}
+ {billing?.maxConcurrentSandboxes ?? 50} concurrent sandboxes ·{' '}
{isPro ? 'all tiers' : 'up to 4 GB / 1 vCPU'}
</p>
@@ -389,7 +389,7 @@ function PrepaidPlan() {
<p className="text-muted-foreground mb-4 text-sm">
You can run{' '}
<strong className="text-foreground">
- {autumn?.maxConcurrentSandboxes ?? 5}
+ {autumn?.maxConcurrentSandboxes ?? 50}
</strong>{' '}
sandboxes at once on the{' '}
<strong className="text-foreground">