[{"data":1,"prerenderedAt":1863},["ShallowReactive",2],{"blog-en-database-indexing-explained":3,"blog-related-en-database-indexing-explained":345},{"id":4,"title":5,"author":6,"body":7,"date":327,"description":328,"extension":329,"featured":330,"image":331,"meta":332,"navigation":333,"path":334,"readingTime":335,"seo":336,"slug":337,"stem":338,"tags":339,"__hash__":344},"blog\u002Fblog\u002Fen\u002Fdatabase-indexing-explained.md","Database Indexing Explained: Why Your API is Slow Even with Just 50,000 Rows","Adam Abdel-Djamal",{"type":8,"value":9,"toc":317},"minimark",[10,14,22,25,30,33,50,53,55,62,73,114,117,125,130,157,159,163,166,175,181,187,201,203,207,218,250,274,276,280,290,310,313],[11,12,13],"p",{},"When developing locally with 20 seed records in SQLite or PostgreSQL, every query returns in under 1ms. But deploy that same code to production with just 50,000 customer records, and suddenly your dashboard endpoints take 1,200ms to respond.",[11,15,16,17,21],{},"The culprit is almost always a missing or misconfigured index. In this guide, we'll demystify how B-Tree indexes work under the hood, how to read ",[18,19,20],"code",{},"EXPLAIN ANALYZE",", and the exact rules for multi-column composite indexes.",[23,24],"hr",{},[26,27,29],"h2",{"id":28},"_1-table-scan-vs-index-scan-the-phone-book-analogy","1. Table Scan vs. Index Scan: The Phone Book Analogy",[11,31,32],{},"Imagine searching for \"Sophie Martin\" in a phone book:",[34,35,36,44],"ul",{},[37,38,39,43],"li",{},[40,41,42],"strong",{},"Sequential Scan (Seq Scan)",": Reading every single entry from page 1 to page 500 until you find the name. This is an (O(N)) disk operation.",[37,45,46,49],{},[40,47,48],{},"Index Scan",": Jumping directly to the \"M\" section using an alphabetical index, finding \"Martin\", and jumping straight to the exact page. This is an (O(\\log N)) operation.",[11,51,52],{},"When your table lacks an index on a queried column, PostgreSQL has no choice: it must load every single page from disk into RAM and scan every row.",[23,54],{},[26,56,58,59,61],{"id":57},"_2-reading-explain-analyze-like-a-senior-engineer","2. Reading ",[18,60,20],{}," Like a Senior Engineer",[11,63,64,65,68,69,72],{},"Before adding indexes blindly, you must profile the query plan. Prepend ",[18,66,67],{},"EXPLAIN (ANALYZE, BUFFERS)"," to your query in ",[18,70,71],{},"psql",":",[74,75,80],"pre",{"className":76,"code":77,"language":78,"meta":79,"style":79},"language-sql shiki shiki-themes github-light github-dark","EXPLAIN (ANALYZE, BUFFERS)\nSELECT id, customer_name, total_amount, created_at\nFROM orders\nWHERE status = 'completed'\n  AND created_at >= '2026-01-01';\n","sql","",[18,81,82,90,96,102,108],{"__ignoreMap":79},[83,84,87],"span",{"class":85,"line":86},"line",1,[83,88,89],{},"EXPLAIN (ANALYZE, BUFFERS)\n",[83,91,93],{"class":85,"line":92},2,[83,94,95],{},"SELECT id, customer_name, total_amount, created_at\n",[83,97,99],{"class":85,"line":98},3,[83,100,101],{},"FROM orders\n",[83,103,105],{"class":85,"line":104},4,[83,106,107],{},"WHERE status = 'completed'\n",[83,109,111],{"class":85,"line":110},5,[83,112,113],{},"  AND created_at >= '2026-01-01';\n",[11,115,116],{},"Look for two critical lines in the output:",[74,118,123],{"className":119,"code":121,"language":122,"meta":79},[120],"language-text","->  Seq Scan on orders  (cost=0.00..1842.00 rows=1240 width=48) (actual time=0.045..42.812 rows=1450 loops=1)\n      Filter: ((status = 'completed'::text) AND (created_at >= '2026-01-01'::date))\n      Rows Removed by Filter: 48550\n      Buffers: shared hit=842 read=1000\nPlanning Time: 0.120 ms\nExecution Time: 43.180 ms\n","text",[18,124,121],{"__ignoreMap":79},[126,127,129],"h3",{"id":128},"key-red-flags","Key Red Flags:",[131,132,133,141,149],"ol",{},[37,134,135,140],{},[40,136,137],{},[18,138,139],{},"Seq Scan on orders",": The database examined all 50,000 rows.",[37,142,143,148],{},[40,144,145],{},[18,146,147],{},"Rows Removed by Filter: 48550",": The engine threw away 97% of the data it read from disk.",[37,150,151,156],{},[40,152,153],{},[18,154,155],{},"Buffers: read=1000",": The database had to read 1,000 blocks directly from cold storage instead of memory cache.",[23,158],{},[26,160,162],{"id":161},"_3-creating-the-optimal-index","3. Creating the Optimal Index",[11,164,165],{},"To fix this query, we create a B-Tree index on the filtered columns:",[74,167,169],{"className":76,"code":168,"language":78,"meta":79,"style":79},"CREATE INDEX idx_orders_status_created_at ON orders (status, created_at);\n",[18,170,171],{"__ignoreMap":79},[83,172,173],{"class":85,"line":86},[83,174,168],{},[11,176,177,178,180],{},"Run ",[18,179,20],{}," again:",[74,182,185],{"className":183,"code":184,"language":122,"meta":79},[120],"->  Bitmap Index Scan on idx_orders_status_created_at  (cost=0.00..12.40 rows=1450 width=0) (actual time=0.120..0.120 rows=1450 loops=1)\n      Index Cond: ((status = 'completed'::text) AND (created_at >= '2026-01-01'::date))\n      Buffers: shared hit=18\nExecution Time: 0.820 ms\n",[18,186,184],{"__ignoreMap":79},[11,188,189,192,193,196,197,200],{},[40,190,191],{},"Result",": Execution time dropped from ",[40,194,195],{},"43.1ms down to 0.8ms"," — a ",[40,198,199],{},"52x speedup"," with 98% fewer disk reads!",[23,202],{},[26,204,206],{"id":205},"_4-the-golden-rule-of-composite-indexes-leftmost-prefix","4. The Golden Rule of Composite Indexes: Leftmost Prefix",[11,208,209,210,213,214,217],{},"When creating multi-column indexes like ",[18,211,212],{},"CREATE INDEX idx_user_filter ON users (country, status, created_at)",", PostgreSQL reads columns ",[40,215,216],{},"from left to right",".",[34,219,220,227,232,237,244],{},[37,221,222,223,226],{},"✅ ",[18,224,225],{},"WHERE country = 'BJ'"," (Uses index)",[37,228,222,229,226],{},[18,230,231],{},"WHERE country = 'BJ' AND status = 'active'",[37,233,222,234,226],{},[18,235,236],{},"WHERE country = 'BJ' AND status = 'active' AND created_at > '2026-01-01'",[37,238,239,240,243],{},"❌ ",[18,241,242],{},"WHERE status = 'active'"," (Index CANNOT be used efficiently!)",[37,245,239,246,249],{},[18,247,248],{},"WHERE created_at > '2026-01-01'"," (Index CANNOT be used!)",[251,252,253],"blockquote",{},[11,254,255,258,259,262,263,266,267,266,270,273],{},[40,256,257],{},"Rule of Thumb",": Put exact equality columns (",[18,260,261],{},"=",") first, and range\u002Fcomparison columns (",[18,264,265],{},">",", ",[18,268,269],{},"\u003C",[18,271,272],{},"BETWEEN",") last.",[23,275],{},[26,277,279],{"id":278},"_5-partial-indexes-the-secret-superpower","5. Partial Indexes: The Secret Superpower",[11,281,282,283,286,287,72],{},"If 90% of your orders are ",[18,284,285],{},"completed",", indexing the entire table wastes disk and RAM. Use a ",[40,288,289],{},"partial index",[74,291,293],{"className":76,"code":292,"language":78,"meta":79,"style":79},"-- Only indexes rows that match the condition\nCREATE INDEX idx_pending_orders ON orders (created_at)\nWHERE status = 'pending';\n",[18,294,295,300,305],{"__ignoreMap":79},[83,296,297],{"class":85,"line":86},[83,298,299],{},"-- Only indexes rows that match the condition\n",[83,301,302],{"class":85,"line":92},[83,303,304],{},"CREATE INDEX idx_pending_orders ON orders (created_at)\n",[83,306,307],{"class":85,"line":98},[83,308,309],{},"WHERE status = 'pending';\n",[11,311,312],{},"This index is 90% smaller, stays hot in RAM, and speeds up invoice processing queues dramatically.",[314,315,316],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":79,"searchDepth":92,"depth":92,"links":318},[319,320,324,325,326],{"id":28,"depth":92,"text":29},{"id":57,"depth":92,"text":321,"children":322},"2. Reading EXPLAIN ANALYZE Like a Senior Engineer",[323],{"id":128,"depth":98,"text":129},{"id":161,"depth":92,"text":162},{"id":205,"depth":92,"text":206},{"id":278,"depth":92,"text":279},"2026-08-10","A visual guide to database bottlenecks. Explains table scans vs. index scans, when composite indexes work (and when they fail), and how to read EXPLAIN ANALYZE.","md",false,null,{},true,"\u002Fblog\u002Fen\u002Fdatabase-indexing-explained",7,{"title":5,"description":328},"database-indexing-explained","blog\u002Fen\u002Fdatabase-indexing-explained",[340,341,342,343,78],"postgresql","database","performance","backend","eDveI9i8iMWk0sJVyfO0p9pwrQW9wk5AFW9xLc8HeSg",[346,1196],{"id":347,"title":348,"author":6,"body":349,"date":1185,"description":1186,"extension":329,"featured":330,"image":331,"meta":1187,"navigation":333,"path":1188,"readingTime":489,"seo":1189,"slug":331,"stem":1190,"tags":1191,"__hash__":1195},"blog\u002Fblog\u002Fen\u002Fapi-common-mistakes.md","6 Common API Mistakes (And How to Fix Them)",{"type":8,"value":350,"toc":1176},[351,354,356,360,371,403,424,426,430,437,530,535,655,657,661,664,724,727,729,733,736,874,881,883,887,890,1068,1071,1073,1077,1080,1114,1121,1123,1127,1130,1173],[11,352,353],{},"Building an API feels straightforward until your first production incident. Most bugs aren't complex — they're the same six mistakes repeated across thousands of codebases. Here's what they are and how to stop making them.",[23,355],{},[26,357,359],{"id":358},"_1-using-the-wrong-http-method","1. Using the Wrong HTTP Method",[11,361,362,363,366,367,370],{},"The most visible mistake. Using ",[18,364,365],{},"GET"," to delete a resource, or ",[18,368,369],{},"POST"," for everything because \"it works.\"",[74,372,376],{"className":373,"code":374,"language":375,"meta":79,"style":79},"language-http shiki shiki-themes github-light github-dark","# ❌ Deleting with GET — catastrophic if a browser prefetches this URL\nGET \u002Fapi\u002Fusers\u002F42\u002Fdelete\n\n# ✅ Correct\nDELETE \u002Fapi\u002Fusers\u002F42\n","http",[18,377,378,383,388,393,398],{"__ignoreMap":79},[83,379,380],{"class":85,"line":86},[83,381,382],{},"# ❌ Deleting with GET — catastrophic if a browser prefetches this URL\n",[83,384,385],{"class":85,"line":92},[83,386,387],{},"GET \u002Fapi\u002Fusers\u002F42\u002Fdelete\n",[83,389,390],{"class":85,"line":98},[83,391,392],{"emptyLinePlaceholder":333},"\n",[83,394,395],{"class":85,"line":104},[83,396,397],{},"# ✅ Correct\n",[83,399,400],{"class":85,"line":110},[83,401,402],{},"DELETE \u002Fapi\u002Fusers\u002F42\n",[11,404,405,406,408,409,411,412,415,416,419,420,423],{},"HTTP methods carry semantic meaning that clients, proxies, and caches rely on. ",[18,407,365],{}," must be idempotent and safe (no side effects). ",[18,410,369],{}," creates. ",[18,413,414],{},"PUT","\u002F",[18,417,418],{},"PATCH"," update. ",[18,421,422],{},"DELETE"," removes. Violating these conventions breaks caching, browser history, and every HTTP client that follows the spec.",[23,425],{},[26,427,429],{"id":428},"_2-wrong-status-codes","2. Wrong Status Codes",[11,431,432,433,436],{},"Returning ",[18,434,435],{},"200 OK"," for an error response is the most common mistake in junior APIs.",[74,438,442],{"className":439,"code":440,"language":441,"meta":79,"style":79},"language-json shiki shiki-themes github-light github-dark","\u002F\u002F ❌ Status 200, but it's an error\n{\n  \"success\": false,\n  \"error\": \"User not found\"\n}\n\n\u002F\u002F ✅ Status 404 — the client knows immediately without parsing the body\n{\n  \"error\": \"User not found\",\n  \"code\": \"USER_NOT_FOUND\"\n}\n","json",[18,443,444,450,456,471,482,487,492,497,502,514,525],{"__ignoreMap":79},[83,445,446],{"class":85,"line":86},[83,447,449],{"class":448},"sJ8bj","\u002F\u002F ❌ Status 200, but it's an error\n",[83,451,452],{"class":85,"line":92},[83,453,455],{"class":454},"sVt8B","{\n",[83,457,458,462,465,468],{"class":85,"line":98},[83,459,461],{"class":460},"sj4cs","  \"success\"",[83,463,464],{"class":454},": ",[83,466,467],{"class":460},"false",[83,469,470],{"class":454},",\n",[83,472,473,476,478],{"class":85,"line":104},[83,474,475],{"class":460},"  \"error\"",[83,477,464],{"class":454},[83,479,481],{"class":480},"sZZnC","\"User not found\"\n",[83,483,484],{"class":85,"line":110},[83,485,486],{"class":454},"}\n",[83,488,490],{"class":85,"line":489},6,[83,491,392],{"emptyLinePlaceholder":333},[83,493,494],{"class":85,"line":335},[83,495,496],{"class":448},"\u002F\u002F ✅ Status 404 — the client knows immediately without parsing the body\n",[83,498,500],{"class":85,"line":499},8,[83,501,455],{"class":454},[83,503,505,507,509,512],{"class":85,"line":504},9,[83,506,475],{"class":460},[83,508,464],{"class":454},[83,510,511],{"class":480},"\"User not found\"",[83,513,470],{"class":454},[83,515,517,520,522],{"class":85,"line":516},10,[83,518,519],{"class":460},"  \"code\"",[83,521,464],{"class":454},[83,523,524],{"class":480},"\"USER_NOT_FOUND\"\n",[83,526,528],{"class":85,"line":527},11,[83,529,486],{"class":454},[11,531,532],{},[40,533,534],{},"The codes that matter most:",[536,537,538,551],"table",{},[539,540,541],"thead",{},[542,543,544,548],"tr",{},[545,546,547],"th",{},"Code",[545,549,550],{},"When to use it",[552,553,554,565,575,585,595,605,615,625,635,645],"tbody",{},[542,555,556,562],{},[557,558,559],"td",{},[18,560,561],{},"200",[557,563,564],{},"Success with a body",[542,566,567,572],{},[557,568,569],{},[18,570,571],{},"201",[557,573,574],{},"Resource created (POST)",[542,576,577,582],{},[557,578,579],{},[18,580,581],{},"204",[557,583,584],{},"Success, no body (DELETE)",[542,586,587,592],{},[557,588,589],{},[18,590,591],{},"400",[557,593,594],{},"Invalid input from the client",[542,596,597,602],{},[557,598,599],{},[18,600,601],{},"401",[557,603,604],{},"Not authenticated",[542,606,607,612],{},[557,608,609],{},[18,610,611],{},"403",[557,613,614],{},"Authenticated but not authorized",[542,616,617,622],{},[557,618,619],{},[18,620,621],{},"404",[557,623,624],{},"Resource doesn't exist",[542,626,627,632],{},[557,628,629],{},[18,630,631],{},"422",[557,633,634],{},"Input syntactically valid but semantically wrong",[542,636,637,642],{},[557,638,639],{},[18,640,641],{},"429",[557,643,644],{},"Rate limit exceeded",[542,646,647,652],{},[557,648,649],{},[18,650,651],{},"500",[557,653,654],{},"Server error (never the client's fault)",[23,656],{},[26,658,660],{"id":659},"_3-trusting-client-input","3. Trusting Client Input",[11,662,663],{},"Every value sent by a client is a potential attack vector.",[74,665,669],{"className":666,"code":667,"language":668,"meta":79,"style":79},"language-php shiki shiki-themes github-light github-dark","\u002F\u002F ❌ Never do this\n$id = $_GET['id'];\n$query = \"SELECT * FROM users WHERE id = $id\";\n\u002F\u002F SQL injection: ?id=1 OR 1=1\n\n\u002F\u002F ✅ Always validate and sanitize\n$id = filter_var($_GET['id'], FILTER_VALIDATE_INT);\nif (!$id) {\n    return response()->json(['error' => 'Invalid ID'], 400);\n}\n$user = User::findOrFail($id); \u002F\u002F parameterized query\n","php",[18,670,671,676,681,686,691,695,700,705,710,715,719],{"__ignoreMap":79},[83,672,673],{"class":85,"line":86},[83,674,675],{},"\u002F\u002F ❌ Never do this\n",[83,677,678],{"class":85,"line":92},[83,679,680],{},"$id = $_GET['id'];\n",[83,682,683],{"class":85,"line":98},[83,684,685],{},"$query = \"SELECT * FROM users WHERE id = $id\";\n",[83,687,688],{"class":85,"line":104},[83,689,690],{},"\u002F\u002F SQL injection: ?id=1 OR 1=1\n",[83,692,693],{"class":85,"line":110},[83,694,392],{"emptyLinePlaceholder":333},[83,696,697],{"class":85,"line":489},[83,698,699],{},"\u002F\u002F ✅ Always validate and sanitize\n",[83,701,702],{"class":85,"line":335},[83,703,704],{},"$id = filter_var($_GET['id'], FILTER_VALIDATE_INT);\n",[83,706,707],{"class":85,"line":499},[83,708,709],{},"if (!$id) {\n",[83,711,712],{"class":85,"line":504},[83,713,714],{},"    return response()->json(['error' => 'Invalid ID'], 400);\n",[83,716,717],{"class":85,"line":516},[83,718,486],{},[83,720,721],{"class":85,"line":527},[83,722,723],{},"$user = User::findOrFail($id); \u002F\u002F parameterized query\n",[11,725,726],{},"Validate: type, format, length, range. Sanitize before any database or filesystem operation. Never trust what arrives in the request body, headers, or query string.",[23,728],{},[26,730,732],{"id":731},"_4-leaking-sensitive-data","4. Leaking Sensitive Data",[11,734,735],{},"Returning the full database object without filtering is an invitation to a data breach.",[74,737,739],{"className":439,"code":738,"language":441,"meta":79,"style":79},"\u002F\u002F ❌ Returning the raw User model\n{\n  \"id\": 42,\n  \"email\": \"user@example.com\",\n  \"password\": \"$2b$12$...\",\n  \"stripe_customer_id\": \"cus_xxx\",\n  \"internal_notes\": \"flagged for review\",\n  \"created_at\": \"2024-01-01\"\n}\n\n\u002F\u002F ✅ Return only what the client actually needs\n{\n  \"id\": 42,\n  \"email\": \"user@example.com\",\n  \"created_at\": \"2024-01-01\"\n}\n",[18,740,741,746,750,762,774,786,798,810,820,824,828,833,838,849,860,869],{"__ignoreMap":79},[83,742,743],{"class":85,"line":86},[83,744,745],{"class":448},"\u002F\u002F ❌ Returning the raw User model\n",[83,747,748],{"class":85,"line":92},[83,749,455],{"class":454},[83,751,752,755,757,760],{"class":85,"line":98},[83,753,754],{"class":460},"  \"id\"",[83,756,464],{"class":454},[83,758,759],{"class":460},"42",[83,761,470],{"class":454},[83,763,764,767,769,772],{"class":85,"line":104},[83,765,766],{"class":460},"  \"email\"",[83,768,464],{"class":454},[83,770,771],{"class":480},"\"user@example.com\"",[83,773,470],{"class":454},[83,775,776,779,781,784],{"class":85,"line":110},[83,777,778],{"class":460},"  \"password\"",[83,780,464],{"class":454},[83,782,783],{"class":480},"\"$2b$12$...\"",[83,785,470],{"class":454},[83,787,788,791,793,796],{"class":85,"line":489},[83,789,790],{"class":460},"  \"stripe_customer_id\"",[83,792,464],{"class":454},[83,794,795],{"class":480},"\"cus_xxx\"",[83,797,470],{"class":454},[83,799,800,803,805,808],{"class":85,"line":335},[83,801,802],{"class":460},"  \"internal_notes\"",[83,804,464],{"class":454},[83,806,807],{"class":480},"\"flagged for review\"",[83,809,470],{"class":454},[83,811,812,815,817],{"class":85,"line":499},[83,813,814],{"class":460},"  \"created_at\"",[83,816,464],{"class":454},[83,818,819],{"class":480},"\"2024-01-01\"\n",[83,821,822],{"class":85,"line":504},[83,823,486],{"class":454},[83,825,826],{"class":85,"line":516},[83,827,392],{"emptyLinePlaceholder":333},[83,829,830],{"class":85,"line":527},[83,831,832],{"class":448},"\u002F\u002F ✅ Return only what the client actually needs\n",[83,834,836],{"class":85,"line":835},12,[83,837,455],{"class":454},[83,839,841,843,845,847],{"class":85,"line":840},13,[83,842,754],{"class":460},[83,844,464],{"class":454},[83,846,759],{"class":460},[83,848,470],{"class":454},[83,850,852,854,856,858],{"class":85,"line":851},14,[83,853,766],{"class":460},[83,855,464],{"class":454},[83,857,771],{"class":480},[83,859,470],{"class":454},[83,861,863,865,867],{"class":85,"line":862},15,[83,864,814],{"class":460},[83,866,464],{"class":454},[83,868,819],{"class":480},[83,870,872],{"class":85,"line":871},16,[83,873,486],{"class":454},[11,875,876,877,880],{},"Use serializers, DTOs, or API Resources (Laravel) to explicitly define what gets exposed. The rule: ",[40,878,879],{},"opt-in, not opt-out."," Start with nothing, add what's needed.",[23,882],{},[26,884,886],{"id":885},"_5-inconsistent-error-format","5. Inconsistent Error Format",[11,888,889],{},"When every endpoint returns errors differently, every client has to handle every format.",[74,891,893],{"className":439,"code":892,"language":441,"meta":79,"style":79},"\u002F\u002F ❌ Endpoint A\n{ \"message\": \"Not found\" }\n\n\u002F\u002F ❌ Endpoint B\n{ \"error\": true, \"msg\": \"Validation failed\", \"fields\": [\"email\"] }\n\n\u002F\u002F ❌ Endpoint C\n\"Internal server error\"\n\n\u002F\u002F ✅ One format, everywhere\n{\n  \"error\": {\n    \"code\": \"VALIDATION_FAILED\",\n    \"message\": \"The request contains invalid fields.\",\n    \"details\": [\n      { \"field\": \"email\", \"issue\": \"Invalid email format\" }\n    ]\n  }\n}\n",[18,894,895,900,916,920,925,961,965,970,975,979,984,988,995,1007,1019,1027,1051,1057,1063],{"__ignoreMap":79},[83,896,897],{"class":85,"line":86},[83,898,899],{"class":448},"\u002F\u002F ❌ Endpoint A\n",[83,901,902,905,908,910,913],{"class":85,"line":92},[83,903,904],{"class":454},"{ ",[83,906,907],{"class":460},"\"message\"",[83,909,464],{"class":454},[83,911,912],{"class":480},"\"Not found\"",[83,914,915],{"class":454}," }\n",[83,917,918],{"class":85,"line":98},[83,919,392],{"emptyLinePlaceholder":333},[83,921,922],{"class":85,"line":104},[83,923,924],{"class":448},"\u002F\u002F ❌ Endpoint B\n",[83,926,927,929,932,934,937,939,942,944,947,949,952,955,958],{"class":85,"line":110},[83,928,904],{"class":454},[83,930,931],{"class":460},"\"error\"",[83,933,464],{"class":454},[83,935,936],{"class":460},"true",[83,938,266],{"class":454},[83,940,941],{"class":460},"\"msg\"",[83,943,464],{"class":454},[83,945,946],{"class":480},"\"Validation failed\"",[83,948,266],{"class":454},[83,950,951],{"class":460},"\"fields\"",[83,953,954],{"class":454},": [",[83,956,957],{"class":480},"\"email\"",[83,959,960],{"class":454},"] }\n",[83,962,963],{"class":85,"line":489},[83,964,392],{"emptyLinePlaceholder":333},[83,966,967],{"class":85,"line":335},[83,968,969],{"class":448},"\u002F\u002F ❌ Endpoint C\n",[83,971,972],{"class":85,"line":499},[83,973,974],{"class":480},"\"Internal server error\"\n",[83,976,977],{"class":85,"line":504},[83,978,392],{"emptyLinePlaceholder":333},[83,980,981],{"class":85,"line":516},[83,982,983],{"class":448},"\u002F\u002F ✅ One format, everywhere\n",[83,985,986],{"class":85,"line":527},[83,987,455],{"class":454},[83,989,990,992],{"class":85,"line":835},[83,991,475],{"class":460},[83,993,994],{"class":454},": {\n",[83,996,997,1000,1002,1005],{"class":85,"line":840},[83,998,999],{"class":460},"    \"code\"",[83,1001,464],{"class":454},[83,1003,1004],{"class":480},"\"VALIDATION_FAILED\"",[83,1006,470],{"class":454},[83,1008,1009,1012,1014,1017],{"class":85,"line":851},[83,1010,1011],{"class":460},"    \"message\"",[83,1013,464],{"class":454},[83,1015,1016],{"class":480},"\"The request contains invalid fields.\"",[83,1018,470],{"class":454},[83,1020,1021,1024],{"class":85,"line":862},[83,1022,1023],{"class":460},"    \"details\"",[83,1025,1026],{"class":454},": [\n",[83,1028,1029,1032,1035,1037,1039,1041,1044,1046,1049],{"class":85,"line":871},[83,1030,1031],{"class":454},"      { ",[83,1033,1034],{"class":460},"\"field\"",[83,1036,464],{"class":454},[83,1038,957],{"class":480},[83,1040,266],{"class":454},[83,1042,1043],{"class":460},"\"issue\"",[83,1045,464],{"class":454},[83,1047,1048],{"class":480},"\"Invalid email format\"",[83,1050,915],{"class":454},[83,1052,1054],{"class":85,"line":1053},17,[83,1055,1056],{"class":454},"    ]\n",[83,1058,1060],{"class":85,"line":1059},18,[83,1061,1062],{"class":454},"  }\n",[83,1064,1066],{"class":85,"line":1065},19,[83,1067,486],{"class":454},[11,1069,1070],{},"Define your error envelope once. Apply it everywhere via a global exception handler. Clients — including your own frontend — will thank you.",[23,1072],{},[26,1074,1076],{"id":1075},"_6-no-api-versioning","6. No API Versioning",[11,1078,1079],{},"Changing an endpoint response breaks every client using it. Without versioning, you can never evolve the API.",[74,1081,1083],{"className":373,"code":1082,"language":375,"meta":79,"style":79},"# ❌ No version — any breaking change affects all clients immediately\nGET \u002Fapi\u002Fusers\n\n# ✅ Versioned — v1 stays stable, v2 introduces breaking changes safely\nGET \u002Fapi\u002Fv1\u002Fusers\nGET \u002Fapi\u002Fv2\u002Fusers\n",[18,1084,1085,1090,1095,1099,1104,1109],{"__ignoreMap":79},[83,1086,1087],{"class":85,"line":86},[83,1088,1089],{},"# ❌ No version — any breaking change affects all clients immediately\n",[83,1091,1092],{"class":85,"line":92},[83,1093,1094],{},"GET \u002Fapi\u002Fusers\n",[83,1096,1097],{"class":85,"line":98},[83,1098,392],{"emptyLinePlaceholder":333},[83,1100,1101],{"class":85,"line":104},[83,1102,1103],{},"# ✅ Versioned — v1 stays stable, v2 introduces breaking changes safely\n",[83,1105,1106],{"class":85,"line":110},[83,1107,1108],{},"GET \u002Fapi\u002Fv1\u002Fusers\n",[83,1110,1111],{"class":85,"line":489},[83,1112,1113],{},"GET \u002Fapi\u002Fv2\u002Fusers\n",[11,1115,1116,1117,1120],{},"Version from day one, even if you only have v1. The cost of adding ",[18,1118,1119],{},"\u002Fv1\u002F"," later — after clients are in production — is much higher than the cost of including it from the start.",[23,1122],{},[26,1124,1126],{"id":1125},"the-takeaway","The Takeaway",[11,1128,1129],{},"None of these mistakes require advanced knowledge to fix. They require discipline: a checklist before every endpoint ships.",[34,1131,1134,1143,1149,1155,1161,1167],{"className":1132},[1133],"contains-task-list",[37,1135,1138,1142],{"className":1136},[1137],"task-list-item",[1139,1140],"input",{"disabled":333,"type":1141},"checkbox"," HTTP method matches the operation's semantics",[37,1144,1146,1148],{"className":1145},[1137],[1139,1147],{"disabled":333,"type":1141}," Status code is accurate",[37,1150,1152,1154],{"className":1151},[1137],[1139,1153],{"disabled":333,"type":1141}," All input is validated before use",[37,1156,1158,1160],{"className":1157},[1137],[1139,1159],{"disabled":333,"type":1141}," Response only exposes necessary fields",[37,1162,1164,1166],{"className":1163},[1137],[1139,1165],{"disabled":333,"type":1141}," Errors follow the global format",[37,1168,1170,1172],{"className":1169},[1137],[1139,1171],{"disabled":333,"type":1141}," URL includes an API version",[314,1174,1175],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}",{"title":79,"searchDepth":92,"depth":92,"links":1177},[1178,1179,1180,1181,1182,1183,1184],{"id":358,"depth":92,"text":359},{"id":428,"depth":92,"text":429},{"id":659,"depth":92,"text":660},{"id":731,"depth":92,"text":732},{"id":885,"depth":92,"text":886},{"id":1075,"depth":92,"text":1076},{"id":1125,"depth":92,"text":1126},"2026-06-04","From wrong HTTP methods to leaking sensitive data — the errors most developers make when building their first API, and the concrete fixes.",{},"\u002Fblog\u002Fen\u002Fapi-common-mistakes",{"title":348,"description":1186},"blog\u002Fen\u002Fapi-common-mistakes",[1192,343,1193,1194],"api","rest","best-practices","z2NMprz3c9WpXKotgDMzEF9WM_LLLolyFqidBZu4I6s",{"id":1197,"title":1198,"author":6,"body":1199,"date":1852,"description":1853,"extension":329,"featured":330,"image":331,"meta":1854,"navigation":333,"path":1855,"readingTime":489,"seo":1856,"slug":1857,"stem":1858,"tags":1859,"__hash__":1862},"blog\u002Fblog\u002Fen\u002Fapi-rate-limiting-redis.md","API Rate Limiting in Practice: Token Bucket vs. Sliding Window with Redis",{"type":8,"value":1200,"toc":1843},[1201,1204,1207,1218,1220,1224,1228,1235,1239,1242,1250,1254,1257,1259,1263,1270,1771,1773,1777,1780,1837,1840],[11,1202,1203],{},"Without API rate limiting, a single rogue script or misconfigured webhook client can fire 10,000 requests per second at your login or checkout endpoint, exhausting your database connection pool and taking your entire application down.",[11,1205,1206],{},"Rate limiting is the first line of defense against bot attacks, credential stuffing, and API resource abuse. But which algorithm should you implement?",[11,1208,1209,1210,1213,1214,1217],{},"In this article, we compare the two industry-standard algorithms — ",[40,1211,1212],{},"Token Bucket"," and ",[40,1215,1216],{},"Sliding Window Log"," — and show how to implement a high-speed sliding window rate limiter in Redis.",[23,1219],{},[26,1221,1223],{"id":1222},"_1-comparing-the-algorithms","1. Comparing the Algorithms",[126,1225,1227],{"id":1226},"a-fixed-window-counter-the-flawed-default","A. Fixed Window Counter (The Flawed Default)",[11,1229,1230,1231,1234],{},"Divides time into fixed buckets (e.g. 10:00 to 10:01). If a user can make 100 requests per minute, they can send 100 requests at 10:00:59, and another 100 requests at 10:01:01. That means ",[40,1232,1233],{},"200 requests in 2 seconds"," — double the intended burst limit!",[126,1236,1238],{"id":1237},"b-token-bucket","B. Token Bucket",[11,1240,1241],{},"A bucket holds a fixed number of tokens (burst capacity). Tokens are continuously replenished at a constant rate. Each incoming request consumes one token.",[34,1243,1244],{},[37,1245,1246,1249],{},[40,1247,1248],{},"Great for",": APIs that want to allow legitimate temporary traffic spikes while capping sustained throughput.",[126,1251,1253],{"id":1252},"c-sliding-window-counter-the-production-standard","C. Sliding Window Counter (The Production Standard)",[11,1255,1256],{},"Combines the low memory usage of fixed windows with the smoothness of a rolling window. It calculates the request rate by weighting the request count of the previous window and the current window.",[23,1258],{},[26,1260,1262],{"id":1261},"_2-sliding-window-rate-limiter-with-redis-sorted-sets","2. Sliding Window Rate Limiter with Redis Sorted Sets",[11,1264,1265,1266,1269],{},"Redis Sorted Sets (",[18,1267,1268],{},"ZSET",") allow us to track requests by timestamp with microsecond accuracy:",[74,1271,1275],{"className":1272,"code":1273,"language":1274,"meta":79,"style":79},"language-typescript shiki shiki-themes github-light github-dark","import Redis from 'ioredis'\n\nconst redis = new Redis(process.env.REDIS_URL!)\n\nexport async function checkRateLimit(identifier: string, limit = 60, windowInSeconds = 60) {\n  const now = Date.now()\n  const windowStart = now - (windowInSeconds * 1000)\n  const key = `ratelimit:${identifier}`\n\n  \u002F\u002F Atomic Redis Pipeline (Runs in a single round-trip)\n  const multi = redis.multi()\n  \u002F\u002F 1. Remove all request timestamps older than the active window\n  multi.zremrangebyscore(key, 0, windowStart)\n  \u002F\u002F 2. Count requests currently in the active window\n  multi.zcard(key)\n  \u002F\u002F 3. Add the current timestamp as a new request\n  multi.zadd(key, now, `${now}-${Math.random()}`)\n  \u002F\u002F 4. Set key expiration to auto-clean idle users\n  multi.expire(key, windowInSeconds)\n\n  const results = await multi.exec()\n  const currentCount = (results?.[1]?.[1] as number) || 0\n\n  if (currentCount >= limit) {\n    return {\n      allowed: false,\n      remaining: 0,\n      retryAfter: Math.ceil(windowInSeconds - ((now - windowStart) \u002F 1000))\n    }\n  }\n\n  return {\n    allowed: true,\n    remaining: limit - currentCount - 1,\n    retryAfter: 0\n  }\n}\n","typescript",[18,1276,1277,1292,1296,1326,1330,1378,1397,1423,1440,1444,1449,1466,1471,1488,1493,1503,1508,1542,1547,1557,1562,1583,1622,1627,1642,1651,1661,1671,1700,1706,1711,1716,1724,1734,1752,1761,1766],{"__ignoreMap":79},[83,1278,1279,1283,1286,1289],{"class":85,"line":86},[83,1280,1282],{"class":1281},"szBVR","import",[83,1284,1285],{"class":454}," Redis ",[83,1287,1288],{"class":1281},"from",[83,1290,1291],{"class":480}," 'ioredis'\n",[83,1293,1294],{"class":85,"line":92},[83,1295,392],{"emptyLinePlaceholder":333},[83,1297,1298,1301,1304,1307,1310,1314,1317,1320,1323],{"class":85,"line":98},[83,1299,1300],{"class":1281},"const",[83,1302,1303],{"class":460}," redis",[83,1305,1306],{"class":1281}," =",[83,1308,1309],{"class":1281}," new",[83,1311,1313],{"class":1312},"sScJk"," Redis",[83,1315,1316],{"class":454},"(process.env.",[83,1318,1319],{"class":460},"REDIS_URL",[83,1321,1322],{"class":1281},"!",[83,1324,1325],{"class":454},")\n",[83,1327,1328],{"class":85,"line":104},[83,1329,392],{"emptyLinePlaceholder":333},[83,1331,1332,1335,1338,1341,1344,1347,1351,1353,1356,1358,1361,1363,1366,1368,1371,1373,1375],{"class":85,"line":110},[83,1333,1334],{"class":1281},"export",[83,1336,1337],{"class":1281}," async",[83,1339,1340],{"class":1281}," function",[83,1342,1343],{"class":1312}," checkRateLimit",[83,1345,1346],{"class":454},"(",[83,1348,1350],{"class":1349},"s4XuR","identifier",[83,1352,72],{"class":1281},[83,1354,1355],{"class":460}," string",[83,1357,266],{"class":454},[83,1359,1360],{"class":1349},"limit",[83,1362,1306],{"class":1281},[83,1364,1365],{"class":460}," 60",[83,1367,266],{"class":454},[83,1369,1370],{"class":1349},"windowInSeconds",[83,1372,1306],{"class":1281},[83,1374,1365],{"class":460},[83,1376,1377],{"class":454},") {\n",[83,1379,1380,1383,1386,1388,1391,1394],{"class":85,"line":489},[83,1381,1382],{"class":1281},"  const",[83,1384,1385],{"class":460}," now",[83,1387,1306],{"class":1281},[83,1389,1390],{"class":454}," Date.",[83,1392,1393],{"class":1312},"now",[83,1395,1396],{"class":454},"()\n",[83,1398,1399,1401,1404,1406,1409,1412,1415,1418,1421],{"class":85,"line":335},[83,1400,1382],{"class":1281},[83,1402,1403],{"class":460}," windowStart",[83,1405,1306],{"class":1281},[83,1407,1408],{"class":454}," now ",[83,1410,1411],{"class":1281},"-",[83,1413,1414],{"class":454}," (windowInSeconds ",[83,1416,1417],{"class":1281},"*",[83,1419,1420],{"class":460}," 1000",[83,1422,1325],{"class":454},[83,1424,1425,1427,1430,1432,1435,1437],{"class":85,"line":499},[83,1426,1382],{"class":1281},[83,1428,1429],{"class":460}," key",[83,1431,1306],{"class":1281},[83,1433,1434],{"class":480}," `ratelimit:${",[83,1436,1350],{"class":454},[83,1438,1439],{"class":480},"}`\n",[83,1441,1442],{"class":85,"line":504},[83,1443,392],{"emptyLinePlaceholder":333},[83,1445,1446],{"class":85,"line":516},[83,1447,1448],{"class":448},"  \u002F\u002F Atomic Redis Pipeline (Runs in a single round-trip)\n",[83,1450,1451,1453,1456,1458,1461,1464],{"class":85,"line":527},[83,1452,1382],{"class":1281},[83,1454,1455],{"class":460}," multi",[83,1457,1306],{"class":1281},[83,1459,1460],{"class":454}," redis.",[83,1462,1463],{"class":1312},"multi",[83,1465,1396],{"class":454},[83,1467,1468],{"class":85,"line":835},[83,1469,1470],{"class":448},"  \u002F\u002F 1. Remove all request timestamps older than the active window\n",[83,1472,1473,1476,1479,1482,1485],{"class":85,"line":840},[83,1474,1475],{"class":454},"  multi.",[83,1477,1478],{"class":1312},"zremrangebyscore",[83,1480,1481],{"class":454},"(key, ",[83,1483,1484],{"class":460},"0",[83,1486,1487],{"class":454},", windowStart)\n",[83,1489,1490],{"class":85,"line":851},[83,1491,1492],{"class":448},"  \u002F\u002F 2. Count requests currently in the active window\n",[83,1494,1495,1497,1500],{"class":85,"line":862},[83,1496,1475],{"class":454},[83,1498,1499],{"class":1312},"zcard",[83,1501,1502],{"class":454},"(key)\n",[83,1504,1505],{"class":85,"line":871},[83,1506,1507],{"class":448},"  \u002F\u002F 3. Add the current timestamp as a new request\n",[83,1509,1510,1512,1515,1518,1521,1523,1526,1529,1531,1534,1537,1540],{"class":85,"line":1053},[83,1511,1475],{"class":454},[83,1513,1514],{"class":1312},"zadd",[83,1516,1517],{"class":454},"(key, now, ",[83,1519,1520],{"class":480},"`${",[83,1522,1393],{"class":454},[83,1524,1525],{"class":480},"}-${",[83,1527,1528],{"class":454},"Math",[83,1530,217],{"class":480},[83,1532,1533],{"class":1312},"random",[83,1535,1536],{"class":480},"()",[83,1538,1539],{"class":480},"}`",[83,1541,1325],{"class":454},[83,1543,1544],{"class":85,"line":1059},[83,1545,1546],{"class":448},"  \u002F\u002F 4. Set key expiration to auto-clean idle users\n",[83,1548,1549,1551,1554],{"class":85,"line":1065},[83,1550,1475],{"class":454},[83,1552,1553],{"class":1312},"expire",[83,1555,1556],{"class":454},"(key, windowInSeconds)\n",[83,1558,1560],{"class":85,"line":1559},20,[83,1561,392],{"emptyLinePlaceholder":333},[83,1563,1565,1567,1570,1572,1575,1578,1581],{"class":85,"line":1564},21,[83,1566,1382],{"class":1281},[83,1568,1569],{"class":460}," results",[83,1571,1306],{"class":1281},[83,1573,1574],{"class":1281}," await",[83,1576,1577],{"class":454}," multi.",[83,1579,1580],{"class":1312},"exec",[83,1582,1396],{"class":454},[83,1584,1586,1588,1591,1593,1596,1599,1602,1604,1607,1610,1613,1616,1619],{"class":85,"line":1585},22,[83,1587,1382],{"class":1281},[83,1589,1590],{"class":460}," currentCount",[83,1592,1306],{"class":1281},[83,1594,1595],{"class":454}," (results?.[",[83,1597,1598],{"class":460},"1",[83,1600,1601],{"class":454},"]?.[",[83,1603,1598],{"class":460},[83,1605,1606],{"class":454},"] ",[83,1608,1609],{"class":1281},"as",[83,1611,1612],{"class":460}," number",[83,1614,1615],{"class":454},") ",[83,1617,1618],{"class":1281},"||",[83,1620,1621],{"class":460}," 0\n",[83,1623,1625],{"class":85,"line":1624},23,[83,1626,392],{"emptyLinePlaceholder":333},[83,1628,1630,1633,1636,1639],{"class":85,"line":1629},24,[83,1631,1632],{"class":1281},"  if",[83,1634,1635],{"class":454}," (currentCount ",[83,1637,1638],{"class":1281},">=",[83,1640,1641],{"class":454}," limit) {\n",[83,1643,1645,1648],{"class":85,"line":1644},25,[83,1646,1647],{"class":1281},"    return",[83,1649,1650],{"class":454}," {\n",[83,1652,1654,1657,1659],{"class":85,"line":1653},26,[83,1655,1656],{"class":454},"      allowed: ",[83,1658,467],{"class":460},[83,1660,470],{"class":454},[83,1662,1664,1667,1669],{"class":85,"line":1663},27,[83,1665,1666],{"class":454},"      remaining: ",[83,1668,1484],{"class":460},[83,1670,470],{"class":454},[83,1672,1674,1677,1680,1683,1685,1688,1690,1693,1695,1697],{"class":85,"line":1673},28,[83,1675,1676],{"class":454},"      retryAfter: Math.",[83,1678,1679],{"class":1312},"ceil",[83,1681,1682],{"class":454},"(windowInSeconds ",[83,1684,1411],{"class":1281},[83,1686,1687],{"class":454}," ((now ",[83,1689,1411],{"class":1281},[83,1691,1692],{"class":454}," windowStart) ",[83,1694,415],{"class":1281},[83,1696,1420],{"class":460},[83,1698,1699],{"class":454},"))\n",[83,1701,1703],{"class":85,"line":1702},29,[83,1704,1705],{"class":454},"    }\n",[83,1707,1709],{"class":85,"line":1708},30,[83,1710,1062],{"class":454},[83,1712,1714],{"class":85,"line":1713},31,[83,1715,392],{"emptyLinePlaceholder":333},[83,1717,1719,1722],{"class":85,"line":1718},32,[83,1720,1721],{"class":1281},"  return",[83,1723,1650],{"class":454},[83,1725,1727,1730,1732],{"class":85,"line":1726},33,[83,1728,1729],{"class":454},"    allowed: ",[83,1731,936],{"class":460},[83,1733,470],{"class":454},[83,1735,1737,1740,1742,1745,1747,1750],{"class":85,"line":1736},34,[83,1738,1739],{"class":454},"    remaining: limit ",[83,1741,1411],{"class":1281},[83,1743,1744],{"class":454}," currentCount ",[83,1746,1411],{"class":1281},[83,1748,1749],{"class":460}," 1",[83,1751,470],{"class":454},[83,1753,1755,1758],{"class":85,"line":1754},35,[83,1756,1757],{"class":454},"    retryAfter: ",[83,1759,1760],{"class":460},"0\n",[83,1762,1764],{"class":85,"line":1763},36,[83,1765,1062],{"class":454},[83,1767,1769],{"class":85,"line":1768},37,[83,1770,486],{"class":454},[23,1772],{},[26,1774,1776],{"id":1775},"_3-returning-standard-http-rate-limit-headers","3. Returning Standard HTTP Rate Limit Headers",[11,1778,1779],{},"Whenever your server answers a request, communicate rate limit states in the response headers (following IETF draft standards):",[74,1781,1783],{"className":373,"code":1782,"language":375,"meta":79,"style":79},"HTTP\u002F1.1 429 Too Many Requests\nRetry-After: 32\nX-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nX-RateLimit-Reset: 1773489240\nContent-Type: application\u002Fjson\n\n{\n  \"error\": \"Too Many Requests\",\n  \"message\": \"Rate limit exceeded. Please retry in 32 seconds.\"\n}\n",[18,1784,1785,1790,1795,1800,1805,1810,1815,1819,1823,1828,1833],{"__ignoreMap":79},[83,1786,1787],{"class":85,"line":86},[83,1788,1789],{},"HTTP\u002F1.1 429 Too Many Requests\n",[83,1791,1792],{"class":85,"line":92},[83,1793,1794],{},"Retry-After: 32\n",[83,1796,1797],{"class":85,"line":98},[83,1798,1799],{},"X-RateLimit-Limit: 60\n",[83,1801,1802],{"class":85,"line":104},[83,1803,1804],{},"X-RateLimit-Remaining: 0\n",[83,1806,1807],{"class":85,"line":110},[83,1808,1809],{},"X-RateLimit-Reset: 1773489240\n",[83,1811,1812],{"class":85,"line":489},[83,1813,1814],{},"Content-Type: application\u002Fjson\n",[83,1816,1817],{"class":85,"line":335},[83,1818,392],{"emptyLinePlaceholder":333},[83,1820,1821],{"class":85,"line":499},[83,1822,455],{},[83,1824,1825],{"class":85,"line":504},[83,1826,1827],{},"  \"error\": \"Too Many Requests\",\n",[83,1829,1830],{"class":85,"line":516},[83,1831,1832],{},"  \"message\": \"Rate limit exceeded. Please retry in 32 seconds.\"\n",[83,1834,1835],{"class":85,"line":527},[83,1836,486],{},[11,1838,1839],{},"This ensures honest third-party API clients and mobile SDKs can automatically back off and retry without overwhelming your infrastructure.",[314,1841,1842],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":79,"searchDepth":92,"depth":92,"links":1844},[1845,1850,1851],{"id":1222,"depth":92,"text":1223,"children":1846},[1847,1848,1849],{"id":1226,"depth":98,"text":1227},{"id":1237,"depth":98,"text":1238},{"id":1252,"depth":98,"text":1253},{"id":1261,"depth":92,"text":1262},{"id":1775,"depth":92,"text":1776},"2026-09-14","Comparing rate-limiting algorithms to protect your backend against scrapers, credential stuffing, and bot spam with minimal latency overhead.",{},"\u002Fblog\u002Fen\u002Fapi-rate-limiting-redis",{"title":1198,"description":1853},"api-rate-limiting-redis","blog\u002Fen\u002Fapi-rate-limiting-redis",[1192,1860,1861,343,342],"security","redis","KXTsuQOwj895dkbCDObhyO_wOncRKtB2ufJbjc-AUyc",1792236100750]