Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/clickhouse-rate-limits

@0d57af8
Run it yourself

Configure ClickHouse query concurrency, memory quotas, and connection limits. Use when hitting "too many simultaneous queries", managing concurrent users, or tuning server-side resource limits so an app never starves the cluster. Trigger with "clickhouse rate limit", "clickhouse concurrency", "clickhouse quota", "too many simultaneous queries", "clickhouse connection limit".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/clickhouse-rate-limits

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesexamples.md

≈698 tokens on demand. Your agent reads this file only when SKILL.md points to it.

ClickHouse Rate Limits — Monitoring & Worked Examples

Concrete monitoring queries and end-to-end usage scenarios that build on the patterns in implementation.md.

Monitor Concurrency

-- Currently running queries
SELECT user, count() AS running_queries, sum(memory_usage) AS total_memory
FROM system.processes
GROUP BY user;

-- Query queue depth (if queries are waiting)
SELECT metric, value FROM system.metrics
WHERE metric IN ('Query', 'MaxConcurrentQueries', 'TCPConnection', 'HTTPConnection');

-- Historical peak concurrency
SELECT
    toStartOfMinute(event_time) AS minute,
    max(ProfileEvents['ConcurrentQuery']) AS peak_concurrent
FROM system.query_log
WHERE event_time >= now() - INTERVAL 1 HOUR
GROUP BY minute
ORDER BY minute;

Example 1: Cap a Reporting Service at 5 Concurrent Queries

A dashboard backend fans out many queries when a user loads a page. Wrap every query in the p-queue limiter so the app never exceeds 5 in-flight queries, regardless of how many dashboard tiles render at once.

// Every tile calls this — the queue serializes beyond concurrency: 5
const rows = await rateLimitedQuery<{ ts: string; value: number }>(
  `SELECT toStartOfHour(event_time) AS ts, count() AS value
   FROM events WHERE event_time >= now() - INTERVAL 24 HOUR
   GROUP BY ts ORDER BY ts`,
);

Pair this with a server-side max_concurrent_queries_for_user = 10 so a misbehaving client still cannot starve other users.

Example 2: Survive a Concurrency Spike with Retry + Backoff

During a traffic burst the server returns TOO_MANY_SIMULTANEOUS_QUERIES (code 202). queryWithRetry retries with exponential backoff + jitter, so transient spikes self-heal instead of surfacing as user-facing 500s.

const result = await queryWithRetry<{ id: string }>(
  `SELECT id FROM orders WHERE status = 'pending' LIMIT 100`,
);
// Retries up to 3 times on 202 / TIMEOUT_EXCEEDED / NETWORK_ERROR,
// then rethrows so the caller can fail cleanly.

Example 3: High-Throughput Ingest Without "Too Many Parts"

A firehose of events would create one part per insert and trip TOO_MANY_PARTS (code 252). InsertBuffer batches rows and flushes every 10,000 rows or 5 seconds, turning thousands of tiny inserts into a few large ones.

const buffer = new InsertBuffer(client, 'events', 10_000, 5_000);
for await (const event of eventStream) {
  await buffer.add(event);   // auto-flushes on size or interval
}
await buffer.flush();        // drain the tail on shutdown

Verify Your Limits Are Applied

After creating a quota and profile, confirm they bind to the user:

SHOW QUOTAS;
SHOW CREATE QUOTA app_quota;
SELECT * FROM system.quota_usage WHERE quota_name = 'app_quota';

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides legitimate guidance and code templates for managing ClickHouse resource limits, quotas, and application-level concurrency. It follows security best practices for credential handling and uses reputable libraries.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 months ago
What it can do
Reads files Edits files
version
1.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "database",
  "analytics",
  "clickhouse",
  "olap"
]
All 3 allowed tools
ReadWriteEdit
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/clickhouse-rate-limits