replit-rate-limits
Implement Replit rate limiting, backoff, and idempotency patterns. Use when handling rate limit errors, implementing retry logic, or optimizing API request throughput for Replit. Trigger with phrases like "replit rate limit", "replit throttling", "replit 429", "replit retry", "replit backoff".
Install
mkdir -p .claude/skills/replit-rate-limits && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5430" && unzip -o skill.zip -d .claude/skills/replit-rate-limits && rm skill.zipInstalls to .claude/skills/replit-rate-limits
About this skill
Replit Rate Limits
Overview
Understand and work within Replit's resource limits: Key-Value Database size caps, Object Storage quotas, deployment compute budgets, and egress allowances. Implement rate limiting in your own app for production safety.
Prerequisites
- Replit account with active Repls
- Understanding of your current resource usage
- For rate limiting: Express or Flask app
Replit Platform Limits
Key-Value Database
| Limit | Value |
|---|---|
| Total storage | 50 MiB (keys + values combined) |
| Maximum keys | 5,000 |
| Key size | 1,000 bytes |
| Value size | 5 MiB per value |
Object Storage (App Storage)
| Limit | Value |
|---|---|
| Object size | Configurable per bucket |
| Bucket count | Per Repl (auto-provisioned) |
| Rate | Throttled at high request volume |
PostgreSQL
| Limit | Value |
|---|---|
| Storage | Plan-dependent (1-10+ GB) |
| Connections | Pooled, plan-dependent |
| Dev + Prod | Separate databases auto-provisioned |
Deployments
| Resource | Autoscale | Reserved VM |
|---|---|---|
| Scale behavior | 0 to N based on traffic | Always-on, fixed size |
| Min cost | Pay per request | $0.20/day (~$6.20/month) |
| Max resources | Plan-dependent | Up to 4 vCPU, 16 GiB RAM |
| Egress | $0.10/GiB over allowance | $0.10/GiB over allowance |
Instructions
Step 1: Monitor KV Database Usage
// Check how close you are to KV limits
import Database from '@replit/database';
async function checkKVUsage() {
const db = new Database();
const keys = await db.list();
let totalSize = 0;
for (const key of keys) {
const value = await db.get(key);
const valueSize = JSON.stringify(value).length;
totalSize += key.length + valueSize;
}
const limitMiB = 50;
const usedMiB = totalSize / (1024 * 1024);
const percentUsed = (usedMiB / limitMiB * 100).toFixed(1);
console.log(`KV Usage: ${usedMiB.toFixed(2)} MiB / ${limitMiB} MiB (${percentUsed}%)`);
console.log(`Keys: ${keys.length} / 5,000`);
if (parseFloat(percentUsed) > 80) {
console.warn('WARNING: KV database above 80%. Consider migrating large values to Object Storage.');
}
}
Step 2: Implement App-Level Rate Limiting
// src/middleware/rate-limit.ts — protect your Replit-hosted API
import { Request, Response, NextFunction } from 'express';
interface RateLimitEntry {
count: number;
resetAt: number;
}
const store = new Map<string, RateLimitEntry>();
export function rateLimit(opts = { windowMs: 60000, max: 100 }) {
return (req: Request, res: Response, next: NextFunction) => {
const key = req.headers['x-replit-user-id'] as string || req.ip;
const now = Date.now();
const entry = store.get(key);
if (!entry || now > entry.resetAt) {
store.set(key, { count: 1, resetAt: now + opts.windowMs });
setRateLimitHeaders(res, opts.max, opts.max - 1, now + opts.windowMs);
return next();
}
entry.count++;
const remaining = Math.max(0, opts.max - entry.count);
setRateLimitHeaders(res, opts.max, remaining, entry.resetAt);
if (entry.count > opts.max) {
const retryAfter = Math.ceil((entry.resetAt - now) / 1000);
res.set('Retry-After', String(retryAfter));
return res.status(429).json({
error: 'Too many requests',
retryAfter,
});
}
next();
};
}
function setRateLimitHeaders(res: Response, limit: number, remaining: number, reset: number) {
res.set('X-RateLimit-Limit', String(limit));
res.set('X-RateLimit-Remaining', String(remaining));
res.set('X-RateLimit-Reset', String(Math.ceil(reset / 1000)));
}
// Clean up expired entries periodically
setInterval(() => {
const now = Date.now();
for (const [key, entry] of store) {
if (now > entry.resetAt) store.delete(key);
}
}, 60000);
Step 3: Apply Rate Limiting
import express from 'express';
import { rateLimit } from './middleware/rate-limit';
const app = express();
// Global: 100 requests per minute
app.use(rateLimit({ windowMs: 60000, max: 100 }));
// Strict: 10 per minute for write operations
app.post('/api/*', rateLimit({ windowMs: 60000, max: 10 }));
// Generous: 500 per minute for reads
app.get('/api/*', rateLimit({ windowMs: 60000, max: 500 }));
Step 4: Exponential Backoff for External APIs
// When your Replit app calls external APIs
export async function withBackoff<T>(
fn: () => Promise<T>,
opts = { maxRetries: 5, baseMs: 1000, maxMs: 30000 }
): Promise<T> {
for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
try {
return await fn();
} catch (err: any) {
if (attempt === opts.maxRetries) throw err;
const status = err.status || err.response?.status;
if (status && status !== 429 && status < 500) throw err;
const delay = Math.min(opts.baseMs * 2 ** attempt, opts.maxMs);
const jitter = Math.random() * delay * 0.1;
await new Promise(r => setTimeout(r, delay + jitter));
}
}
throw new Error('Unreachable');
}
Step 5: Request Queue for Burst Protection
import PQueue from 'p-queue';
// Limit concurrent requests to external services
const queue = new PQueue({
concurrency: 5, // max parallel requests
interval: 1000, // per this window
intervalCap: 10, // max requests in window
});
async function rateLimitedFetch(url: string, opts?: RequestInit) {
return queue.add(() => fetch(url, opts));
}
Error Handling
| Error | Cause | Solution |
|---|---|---|
KV Max storage exceeded | Over 50 MiB | Migrate large values to Object Storage |
KV Max keys exceeded | Over 5,000 keys | Archive old data, use prefix namespacing |
| 429 from your API | Client hitting your limits | Return Retry-After header |
| Object Storage throttled | Too many rapid requests | Add client-side request queue |
| High egress costs | Large responses | Compress, paginate, or cache at CDN |
Resources
Next Steps
For security configuration, see replit-security-basics.
More by jeremylongshore
View all skills by jeremylongshore →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversUnlock seamless Figma to code: streamline Figma to HTML with Framelink MCP Server for fast, accurate design-to-code work
Access official Microsoft Docs instantly for up-to-date info. Integrates with ms word and ms word online for seamless wo
Integrate Feishu (Lark) for seamless document retrieval, messaging, and collaboration via TypeScript CLI or HTTP server
Reddit Buddy offers powerful Reddit API tools for browsing, searching, and data annotation with secure access, rate limi
Reddit Buddy offers clean access to Reddit API, advanced reddit tools, and seamless data annotation reddit with smart ca
Explore Magic UI, a React UI library offering structured component access, code suggestions, and installation guides for
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.