Examples & benchmarks / #92 · 2026-11-27 · Example · Easy · for web scraping
When the fleet is full: 503 capacity_full and Retry-After, vs your own 429 thread cap
Three plans launch while the shared fleet is full. A shared plan gets `503 shared_capacity_full` with `Retry-After: 5` and waits as told; a Community launch is refused the same way; a dedicated plan keeps launching until its own 10 threads are used, and only then gets `429 threads_exceeded` with `Retry-After: 1`. Two different limits, two different fixes, in five languages.
Run on production on 2026-11-27: ✓ Node.js ✓ Python ✓ Java ✓ C# ✓ Go
The problem
A launch can be refused for two different reasons, and they need different handling. Your plan has a thread cap: hit it and the answer is 429 threads_exceeded, which only clears when one of your own sessions ends. Shared and Community plans also run on a shared fleet: when it is full the answer is 503 with shared_capacity_full or community_capacity_full, which clears on its own as capacity frees up. To show the 503 for real, the shared fleet's capacity was set to 3 threads for about 5 minutes on 2026-11-27 and filled, and these programs ran inside that window.
What we used, and why
| What | Why |
|---|---|
POST https://starter.cdpfleet.com/chromium/session | The launch request. The programs only read the answer (status, error, the Retry-After header and in_use); nobody connects, so each launched session is ended at once. |
| Three accounts | A shared plan (with your own proxy), the free Community plan (on the Community proxy) and a dedicated plan with 10 threads. |
A retry that follows Retry-After | On a 503 …_capacity_full wait the number of seconds in Retry-After, then try again; give up after 4 tries. |
DELETE /v1/me/threads/:id | Ends a launched session and frees its thread; each program checks that nothing is left running. |
How it works
- Shared plan: launch; on
503waitRetry-Afterseconds and launch again, at most 4 tries; record each answer and when it came. - Community plan: launch once on the Community proxy and record the answer.
- Dedicated plan: launch until all 10 of its threads are in use, then launch one more and record the answer.
- End every session and count the threads left running on each account.
The code
The same program in five languages (also on GitHub, with the raw output). Set these environment variables first:
CDPFLEET_API_KEY— your API key (dashboard → API keys)COMMUNITY_API_KEY— an API key of an account on the free Community plan (dashboard → API keys); its launches use the plan's included proxyCDPFLEET_DEDICATED_API_KEY— an API key of an account with dedicated threads (dashboard → API keys)PROXY_URL— your proxy, e.g.http://user:[email protected]:8000
// Node 20+ (fetch), no packages needed.
// env: CDPFLEET_API_KEY (a shared plan), COMMUNITY_API_KEY (the free Community plan),
// CDPFLEET_DEDICATED_API_KEY (a dedicated plan), PROXY_URL
const STARTER = 'https://starter.cdpfleet.com';
const API = 'https://cdpfleet.com';
const PROXY = process.env.PROXY_URL;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const t0 = Date.now();
const at = () => Math.round((Date.now() - t0) / 100) / 10;
// One launch request; the answer is all we look at (nobody connects, so the session is ended right after).
async function launch(key, body) {
const res = await fetch(`${STARTER}/chromium/session`, {
method: 'POST',
headers: { 'x-api-key': key, 'content-type': 'application/json' },
body: JSON.stringify({ headless: true, record: false, ...body }),
});
const j = await res.json().catch(() => ({}));
return { status: res.status, error: j.error ?? null, retry_after: res.headers.get('retry-after'), in_use: j.in_use ?? null, session_id: j.sessionId ?? null };
}
const end = (key, id) => fetch(`${API}/v1/me/threads/${id}`, { method: 'DELETE', headers: { 'x-api-key': key } });
const threadsLeft = async (key) => (await (await fetch(`${API}/v1/me/threads`, { headers: { 'x-api-key': key } })).json()).threads.length;
// What a client should do with each answer.
function meaning(r) {
if (r.status === 200) return 'launched';
if (r.status === 503 && /capacity_full$/.test(r.error)) return 'the fleet is full: wait Retry-After and try again';
if (r.status === 429 && r.error === 'threads_exceeded') return 'your own plan is at its thread cap: end a session or wait for one';
if (r.status === 429 && r.error === 'rate_limited') return 'too many launches a second: slow down';
return 'other';
}
// 1. A shared plan: launch, and on a full fleet wait as Retry-After says, at most 4 tries.
async function sharedPlan() {
const key = process.env.CDPFLEET_API_KEY;
const attempts = [];
for (let i = 0; i < 4; i++) {
const r = await launch(key, { proxy: PROXY });
attempts.push({ at_s: at(), status: r.status, error: r.error, retry_after: r.retry_after, meaning: meaning(r) });
if (r.status === 200) { await end(key, r.session_id); break; }
if (!(r.status === 503 && r.retry_after)) break;
if (i < 3) await sleep(Number(r.retry_after) * 1000);
}
return { attempts, got_session: attempts.at(-1).status === 200, threads_left: await threadsLeft(key) };
}
// 2. The free Community plan, on the Community proxy (no proxy given): one launch.
async function communityPlan() {
const key = process.env.COMMUNITY_API_KEY;
const r = await launch(key, {});
if (r.status === 200) await end(key, r.session_id);
return { status: r.status, error: r.error, retry_after: r.retry_after, meaning: meaning(r), threads_left: await threadsLeft(key) };
}
// 3. A dedicated plan: fill its own threads, then ask for one more.
async function dedicatedPlan() {
const key = process.env.CDPFLEET_DEDICATED_API_KEY;
const threads = (await (await fetch(`${API}/v1/me`, { headers: { 'x-api-key': key } })).json()).subscription.threads;
const held = [];
try {
while (held.length < threads) {
const r = await launch(key, { proxy: PROXY });
if (r.status === 200) held.push(r.session_id);
else if (r.status === 429 && r.error === 'rate_limited') await sleep(Number(r.retry_after || 1) * 1000);
else throw new Error(`hold ${r.status} ${r.error}`);
await sleep(300);
}
const over = await launch(key, { proxy: PROXY });
if (over.status === 200) held.push(over.session_id);
return { threads, held: Math.min(held.length, threads), over_cap: { status: over.status, error: over.error, retry_after: over.retry_after, in_use: over.in_use, meaning: meaning(over) } };
} finally {
for (const id of held) await end(key, id);
}
}
const out = { language: 'node' };
out.shared = await sharedPlan();
out.community = await communityPlan();
out.dedicated = await dedicatedPlan();
await sleep(3000);
out.dedicated.threads_left = await threadsLeft(process.env.CDPFLEET_DEDICATED_API_KEY);
out.measured_at = new Date().toISOString().slice(0, 10);
console.log(JSON.stringify(out, null, 2));
# pip install requests
# env: CDPFLEET_API_KEY (a shared plan), COMMUNITY_API_KEY (the free Community plan),
# CDPFLEET_DEDICATED_API_KEY (a dedicated plan), PROXY_URL
import json
import os
import re
import time
from datetime import date
import requests
STARTER = "https://starter.cdpfleet.com"
API = "https://cdpfleet.com"
PROXY = os.environ["PROXY_URL"]
T0 = time.time()
def at():
return round(time.time() - T0, 1)
# One launch request; the answer is all we look at (nobody connects, so the session is ended right after).
def launch(key, body):
r = requests.post(f"{STARTER}/chromium/session", headers={"x-api-key": key},
json={"headless": True, "record": False, **body}, timeout=60)
try:
j = r.json()
except ValueError:
j = {}
return {"status": r.status_code, "error": j.get("error"), "retry_after": r.headers.get("retry-after"),
"in_use": j.get("in_use"), "session_id": j.get("sessionId")}
def end(key, sid):
requests.delete(f"{API}/v1/me/threads/{sid}", headers={"x-api-key": key}, timeout=30)
def threads_left(key):
return len(requests.get(f"{API}/v1/me/threads", headers={"x-api-key": key}, timeout=30).json()["threads"])
# What a client should do with each answer.
def meaning(r):
if r["status"] == 200:
return "launched"
if r["status"] == 503 and re.search(r"capacity_full$", r["error"] or ""):
return "the fleet is full: wait Retry-After and try again"
if r["status"] == 429 and r["error"] == "threads_exceeded":
return "your own plan is at its thread cap: end a session or wait for one"
if r["status"] == 429 and r["error"] == "rate_limited":
return "too many launches a second: slow down"
return "other"
# 1. A shared plan: launch, and on a full fleet wait as Retry-After says, at most 4 tries.
def shared_plan():
key = os.environ["CDPFLEET_API_KEY"]
attempts = []
for i in range(4):
r = launch(key, {"proxy": PROXY})
attempts.append({"at_s": at(), "status": r["status"], "error": r["error"], "retry_after": r["retry_after"], "meaning": meaning(r)})
if r["status"] == 200:
end(key, r["session_id"])
break
if not (r["status"] == 503 and r["retry_after"]):
break
if i < 3:
time.sleep(float(r["retry_after"]))
return {"attempts": attempts, "got_session": attempts[-1]["status"] == 200, "threads_left": threads_left(key)}
# 2. The free Community plan, on the Community proxy (no proxy given): one launch.
def community_plan():
key = os.environ["COMMUNITY_API_KEY"]
r = launch(key, {})
if r["status"] == 200:
end(key, r["session_id"])
return {"status": r["status"], "error": r["error"], "retry_after": r["retry_after"], "meaning": meaning(r), "threads_left": threads_left(key)}
# 3. A dedicated plan: fill its own threads, then ask for one more.
def dedicated_plan():
key = os.environ["CDPFLEET_DEDICATED_API_KEY"]
threads = requests.get(f"{API}/v1/me", headers={"x-api-key": key}, timeout=30).json()["subscription"]["threads"]
held = []
try:
while len(held) < threads:
r = launch(key, {"proxy": PROXY})
if r["status"] == 200:
held.append(r["session_id"])
elif r["status"] == 429 and r["error"] == "rate_limited":
time.sleep(float(r["retry_after"] or 1))
else:
raise RuntimeError(f"hold {r['status']} {r['error']}")
time.sleep(0.3)
over = launch(key, {"proxy": PROXY})
if over["status"] == 200:
held.append(over["session_id"])
return {"threads": threads, "held": min(len(held), threads),
"over_cap": {"status": over["status"], "error": over["error"], "retry_after": over["retry_after"], "in_use": over["in_use"], "meaning": meaning(over)}}
finally:
for sid in held:
end(key, sid)
out = {"language": "python"}
out["shared"] = shared_plan()
out["community"] = community_plan()
out["dedicated"] = dedicated_plan()
time.sleep(3)
out["dedicated"]["threads_left"] = threads_left(os.environ["CDPFLEET_DEDICATED_API_KEY"])
out["measured_at"] = date.today().isoformat()
print(json.dumps(out, indent=2))
// Maven: com.google.code.gson:gson:2.11.0 (and Java 21's HttpClient)
// env: CDPFLEET_API_KEY (a shared plan), COMMUNITY_API_KEY (the free Community plan),
// CDPFLEET_DEDICATED_API_KEY (a dedicated plan), PROXY_URL
import com.google.gson.*;
import java.net.URI;
import java.net.http.*;
import java.time.LocalDate;
import java.util.*;
public class Main {
static final String STARTER = "https://starter.cdpfleet.com";
static final String API = "https://cdpfleet.com";
static final String PROXY = System.getenv("PROXY_URL");
static final HttpClient HTTP = HttpClient.newHttpClient();
static final Gson GSON = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();
static final long T0 = System.currentTimeMillis();
static double at() { return Math.round((System.currentTimeMillis() - T0) / 100.0) / 10.0; }
// One launch request; the answer is all we look at (nobody connects, so the session is ended right after).
static JsonObject launch(String key, boolean withProxy) throws Exception {
JsonObject body = new JsonObject();
body.addProperty("headless", true);
body.addProperty("record", false);
if (withProxy) body.addProperty("proxy", PROXY);
HttpResponse<String> res = HTTP.send(HttpRequest.newBuilder(URI.create(STARTER + "/chromium/session"))
.header("x-api-key", key).header("content-type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body.toString())).build(), HttpResponse.BodyHandlers.ofString());
JsonObject j;
try { j = JsonParser.parseString(res.body()).getAsJsonObject(); } catch (Exception e) { j = new JsonObject(); }
JsonObject a = new JsonObject();
a.addProperty("status", res.statusCode());
a.add("error", j.has("error") ? j.get("error") : JsonNull.INSTANCE);
a.addProperty("retry_after", res.headers().firstValue("retry-after").orElse(null));
a.add("in_use", j.has("in_use") ? j.get("in_use") : JsonNull.INSTANCE);
a.add("session_id", j.has("sessionId") ? j.get("sessionId") : JsonNull.INSTANCE);
return a;
}
static HttpResponse<String> call(String method, String key, String path) throws Exception {
return HTTP.send(HttpRequest.newBuilder(URI.create(API + path)).header("x-api-key", key)
.method(method, HttpRequest.BodyPublishers.noBody()).build(), HttpResponse.BodyHandlers.ofString());
}
static void end(String key, String id) throws Exception { call("DELETE", key, "/v1/me/threads/" + id); }
static int threadsLeft(String key) throws Exception {
return JsonParser.parseString(call("GET", key, "/v1/me/threads").body()).getAsJsonObject().getAsJsonArray("threads").size();
}
static String str(JsonObject a, String k) { return a.get(k).isJsonNull() ? "" : a.get(k).getAsString(); }
// What a client should do with each answer.
static String meaning(JsonObject a) {
int s = a.get("status").getAsInt();
String e = str(a, "error");
if (s == 200) return "launched";
if (s == 503 && e.endsWith("capacity_full")) return "the fleet is full: wait Retry-After and try again";
if (s == 429 && e.equals("threads_exceeded")) return "your own plan is at its thread cap: end a session or wait for one";
if (s == 429 && e.equals("rate_limited")) return "too many launches a second: slow down";
return "other";
}
static JsonObject describe(JsonObject a) {
JsonObject d = new JsonObject();
d.add("status", a.get("status"));
d.add("error", a.get("error"));
d.add("retry_after", a.get("retry_after"));
d.addProperty("meaning", meaning(a));
return d;
}
// 1. A shared plan: launch, and on a full fleet wait as Retry-After says, at most 4 tries.
static JsonObject sharedPlan() throws Exception {
String key = System.getenv("CDPFLEET_API_KEY");
JsonArray attempts = new JsonArray();
JsonObject last = null;
for (int i = 0; i < 4; i++) {
last = launch(key, true);
JsonObject d = describe(last);
d.addProperty("at_s", at());
attempts.add(d);
if (last.get("status").getAsInt() == 200) { end(key, str(last, "session_id")); break; }
if (!(last.get("status").getAsInt() == 503 && !str(last, "retry_after").isEmpty())) break;
if (i < 3) Thread.sleep((long) (Double.parseDouble(str(last, "retry_after")) * 1000));
}
JsonObject out = new JsonObject();
out.add("attempts", attempts);
out.addProperty("got_session", last.get("status").getAsInt() == 200);
out.addProperty("threads_left", threadsLeft(key));
return out;
}
// 2. The free Community plan, on the Community proxy (no proxy given): one launch.
static JsonObject communityPlan() throws Exception {
String key = System.getenv("COMMUNITY_API_KEY");
JsonObject a = launch(key, false);
if (a.get("status").getAsInt() == 200) end(key, str(a, "session_id"));
JsonObject d = describe(a);
d.addProperty("threads_left", threadsLeft(key));
return d;
}
// 3. A dedicated plan: fill its own threads, then ask for one more.
static JsonObject dedicatedPlan() throws Exception {
String key = System.getenv("CDPFLEET_DEDICATED_API_KEY");
int threads = JsonParser.parseString(call("GET", key, "/v1/me").body()).getAsJsonObject()
.getAsJsonObject("subscription").get("threads").getAsInt();
List<String> held = new ArrayList<>();
try {
while (held.size() < threads) {
JsonObject a = launch(key, true);
int s = a.get("status").getAsInt();
if (s == 200) held.add(str(a, "session_id"));
else if (s == 429 && str(a, "error").equals("rate_limited")) Thread.sleep((long) (Double.parseDouble(str(a, "retry_after").isEmpty() ? "1" : str(a, "retry_after")) * 1000));
else throw new RuntimeException("hold " + s + " " + str(a, "error"));
Thread.sleep(300);
}
JsonObject over = launch(key, true);
if (over.get("status").getAsInt() == 200) held.add(str(over, "session_id"));
JsonObject d = describe(over);
d.add("in_use", over.get("in_use"));
JsonObject out = new JsonObject();
out.addProperty("threads", threads);
out.addProperty("held", Math.min(held.size(), threads));
out.add("over_cap", d);
return out;
} finally {
for (String id : held) end(key, id);
}
}
public static void main(String[] args) throws Exception {
JsonObject out = new JsonObject();
out.addProperty("language", "java");
out.add("shared", sharedPlan());
out.add("community", communityPlan());
JsonObject ded = dedicatedPlan();
Thread.sleep(3000);
ded.addProperty("threads_left", threadsLeft(System.getenv("CDPFLEET_DEDICATED_API_KEY")));
out.add("dedicated", ded);
out.addProperty("measured_at", LocalDate.now().toString());
System.out.println(GSON.toJson(out));
}
}
// .NET 8+, no packages needed.
// env: CDPFLEET_API_KEY (a shared plan), COMMUNITY_API_KEY (the free Community plan),
// CDPFLEET_DEDICATED_API_KEY (a dedicated plan), PROXY_URL
using System.Diagnostics;
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Nodes;
const string Starter = "https://starter.cdpfleet.com";
const string Api = "https://cdpfleet.com";
var proxy = Environment.GetEnvironmentVariable("PROXY_URL")!;
var http = new HttpClient();
var clock = Stopwatch.StartNew();
double At() => Math.Round(clock.Elapsed.TotalSeconds, 1);
// One launch request; the answer is all we look at (nobody connects, so the session is ended right after).
async Task<JsonObject> Launch(string key, bool withProxy)
{
var body = new JsonObject { ["headless"] = true, ["record"] = false };
if (withProxy) body["proxy"] = proxy;
using var req = new HttpRequestMessage(HttpMethod.Post, $"{Starter}/chromium/session") { Content = JsonContent.Create(body) };
req.Headers.Add("x-api-key", key);
using var res = await http.SendAsync(req);
JsonNode? j = null;
try { j = JsonNode.Parse(await res.Content.ReadAsStringAsync()); } catch (JsonException) { }
return new JsonObject
{
["status"] = (int)res.StatusCode,
["error"] = j?["error"]?.GetValue<string>(),
["retry_after"] = res.Headers.TryGetValues("retry-after", out var ra) ? ra.First() : null,
["in_use"] = j?["in_use"]?.GetValue<int>(),
["session_id"] = j?["sessionId"]?.GetValue<string>(),
};
}
async Task<HttpResponseMessage> Call(HttpMethod method, string key, string path)
{
var req = new HttpRequestMessage(method, $"{Api}{path}");
req.Headers.Add("x-api-key", key);
return await http.SendAsync(req);
}
async Task End(string key, string id) => (await Call(HttpMethod.Delete, key, $"/v1/me/threads/{id}")).Dispose();
async Task<int> ThreadsLeft(string key) =>
JsonNode.Parse(await (await Call(HttpMethod.Get, key, "/v1/me/threads")).Content.ReadAsStringAsync())!["threads"]!.AsArray().Count;
string Str(JsonObject a, string k) => a[k]?.GetValue<string>() ?? "";
int Status(JsonObject a) => a["status"]!.GetValue<int>();
// What a client should do with each answer.
string Meaning(JsonObject a) => (Status(a), Str(a, "error")) switch
{
(200, _) => "launched",
(503, var e) when e.EndsWith("capacity_full") => "the fleet is full: wait Retry-After and try again",
(429, "threads_exceeded") => "your own plan is at its thread cap: end a session or wait for one",
(429, "rate_limited") => "too many launches a second: slow down",
_ => "other",
};
JsonObject Describe(JsonObject a) => new()
{
["status"] = Status(a), ["error"] = a["error"]?.DeepClone(), ["retry_after"] = a["retry_after"]?.DeepClone(), ["meaning"] = Meaning(a),
};
// 1. A shared plan: launch, and on a full fleet wait as Retry-After says, at most 4 tries.
async Task<JsonObject> SharedPlan()
{
var key = Environment.GetEnvironmentVariable("CDPFLEET_API_KEY")!;
var attempts = new JsonArray();
JsonObject last = null!;
for (var i = 0; i < 4; i++)
{
last = await Launch(key, true);
var d = Describe(last);
d["at_s"] = At();
attempts.Add(d);
if (Status(last) == 200) { await End(key, Str(last, "session_id")); break; }
if (!(Status(last) == 503 && Str(last, "retry_after") != "")) break;
if (i < 3) await Task.Delay(TimeSpan.FromSeconds(double.Parse(Str(last, "retry_after"))));
}
return new JsonObject { ["attempts"] = attempts, ["got_session"] = Status(last) == 200, ["threads_left"] = await ThreadsLeft(key) };
}
// 2. The free Community plan, on the Community proxy (no proxy given): one launch.
async Task<JsonObject> CommunityPlan()
{
var key = Environment.GetEnvironmentVariable("COMMUNITY_API_KEY")!;
var a = await Launch(key, false);
if (Status(a) == 200) await End(key, Str(a, "session_id"));
var d = Describe(a);
d["threads_left"] = await ThreadsLeft(key);
return d;
}
// 3. A dedicated plan: fill its own threads, then ask for one more.
async Task<JsonObject> DedicatedPlan()
{
var key = Environment.GetEnvironmentVariable("CDPFLEET_DEDICATED_API_KEY")!;
var me = JsonNode.Parse(await (await Call(HttpMethod.Get, key, "/v1/me")).Content.ReadAsStringAsync())!;
var threads = me["subscription"]!["threads"]!.GetValue<int>();
var held = new List<string>();
try
{
while (held.Count < threads)
{
var a = await Launch(key, true);
if (Status(a) == 200) held.Add(Str(a, "session_id"));
else if (Status(a) == 429 && Str(a, "error") == "rate_limited") await Task.Delay(TimeSpan.FromSeconds(double.TryParse(Str(a, "retry_after"), out var s) ? s : 1));
else throw new Exception($"hold {Status(a)} {Str(a, "error")}");
await Task.Delay(300);
}
var over = await Launch(key, true);
if (Status(over) == 200) held.Add(Str(over, "session_id"));
var d = Describe(over);
d["in_use"] = over["in_use"]?.DeepClone();
return new JsonObject { ["threads"] = threads, ["held"] = Math.Min(held.Count, threads), ["over_cap"] = d };
}
finally
{
foreach (var id in held) await End(key, id);
}
}
var output = new JsonObject { ["language"] = "csharp" };
output["shared"] = await SharedPlan();
output["community"] = await CommunityPlan();
var ded = await DedicatedPlan();
await Task.Delay(3000);
ded["threads_left"] = await ThreadsLeft(Environment.GetEnvironmentVariable("CDPFLEET_DEDICATED_API_KEY")!);
output["dedicated"] = ded;
output["measured_at"] = DateTime.UtcNow.ToString("yyyy-MM-dd");
Console.WriteLine(output.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
// Go 1.22, standard library only.
// env: CDPFLEET_API_KEY (a shared plan), COMMUNITY_API_KEY (the free Community plan),
// CDPFLEET_DEDICATED_API_KEY (a dedicated plan), PROXY_URL
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"math"
"net/http"
"os"
"strconv"
"strings"
"time"
)
const starter = "https://starter.cdpfleet.com"
const api = "https://cdpfleet.com"
var proxy = os.Getenv("PROXY_URL")
var t0 = time.Now()
func at() float64 { return math.Round(time.Since(t0).Seconds()*10) / 10 }
type answer struct {
Status int `json:"status"`
Error *string `json:"error"`
RetryAfter *string `json:"retry_after"`
InUse *int `json:"in_use,omitempty"`
SessionID string `json:"-"`
}
// One launch request; the answer is all we look at (nobody connects, so the session is ended right after).
func launch(key string, body map[string]any) answer {
body["headless"], body["record"] = true, false
b, _ := json.Marshal(body)
req, _ := http.NewRequest("POST", starter+"/chromium/session", bytes.NewReader(b))
req.Header.Set("x-api-key", key)
req.Header.Set("content-type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var j struct {
Error *string `json:"error"`
InUse *int `json:"in_use"`
SessionID string `json:"sessionId"`
}
json.NewDecoder(res.Body).Decode(&j)
a := answer{Status: res.StatusCode, Error: j.Error, InUse: j.InUse, SessionID: j.SessionID}
if ra := res.Header.Get("retry-after"); ra != "" {
a.RetryAfter = &ra
}
return a
}
func call(method, key, path string) *http.Response {
req, _ := http.NewRequest(method, api+path, nil)
req.Header.Set("x-api-key", key)
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
return res
}
func end(key, id string) { call("DELETE", key, "/v1/me/threads/"+id).Body.Close() }
func threadsLeft(key string) int {
res := call("GET", key, "/v1/me/threads")
defer res.Body.Close()
var j struct{ Threads []any }
json.NewDecoder(res.Body).Decode(&j)
return len(j.Threads)
}
func str(p *string) string {
if p == nil {
return ""
}
return *p
}
// What a client should do with each answer.
func meaning(a answer) string {
switch {
case a.Status == 200:
return "launched"
case a.Status == 503 && strings.HasSuffix(str(a.Error), "capacity_full"):
return "the fleet is full: wait Retry-After and try again"
case a.Status == 429 && str(a.Error) == "threads_exceeded":
return "your own plan is at its thread cap: end a session or wait for one"
case a.Status == 429 && str(a.Error) == "rate_limited":
return "too many launches a second: slow down"
}
return "other"
}
func seconds(p *string) time.Duration {
n, err := strconv.ParseFloat(str(p), 64)
if err != nil || n <= 0 {
n = 1
}
return time.Duration(n * float64(time.Second))
}
func describe(a answer) map[string]any {
return map[string]any{"status": a.Status, "error": a.Error, "retry_after": a.RetryAfter, "meaning": meaning(a)}
}
// 1. A shared plan: launch, and on a full fleet wait as Retry-After says, at most 4 tries.
func sharedPlan() map[string]any {
key := os.Getenv("CDPFLEET_API_KEY")
attempts := []map[string]any{}
var last answer
for i := 0; i < 4; i++ {
last = launch(key, map[string]any{"proxy": proxy})
d := describe(last)
d["at_s"] = at()
attempts = append(attempts, d)
if last.Status == 200 {
end(key, last.SessionID)
break
}
if !(last.Status == 503 && last.RetryAfter != nil) {
break
}
if i < 3 {
time.Sleep(seconds(last.RetryAfter))
}
}
return map[string]any{"attempts": attempts, "got_session": last.Status == 200, "threads_left": threadsLeft(key)}
}
// 2. The free Community plan, on the Community proxy (no proxy given): one launch.
func communityPlan() map[string]any {
key := os.Getenv("COMMUNITY_API_KEY")
a := launch(key, map[string]any{})
if a.Status == 200 {
end(key, a.SessionID)
}
d := describe(a)
d["threads_left"] = threadsLeft(key)
return d
}
// 3. A dedicated plan: fill its own threads, then ask for one more.
func dedicatedPlan() map[string]any {
key := os.Getenv("CDPFLEET_DEDICATED_API_KEY")
res := call("GET", key, "/v1/me")
var me struct{ Subscription struct{ Threads int } }
json.NewDecoder(res.Body).Decode(&me)
res.Body.Close()
threads := me.Subscription.Threads
held := []string{}
defer func() {
for _, id := range held {
end(key, id)
}
}()
for len(held) < threads {
a := launch(key, map[string]any{"proxy": proxy})
switch {
case a.Status == 200:
held = append(held, a.SessionID)
case a.Status == 429 && str(a.Error) == "rate_limited":
time.Sleep(seconds(a.RetryAfter))
default:
panic(fmt.Sprintf("hold %d %s", a.Status, str(a.Error)))
}
time.Sleep(300 * time.Millisecond)
}
over := launch(key, map[string]any{"proxy": proxy})
if over.Status == 200 {
held = append(held, over.SessionID)
}
d := describe(over)
d["in_use"] = over.InUse
return map[string]any{"threads": threads, "held": min(len(held), threads), "over_cap": d}
}
func main() {
out := map[string]any{"language": "go"}
out["shared"] = sharedPlan()
out["community"] = communityPlan()
ded := dedicatedPlan()
time.Sleep(3 * time.Second)
ded["threads_left"] = threadsLeft(os.Getenv("CDPFLEET_DEDICATED_API_KEY"))
out["dedicated"] = ded
out["measured_at"] = time.Now().UTC().Format("2006-01-02")
b, _ := json.MarshalIndent(out, "", " ")
fmt.Println(string(b))
}
What we got
| Language | Shared plan (4 tries, waiting Retry-After) | Community plan | Dedicated plan, 11th launch | Measured |
|---|---|---|---|---|
| node | 0.1 s: 503 shared_capacity_full, Retry-After 5 s · 5.2 s: 503 shared_capacity_full, Retry-After 5 s · 10.3 s: 503 shared_capacity_full, Retry-After 5 s · 15.4 s: 503 shared_capacity_full, Retry-After 5 s | 503 shared_capacity_full, Retry-After 5 s | 10/10 launched, then 429 threads_exceeded, Retry-After 1 s, in_use 10 | 2026-11-27 |
From the Node.js run on 2026-11-27. IP addresses are replaced with placeholders (203.0.113.x); equal addresses stay equal. The other languages produced the same findings.
Raw output (Node.js)
{
"language": "node",
"shared": {
"attempts": [
{
"at_s": 0.1,
"status": 503,
"error": "shared_capacity_full",
"retry_after": "5",
"meaning": "the fleet is full: wait Retry-After and try again"
},
{
"at_s": 5.2,
"status": 503,
"error": "shared_capacity_full",
"retry_after": "5",
"meaning": "the fleet is full: wait Retry-After and try again"
},
{
"at_s": 10.3,
"status": 503,
"error": "shared_capacity_full",
"retry_after": "5",
"meaning": "the fleet is full: wait Retry-After and try again"
},
{
"at_s": 15.4,
"status": 503,
"error": "shared_capacity_full",
"retry_after": "5",
"meaning": "the fleet is full: wait Retry-After and try again"
}
],
"got_session": false,
"threads_left": 0
},
"community": {
"status": 503,
"error": "shared_capacity_full",
"retry_after": "5",
"meaning": "the fleet is full: wait Retry-After and try again",
"threads_left": 0
},
"dedicated": {
"threads": 10,
"held": 10,
"over_cap": {
"status": 429,
"error": "threads_exceeded",
"retry_after": "1",
"in_use": 10,
"meaning": "your own plan is at its thread cap: end a session or wait for one"
},
"threads_left": 0
},
"measured_at": "2026-11-27"
}Takeaways
- A full shared fleet answers
503 shared_capacity_fullwithRetry-After: 5, and keeps answering it while it stays full. In all five languages the shared plan's four launches, 5.0–5.1 s apart asRetry-Afterasked, were refused the same way. The fleet was held full for the whole window, so the program gave up after about 15 s, as written. With real capacity a slot comes back as shared sessions end. If the fleet stays full and shared launches are waiting, the longest-running shared session is not renewed at its next 15-minute lease mark (sessions and billing). In our own lease test on 2026-11-15 a launch refused this way got its slot 48 s into its retries, at that mark. That wait didn't fit in this case's 5-minute window, so it isn't reproduced here. - A Community launch got the shared refusal too:
503 shared_capacity_full,Retry-After: 5. Community sessions also run on the shared fleet, so when that is full they are refused by the same check.503 community_capacity_fullwithRetry-After: 30is the other "full": the Community plan's own capacity, shared by all Community users, being used up. It was not reproduced live: that would have meant filling the Community capacity as well, and it was left alone. The code and the meaning are in /docs/errors. - A dedicated plan was not refused by the full fleet; it ran into its own cap instead. All 10 of its launches succeeded while shared launches were being turned away, and the 11th got
429 threads_exceededwithRetry-After: 1andin_use: 10. That is the same answer case 76 got on a Community account at its 2 threads (the SDK vs plain Playwright). - So handle them differently. A
503 …_capacity_fullis about the fleet: waitRetry-Afterand try again, and keep trying for a while. A429 threads_exceededis about your own plan: it clears only when one of your sessions ends, so free a thread (DELETE /v1/me/threads/:id) or queue the work, and a tight retry loop gains nothing. A429 rate_limitedis a third case: too many launches a second, so slow down. The SDKs wait asRetry-Aftersays on all of these except the daily and hourly quotas, for up to 120 s by default. - Nothing was left running. Every program ended the sessions it launched, and each account had 0 threads in use at the end.