<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nishchup</title>
    <description>The latest articles on DEV Community by Nishchup (@nishchup_bb539161b3acc994).</description>
    <link>https://dev.to/nishchup_bb539161b3acc994</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3963658%2F94241cd6-bb20-4aee-9077-605ccba0e951.png</url>
      <title>DEV Community: Nishchup</title>
      <link>https://dev.to/nishchup_bb539161b3acc994</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nishchup_bb539161b3acc994"/>
    <language>en</language>
    <item>
      <title>Drishti 1.0: Inside the Crawler Behind Developer's Eye</title>
      <dc:creator>Nishchup</dc:creator>
      <pubDate>Tue, 24 Nov 2026 04:42:50 +0000</pubDate>
      <link>https://dev.to/nishchup_bb539161b3acc994/drishti-10-inside-the-crawler-behind-developers-eye-5494</link>
      <guid>https://dev.to/nishchup_bb539161b3acc994/drishti-10-inside-the-crawler-behind-developers-eye-5494</guid>
      <description>&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nishchup489-afk" rel="noopener noreferrer"&gt;
        nishchup489-afk
      &lt;/a&gt; / &lt;a href="https://github.com/nishchup489-afk/developers_eye" rel="noopener noreferrer"&gt;
        developers_eye
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div&gt;
&lt;a rel="noopener noreferrer" href="https://github.com/nishchup489-afk/developers_eye/assets/homepage.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fnishchup489-afk%2Fdevelopers_eye%2FHEAD%2Fassets%2Fhomepage.png" alt="Developer's Eye home page" width="860"&gt;&lt;/a&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Developer's Eye&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Search built for developers, from the crawler up.&lt;/h3&gt;
&lt;/div&gt;
&lt;p&gt;An open-source search engine for developer docs, built from scratch on PostgreSQL:&lt;br&gt;
crawler, indexer and BM25 ranking, with code-aware search.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye/actions/workflows/ci.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/nishchup489-afk/developers_eye/actions/workflows/ci.yml/badge.svg" alt="CI"&gt;&lt;/a&gt;
&lt;a href="https://github.com/nishchup489-afk/developers_eye/stargazers" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/5f89595d931ed400aa701067cd1aaa33b94fb4226819fcdf55a0ddd6df8a2a3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e697368636875703438392d61666b2f646576656c6f706572735f6579653f7374796c653d666c617426636f6c6f723d663563353432" alt="Stars"&gt;&lt;/a&gt;
&lt;a href="https://github.com/nishchup489-afk/developers_eye/issues" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c358eda7e9bbc6fbf377fe416a7d2fe5556377ef8b96d92a3cdd6873cbdf2de7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e697368636875703438392d61666b2f646576656c6f706572735f6579653f7374796c653d666c6174" alt="Issues"&gt;&lt;/a&gt;
&lt;a href="https://github.com/nishchup489-afk/developers_eye/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/2a59ba041b211bb2313b571ab647d78a4e0a02212303b9e58c94d23a047886e0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e697368636875703438392d61666b2f646576656c6f706572735f6579652f676f6f64253230666972737425323069737375653f7374796c653d666c617426636f6c6f723d373035376666266c6162656c3d676f6f642532306669727374253230697373756573" alt="Good first issues"&gt;&lt;/a&gt;
&lt;a href="https://github.com/nishchup489-afk/developers_eye/CONTRIBUTING.md" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/e30220868442079c9fac1986827563eb55c52395d0f4ad65734a49a4c4bf4153/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d3265613434663f7374796c653d666c6174" alt="PRs welcome"&gt;&lt;/a&gt;
&lt;a href="https://github.com/nishchup489-afk/developers_eye/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/a2e08fedf5131d554d06bf48ca9c58e657c73b2cf2fa0020e999d614afd74b5e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75653f7374796c653d666c6174" alt="License: MIT"&gt;&lt;/a&gt;
&lt;a href="https://discord.gg/jxbRsFj3d" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/fa45a899f907d866b49ede1d75c97ea401ba5a1d2bb1186704016c41927caf26/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d6a6f696e253230746865253230636861742d3538363546323f7374796c653d666c6174266c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465" alt="Discord"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://developers-eye.vercel.app" rel="nofollow noopener noreferrer"&gt;Live demo&lt;/a&gt;&lt;/strong&gt; ·
&lt;strong&gt;&lt;a href="https://discord.gg/jxbRsFj3d" rel="nofollow noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;/strong&gt; ·
&lt;strong&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye#quick-start" rel="noopener noreferrer"&gt;Quick start&lt;/a&gt;&lt;/strong&gt; ·
&lt;strong&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye/setup-guide.md" rel="noopener noreferrer"&gt;Setup guide&lt;/a&gt;&lt;/strong&gt; ·
&lt;strong&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye#architecture" rel="noopener noreferrer"&gt;Architecture&lt;/a&gt;&lt;/strong&gt; ·
&lt;strong&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye/0_tech_docs/README.md" rel="noopener noreferrer"&gt;Why it's built this way&lt;/a&gt;&lt;/strong&gt; ·
&lt;strong&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye#contributing" rel="noopener noreferrer"&gt;Contribute&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Created by &lt;strong&gt;Nish&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://nish-chup-one.vercel.app" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/db773ea6256753bbc16ff38264788eb60ff12ab0b6875f89bfb35207fcf6fb2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f7274666f6c696f2d6e6973682d2d636875702d3131313131313f7374796c653d666f722d7468652d6261646765266c6f676f3d76657263656c266c6f676f436f6c6f723d7768697465" alt="Portfolio"&gt;&lt;/a&gt;
&lt;a href="https://x.com/Nishchup489" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/055e5f42d903f733df2b77468eba58780c3e60c9fd04fa4b193a51b44890f56a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f404e697368636875703438392d3030303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d78266c6f676f436f6c6f723d7768697465" alt="X"&gt;&lt;/a&gt;
&lt;a href="https://www.linkedin.com/in/sadnan-nishthup-7405273a5/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/d718990726aee429b45b5157b4a3428e1efb7206a9aaf452f2628e9fe4bd9a56/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c696e6b6564496e2d5361646e616e2532304e697368746875702d3041363643323f7374796c653d666f722d7468652d6261646765" alt="LinkedIn"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/nishchup489-afk/developers_eye/frontend/content/docs/index.mdx" rel="noopener noreferrer"&gt;Project handbook&lt;/a&gt;&lt;/strong&gt; · Start the frontend and open &lt;code&gt;/docs&lt;/code&gt; to browse or search the guides.&lt;/p&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;What is Developer's Eye?&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Developer's Eye&lt;/strong&gt; is a search engine for technical content. It crawls developer documentation, indexes it, and ranks results with its own BM25 implementation. There is no Elasticsearch, no vector database and no search library underneath: every stage, from the URL frontier to the snippet shown under a result, is code in this repository running on one PostgreSQL database.&lt;/p&gt;
&lt;p&gt;It is also built to be read. Every major decision has a written record, every incident has a post-mortem, and…&lt;/p&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nishchup489-afk/developers_eye" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  What is a crawler, and why do we need one?
&lt;/h2&gt;

&lt;p&gt;When you search something in google it processes that query from billions of pages in its database. Ever wondered who stored those billions of pages? Not google employee manually parse them and add them…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs18o9u7qq0e3tsdcp05x.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs18o9u7qq0e3tsdcp05x.webp" alt="Someone staring at a screen, wondering who stored billions of pages" width="360" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if so then when you make a new website and host it how google find it and already start indexing? Your domain provider informed google? Why they didnt invite duckduckgo or yahoo? If someone make a new website they need to make a new business deal with them? The answer is NO.&lt;/p&gt;

&lt;p&gt;Thats why crawler exists. Its job is to fetch a website which is initially added as seed , find links from those website to other website , visit those websites and keeps going. Just link how a spider traverse its web.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwtw3yjleyr277vi9omtq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwtw3yjleyr277vi9omtq.png" alt="Pages linked together like a spider web, with a crawler moving between them" width="624" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So a crawler basically check source registry find more hyperlinks fetch them safely respect their policy decide weather its worth keeping and hand it to indexer. Indexer helps indexing all documents in database by keywords or lexems like “python” “javascript” which makes the database query a lot cheaper. CHEAPER HOW?&lt;/p&gt;

&lt;p&gt;Imagine someone searched “python async” and the database have 100k of documents. Without indexer database will go find that keyword from one docs repeat it 100k times , sort relevant documents and rank them. But indexer already do this task before , database pressure reduced from 100k query to ~ 1 query ( depends on the query).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw4wf3scbd56jh6o3i32d.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw4wf3scbd56jh6o3i32d.webp" alt="Crawled pages go through the indexer and become a searchable index" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Drishti?
&lt;/h2&gt;

&lt;p&gt;Drishti (দৃষ্টি) means "sight" or "vision" in Bangla and Sanskrit. It is the eye in Developer's Eye. On the wire it identifies itself as &lt;code&gt;DevelopersEyeBot&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Just like other search crawlers like GOOGLE - google bot , Bings - bing bot , Baidu - baiduspider, we have drishti bot.&lt;/p&gt;

&lt;p&gt;The logo was inspired from a gaming character name &lt;code&gt;HSIN&lt;/code&gt; and mostly symbolize fox while the name itself symbolize vision.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faojbsewyotqhhmo0pirm.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faojbsewyotqhhmo0pirm.webp" alt="Drishti Bot logo: a green and white fox" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6q93ibwk1ubdu4wg4d3s.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6q93ibwk1ubdu4wg4d3s.webp" alt="HSIN, the character that inspired the logo" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The whole idea is basically instead of sending a spider we are sending a fox ( a sentinel fox ) [ in v2.0 ] which will not fetch unrelated garbage and will only bring quality documents.&lt;/p&gt;

&lt;p&gt;Drishti 1.0 is a focused crawler. It doesn't try to crawl the whole web. It crawls a curated set of developer sources well, and in local runs it stores about 100,000 documents an hour. This post walks through how it is built, the decisions behind it, and the things that broke along the way.&lt;/p&gt;




&lt;h2&gt;
  
  
  The one rule: PostgreSQL is the whole system
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flqjvttn72lnzlzzkwf65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flqjvttn72lnzlzzkwf65.png" alt="Drishti, the indexer and the search API all talk only to PostgreSQL" width="624" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The design starts from one constraint. Developer's Eye has to be cheap to run and easy for anyone to self-host. The live demo runs on a free-tier Oracle instance. That rules out a separate message queue, a Redis cluster or a coordination service. ( gotta be cheap )&lt;/p&gt;

&lt;p&gt;So Drishti ( the crawler) , the indexer , and the search API are three processes follow one source of truth &lt;code&gt;POSTGRES&lt;/code&gt; and never call each other directly . Besides postgres lots of built in feature it also keeps coordination (leases, politeness) atomic inside single SQL statements.&lt;/p&gt;

&lt;p&gt;The crawler fetech and writes a document in db , indexer notices which documents are new or stale. The API reads the index. Every piece of coordination, from the job queue to per-host rate limits, is a table and a carefully written SQL statement.&lt;/p&gt;

&lt;p&gt;This turns out to be a much stronger MVP foundation than it sounds, as long as you respect a few rules about transactions.&lt;/p&gt;




&lt;h2&gt;
  
  
  The pipeline at a glance
&lt;/h2&gt;

&lt;p&gt;Each URL moves through the same stage&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmhxpqgg86uxiaycyqxpy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmhxpqgg86uxiaycyqxpy.png" alt="Source registry, frontier, scheduler, policy coordinator, pinned fetcher, parser, processor and writer" width="624" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The crawler is asynchronous Python built on &lt;code&gt;asyncio&lt;/code&gt; and HTTPX. Each stage is its own package with its own docs and tests. Every major decision has a written ADR, every outage has an incident report, and every performance claim links to the benchmark that produced it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The frontier is the job queue
&lt;/h2&gt;

&lt;p&gt;There is no RabbitMQ or SQS. The &lt;code&gt;crawl_target&lt;/code&gt; table is the queue (ADR-0004).&lt;/p&gt;

&lt;p&gt;Source registry follows a schema which contains &lt;code&gt;crawl_interval_seconds&lt;/code&gt; , &lt;code&gt;priority&lt;/code&gt; , &lt;code&gt;max_depth&lt;/code&gt; , &lt;code&gt;allowed_hosts&lt;/code&gt; configs. Seed discovery adds the seed URLs as targets and store the record in a database table &lt;code&gt;crawl_target&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F11faml9243f6gubho9bj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F11faml9243f6gubho9bj.png" alt="claim_target() and the scheduler's job queue" width="624" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now schedular check the target from &lt;code&gt;crawl_target&lt;/code&gt; table and claim the target , lease it for next step. BUT a lot interesting things happens in mid.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;claim_target&lt;/code&gt; query uses &lt;code&gt;SELECT … FOR UPDATE SKIP LOCKED&lt;/code&gt; prevents workers from claiming the same url together.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Funjyvlv1fjwvf471qyle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Funjyvlv1fjwvf471qyle.png" alt="SELECT … FOR UPDATE SKIP LOCKED: only one worker gets each row" width="503" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The deadlock
&lt;/h3&gt;

&lt;p&gt;But while applying a more interesting thing happened. DEADLOCK. Basically right now two workers cant hold same target together. But suddenly my crawler started throwing &lt;code&gt;DeadlockDetected&lt;/code&gt; errors. Why?&lt;/p&gt;

&lt;p&gt;Suppose worker 1 locked link X . and waiting for other link Y and worker 2 locked link Y and waiting for other link X , both sides awaits someon to finish their job and unlock the target but nobody unlocks it thinking other is using it. Postgres catches this circle and kills one of the two transactions, so that worker's job fails and the page it fetched is lost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fslqd8bbv1rzwg9lc9h9b.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fslqd8bbv1rzwg9lc9h9b.webp" alt="Two workers each hold one lock and wait for the other's" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq3262x8mbazmpwnh61r1.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq3262x8mbazmpwnh61r1.webp" alt="Before the deadlock: two workers share a task list" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6fje9b0rj43455agiwx6.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6fje9b0rj43455agiwx6.webp" alt="Deadlock: each worker holds the tool the other needs" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How it was fixed
&lt;/h3&gt;

&lt;p&gt;Consistent lock order (commit): in &lt;code&gt;enqueue_targets&lt;/code&gt; , targets are deduplicated by &lt;code&gt;source_id&lt;/code&gt; and &lt;code&gt;normalized_url&lt;/code&gt;. And they are sorted by the same key which matches the unique index before the insert.&lt;/p&gt;

&lt;p&gt;The lock ( &lt;code&gt;pg_advisory_xact_lock&lt;/code&gt; ) is added in sorted &lt;code&gt;source_id&lt;/code&gt; order. A conflicting transaction blocks until the other commits, then its insert becomes a no-op. In simple word, every worker locks links in the same sorted order, so nobody waits in a circle. If it still fails it retries&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F07wy1saz0nelsl93chjj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F07wy1saz0nelsl93chjj.png" alt="The fix: take the tools in the same order, one worker waits its turn" width="471" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing the algorithm in real life
&lt;/h2&gt;

&lt;p&gt;HOW it claims a target , here comes engineering part.&lt;/p&gt;

&lt;p&gt;It uses round-robin algorithm and priority based BFS ( breadth first search ) algorithm.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I came up with this decision
&lt;/h3&gt;

&lt;p&gt;Version 1: priority only.&lt;/p&gt;

&lt;p&gt;Initially crawler had 5 source ( MDN {huge } , &lt;a href="https://python.org" rel="noopener noreferrer"&gt;python.org&lt;/a&gt; , fastapi doc , django doc , rust book ) was supposed to use priority based BFS only but when i inspect the fetching i noticed it was only crawling the first source (MDN) from source registry. No matter how many worker I send all were claiming MDN. The investigation found&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In source config there was priority set up and it wasnt even calculated&lt;/li&gt;
&lt;li&gt;I wasnt using depth to calculate BFS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5p580or1csz0qf1ezwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5p580or1csz0qf1ezwh.png" alt="Source starvation: every worker crowds around MDN while other sources wait" width="481" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The core query was&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nc"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt;          &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;satisfied&lt;/span&gt; &lt;span class="n"&gt;still&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="n"&gt;leased&lt;/span&gt;
  &lt;span class="n"&gt;next_fetch_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;satisfied&lt;/span&gt; &lt;span class="k"&gt;fetch&lt;/span&gt; &lt;span class="kt"&gt;time&lt;/span&gt; &lt;span class="n"&gt;arrived&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;ORDER_BY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nc"&gt;Priority&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;desc&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="o"&gt;|&lt;/span&gt; ‼️&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="n"&gt;so&lt;/span&gt; &lt;span class="n"&gt;skip&lt;/span&gt;
  &lt;span class="n"&gt;next_fetch_at&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;ASC&lt;/span&gt;       &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;same&lt;/span&gt; &lt;span class="k"&gt;fetch&lt;/span&gt; &lt;span class="kt"&gt;time&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;comes&lt;/span&gt; &lt;span class="k"&gt;first&lt;/span&gt;
  &lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;                  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;go&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="k"&gt;first&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AS there was no priority all were going for the first one causing source starvation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fusar2hdmviqvcoj8anh7.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fusar2hdmviqvcoj8anh7.webp" alt="Round robin across sources plus priority-based BFS inside each source" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Version 2: round robin across sources, then priority-based BFS inside the source&lt;/p&gt;

&lt;p&gt;Medicine :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ROUND ROBIN ( give all source a chance to shine regardless of priority )&lt;/li&gt;
&lt;li&gt;use the priority from the source config (a priority calculator basic model exists but is not wired in yet )&lt;/li&gt;
&lt;li&gt;use the calculated depth for BFS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now the whole algorithm is priority based BFS + round robin , in short go by priority first then visit shallowest possible page still give less claimed target a little chance.&lt;/p&gt;

&lt;p&gt;The updated code was :&lt;/p&gt;

&lt;p&gt;Round robin&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhcpc56v4a3gezrf8wmlo.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhcpc56v4a3gezrf8wmlo.webp" alt="Round robin" width="360" height="360"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;TRUE&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;crawl_target&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
      &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'queued'&lt;/span&gt;
      &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next_fetch_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nb"&gt;NOW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last_claimed_at&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt; &lt;span class="k"&gt;NULLS&lt;/span&gt; &lt;span class="k"&gt;FIRST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- WHOEVER IS STARVING&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Priority based BFS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;crawl_target&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;source_id&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'queued'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next_fetch_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nb"&gt;NOW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt;
    &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- famous kid first&lt;/span&gt;
    &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;depth&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;-- BFS go shallowest depth not too deep&lt;/span&gt;
    &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next_fetch_at&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="no"&gt;SKIP&lt;/span&gt; &lt;span class="no"&gt;LOCKED&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;THIS CODES WERE PREVIOUS VERSION, WHILE UPDATING THE QUERY ALSO CHANGED&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Removing a lock made it 8× faster
&lt;/h3&gt;

&lt;p&gt;Before (commit &lt;code&gt;e019701&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;In Version 2 round robin was picking a source and locking it. Then taking the targets from that source and update the &lt;code&gt;last_claimed_at&lt;/code&gt; inside the loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- pick the next source in round-robin order, and LOCK it&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;has&lt;/span&gt; &lt;span class="n"&gt;due&lt;/span&gt; &lt;span class="n"&gt;targets&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last_claimed_at&lt;/span&gt; &lt;span class="k"&gt;NULLS&lt;/span&gt; &lt;span class="k"&gt;FIRST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="no"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="no"&gt;SKIP&lt;/span&gt; &lt;span class="no"&gt;LOCKED&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- then take targets from that source&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;crawl_target&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="no"&gt;SKIP&lt;/span&gt; &lt;span class="no"&gt;LOCKED&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- and update source.last_claimed_at inside the loop&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why that killed throughput&lt;/p&gt;

&lt;p&gt;Take the benchmark case: 1 source with 2,000 due targets and 8 workers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Worker 1 locks the source row and starts claiming.&lt;/li&gt;
&lt;li&gt;Workers 2–8 run the same query. The only source is locked, &lt;code&gt;SKIP LOCKED&lt;/code&gt; skips it, and there’s no other source left, so they return nothing.&lt;/li&gt;
&lt;li&gt;They loop and try again, and get nothing again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So only one worker could claim at a time, even though 2,000 targets were waiting. The other 7 burned transactions on empty claims, about 12,000 of them, and that wasted work also slowed the worker that was claiming. More workers meant more empty round-trips, which is why 8 workers (66–70/s) were slower than 1 (136–143/s).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the source order without locking it.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_enabled&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;has&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;due&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last_claimed_at&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt; &lt;span class="k"&gt;NULLS&lt;/span&gt; &lt;span class="k"&gt;FIRST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;-- whoever is starving&lt;/span&gt;
         &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                                &lt;span class="c1"&gt;-- no FOR UPDATE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every worker gets the same list, and nobody is blocked.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Rotate through sources in memory. The ids go into a queue. Take the front source, claim one URL from it, then put it at the back of the line: MDN → python → fastapi → MDN → … A source with nothing left drops out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lock only the URL.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;crawl_target&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;source_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'queued'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;next_fetch_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;-- famous kid first&lt;/span&gt;
         &lt;span class="n"&gt;depth&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;            &lt;span class="c1"&gt;-- BFS: shallowest first&lt;/span&gt;
         &lt;span class="n"&gt;next_fetch_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="no"&gt;SKIP&lt;/span&gt; &lt;span class="no"&gt;LOCKED&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;-- busy URL? take the next one&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The worker leases that row and calls &lt;code&gt;flush()&lt;/code&gt; right away. &lt;code&gt;SKIP LOCKED&lt;/code&gt; only skips rows locked by other transactions, so without the flush the same worker could grab the URL it had just taken.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Record the turns once, at the end, in sorted order.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;last_claimed_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;GREATEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;last_claimed_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;claimed_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;source_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;-- run for each source, ascending id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Updating in id order is the same trick that fixed the deadlock: everyone takes locks in the same order, so no cycle can form. &lt;code&gt;GREATEST&lt;/code&gt; stops a late commit from moving a source’s turn backwards.&lt;/p&gt;

&lt;p&gt;Now 8 workers on one source each take a different URL, in parallel:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7iyc1tjevo6197js0v4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7iyc1tjevo6197js0v4l.png" alt="Lock the source and one worker works. Lock the URL and all eight do." width="624" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Worker&lt;/th&gt;
&lt;th&gt;Source list&lt;/th&gt;
&lt;th&gt;URL claimed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;W1&lt;/td&gt;
&lt;td&gt;MDN&lt;/td&gt;
&lt;td&gt;#1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;W2&lt;/td&gt;
&lt;td&gt;MDN&lt;/td&gt;
&lt;td&gt;#1 busy → #2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;W3&lt;/td&gt;
&lt;td&gt;MDN&lt;/td&gt;
&lt;td&gt;#1, #2 busy → #3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;…&lt;/td&gt;
&lt;td&gt;…&lt;/td&gt;
&lt;td&gt;…&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;W8&lt;/td&gt;
&lt;td&gt;MDN&lt;/td&gt;
&lt;td&gt;#8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The numbers, from EXP-0001 (1 source, 2,000 URLs):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workers&lt;/th&gt;
&lt;th&gt;With source lock&lt;/th&gt;
&lt;th&gt;Without source lock&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;136–143 targets/s&lt;/td&gt;
&lt;td&gt;174–185 targets/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;92–99 targets/s (≈6,500 empty claims)&lt;/td&gt;
&lt;td&gt;478–485 targets/s (0 empty claims)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;66–70 targets/s (≈12,000 empty claims)&lt;/td&gt;
&lt;td&gt;563–580 targets/s (≈0 empty claims)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With the lock, adding workers made things slower. They spent their time claiming nothing while work sat in the queue. Dropping the lock and relying on target-level &lt;code&gt;SKIP LOCKED&lt;/code&gt; fixed it, at the cost of fairness that is best-effort rather than strict.&lt;/p&gt;

&lt;h2&gt;
  
  
  If a target fails to crawl, when is it retried?
&lt;/h2&gt;

&lt;p&gt;Other interesting part. What if a crawl attempt is failed? Thats will not automatically fall into dark hole , it will just be rescheduled for next crawl. But not immediately, it follows a series formula&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Delay = min( base delay seconds x ( 2^(n-1) ) , cap )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose we set a cap of = 3600 seconds or 1 hr and Base delay seconds = 60s, N = attempt. Suppose target A failed firsttime , its next schedule will be within 60 sec , then 120 sec , then 240 sec , 480 sec, 960 sec , 1920 sec, 3600 sec , 3600 sec , 3600 sec&lt;/p&gt;

&lt;p&gt;It goes like : 1 → 2 → 4 → 8 → 16 → 32 → cap → cap → cap&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqjp9i8swci2emuflkmej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqjp9i8swci2emuflkmej.png" alt="Exponential backoff: 60 s, 120 s, 240 s … capped at 1 hour" width="624" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The 7 security gates
&lt;/h2&gt;

&lt;p&gt;Claiming a URL doesn't mean we fetch it. Every hop has to pass the checkpoint first: allowed host? safe IP (no sneaky localhost)? robots.txt says ok? host not busy? ALL YES → fetch. Unsafe → DENY. Temporary issue → DEFER, try later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fucwnx9tzvtgsky1lnpms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fucwnx9tzvtgsky1lnpms.png" alt="Security first: every URL is checked before a single byte is sent" width="483" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Host policy: The syntax is okay , is target in &lt;code&gt;allowed_hosts&lt;/code&gt; list? Any weird character like &lt;code&gt;user:pass@&lt;/code&gt; ? if passed YES. not DENY.&lt;/li&gt;
&lt;li&gt;DNS policy: The resolved host in host policy’s IP must be public. ocalhost, private network or cloud metadata (&lt;code&gt;169.254.169.254&lt;/code&gt;)? DENY. we connect ONLY to the IPs we just checked, so DNS can’t switch us to localhost midway (DNS rebinding).&lt;/li&gt;
&lt;li&gt;Robots policy: The urls official allow list robots.txt allows us to crawl this site? No = DENY, robots.txt down = DEFER, no robots.txt = allowed&lt;/li&gt;
&lt;li&gt;Politeness policy: one request per host at a time with a gap in between, shared by ALL workers. Got a 429/503? The whole crawler backs off.&lt;/li&gt;
&lt;li&gt;One bounded request: a single GET, 15 s timeout, 2 MB max, no auto redirects, no hidden retries.&lt;/li&gt;
&lt;li&gt;Redirect policy: 301/302/303/307/308: every redirect is a brand-new URL that runs the whole checklist again (max 5 hops, no https → http downgrade).&lt;/li&gt;
&lt;li&gt;Response status: 429/5xx → DEFER and retry later. Anything else → hand it to the parser.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The politeness fix: ~120 → ~4,000 documents/minute (on my local crawl)
&lt;/h2&gt;

&lt;p&gt;In commit &lt;code&gt;800ab2b&lt;/code&gt; we introduced shared politeness. What is politeness? We explained it before, it means dont exhaust a single host too much or it might rate limit you. Thats why every host have a &lt;code&gt;min_interval_seconds&lt;/code&gt; = default 2s. Some sites set their own delay in robots.txt with a &lt;code&gt;Crawl-delay:&lt;/code&gt; line, but Drishti ignores it and uses a hand-written list of longer gaps instead&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faip10e1yk9b9h0qcgtzb.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faip10e1yk9b9h0qcgtzb.webp" alt="Politeness: don't keep messaging someone who hasn't answered yet" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A worker grabbed a URL without checking whether that website was free.&lt;/li&gt;
&lt;li&gt;If the website had just been visited, the worker sat and waited for the 2-second gap, holding its slot and doing nothing.&lt;/li&gt;
&lt;li&gt;Lots of workers ended up waiting on busy websites while other websites had nobody working on them.&lt;/li&gt;
&lt;li&gt;Adding more terminals (processes) didn’t make it faster and polite. Each terminal ignored the others, they were tracking the 2 seconds with their own memory, so they hit the same website together.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7p8mko6orpqaj86jwzsj.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7p8mko6orpqaj86jwzsj.webp" alt="Workers standing around because the tools they picked are still busy" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Workers only grab URLs from websites that are free right now. This is the change that made it fast: no more waiting, so every worker is always fetching something.&lt;/li&gt;
&lt;li&gt;All terminals share one rulebook in Postgres. This made it safe to run many terminals at once. More terminals means more speed, and the sites still aren’t overloaded. This part is called Shared politeness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa24d5i0kfjx39qqmd6rl.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa24d5i0kfjx39qqmd6rl.webp" alt="Shared politeness: one rulebook in Postgres, workers only take tools that are ready" width="799" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  More workers is not more speed
&lt;/h2&gt;

&lt;p&gt;I thought: slow crawler? Just add more workers. 8 → 16 → 32 → 64. The speed didn’t move.&lt;/p&gt;

&lt;p&gt;Here’s my own benchmark (64 fake websites):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workers&lt;/th&gt;
&lt;th&gt;2&lt;/th&gt;
&lt;th&gt;8&lt;/th&gt;
&lt;th&gt;16&lt;/th&gt;
&lt;th&gt;32&lt;/th&gt;
&lt;th&gt;64&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;pages/s&lt;/td&gt;
&lt;td&gt;5.1&lt;/td&gt;
&lt;td&gt;14.0&lt;/td&gt;
&lt;td&gt;14.8&lt;/td&gt;
&lt;td&gt;13.8&lt;/td&gt;
&lt;td&gt;12.2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;After 16, more workers made it slower. Why?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc0gc41hy4fegd1si637a.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc0gc41hy4fegd1si637a.webp" alt="Adding 100 more workers, and most of them have nothing to do" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The crawl delay
&lt;/h3&gt;

&lt;p&gt;Drishti waits 2 seconds between two requests to the same website. That’s the crawl delay, the polite thing to do. So every website can give us about 1 page every ~2.5 seconds, no matter what.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;max speed ≈ number of websites ÷ 2.5 s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;5 websites (my first registry): 5 ÷ 2.5 = ~2 pages/s = ~120 pages/min&lt;/li&gt;
&lt;li&gt;332 websites (now): 332 ÷ 2.5 = ~130 pages/s = ~8,000 pages/min max&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With 5 websites, 32 workers were just standing in line for the same 5 sites. Speed comes from more websites, not more workers.&lt;/p&gt;

&lt;h3&gt;
  
  
  The knobs I can turn
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--concurrency&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Slots: how many URLs one terminal works on at once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--batch-size&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;How many URLs it grabs per claim (really &lt;code&gt;min(batch, concurrency)&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--min-interval-seconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2.0&lt;/td&gt;
&lt;td&gt;Crawl delay: gap between requests to the same website&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--lease-seconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;300&lt;/td&gt;
&lt;td&gt;How long a grabbed URL is “mine” before it’s given back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--job-timeout-seconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;240&lt;/td&gt;
&lt;td&gt;Max time for one URL (always 15 s+ under the lease)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;DB_POOL_SIZE&lt;/code&gt; / &lt;code&gt;DB_MAX_OVERFLOW&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;2 / 2&lt;/td&gt;
&lt;td&gt;Database connections per terminal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The database limit
&lt;/h3&gt;

&lt;p&gt;Every terminal opens its own database connections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pools (&lt;code&gt;DB_POOL_SIZE&lt;/code&gt;): How many database connections terminal keeps open. Default 2. If worker needs it , it uses it and returns back.&lt;/li&gt;
&lt;li&gt;Overflow (&lt;code&gt;DB_MAX_OVERFLOW&lt;/code&gt;): The number of extra connections a terminal may open temporarily when all pool connections are busy. When they’re no longer needed, they’re closed again. Default 2&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;max_connections&lt;/code&gt;: The total number of connections Postgres accepts at once, from every program combined. It’s set in &lt;code&gt;postgresql.conf&lt;/code&gt;. Once it’s full, any new connection is refused with “too many clients”.&lt;/li&gt;
&lt;li&gt;API: The search backend, the FastAPI server the website talks to. Every search a user makes borrows a database connection.&lt;/li&gt;
&lt;li&gt;Indexer: The indexer worker, the process that turns new documents into searchable index rows (&lt;code&gt;search_index&lt;/code&gt;). Each indexer process uses the default 2 + 2 = 4 connections.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terminals × (pool + overflow) + API + indexer ≤ max_connections
20 × (2 + 2) + 10 + ...                       ≈ 96 of 100   (benchmark machine)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Too many terminals and Postgres runs out of connections. (It happened, back before shared politeness.)&lt;/p&gt;

&lt;h3&gt;
  
  
  So what actually made it fast?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp8cy8ob4qvm82f9qwntu.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp8cy8ob4qvm82f9qwntu.webp" alt="The fix list: add more sources, tighten the rules, only take free work" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;More websites. 5 → 332 hosts raised the ceiling.&lt;/li&gt;
&lt;li&gt;Host-aware claims. Workers only grab URLs from websites that are free right now, so nobody waits.&lt;/li&gt;
&lt;li&gt;Shared politeness. All terminals follow ONE crawl delay through Postgres, so adding terminals doesn’t make Drishti rude.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Result on my local crawl: ~120 → ~4,000 pages/min.&lt;/p&gt;

&lt;h2&gt;
  
  
  From bytes to documents
&lt;/h2&gt;

&lt;p&gt;Drishti ingests four formats through bounded adapters: HTML pages, XML sitemaps, RSS/Atom feeds and JSON APIs. Responses are size-capped, and typed failures let the worker tell unsafe requests, retryable errors and oversized content apart.&lt;/p&gt;

&lt;p&gt;Processing is pure and does no I/O (ADR-0019). Content is normalized, classified with explicit rules, and fingerprinted with SHA-256 , every single change of document update the sha code thats how documents change are detected. The writer owns every persistence decision:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exact duplicates are caught by fingerprint.&lt;/li&gt;
&lt;li&gt;A feed record never replaces a page that was actually fetched (ADR-0050).&lt;/li&gt;
&lt;li&gt;A new content source that wants to replace an existing document has to provide at least as much body text (ADR-0052). This came from a real incident where thin pages and competing sources overwrote good content.&lt;/li&gt;
&lt;li&gt;Pages that disappear are marked unavailable instead of deleted (ADR-0011).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Drishti 1.0 by the numbers
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Local crawl throughput&lt;/td&gt;
&lt;td&gt;~100,000 documents/hour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claim throughput, 8 workers on one source&lt;/td&gt;
&lt;td&gt;563–580 targets/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Politeness-safe fetch rate, 4 processes × 200 hosts&lt;/td&gt;
&lt;td&gt;204.5 requests/s, 0 gap violations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Single-process ceiling (local benchmark)&lt;/td&gt;
&lt;td&gt;~60 requests/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indexing with 4 outbox shards&lt;/td&gt;
&lt;td&gt;581 documents/s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are local benchmarks on developer hardware with synthetic hosts where noted. They are not production capacity claims. The hosted demo deliberately runs one crawler worker on a free tier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known limits
&lt;/h2&gt;

&lt;p&gt;Drishti 1.0 is honest about what it doesn't do yet. The limits fall into three groups.&lt;/p&gt;

&lt;h3&gt;
  
  
  Speed
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Websites set the ceiling, not workers. With a 2-second crawl delay per host, the crawler can't go faster than about hosts ÷ 2.5 s. Five hosts cap it near 120 pages a minute, and 332 hosts near 8,000.&lt;/li&gt;
&lt;li&gt;One process tops out around 60 requests/s. in local benchmarks, likely Python's single event loop, so scaling past that means more processes, not more slots.&lt;/li&gt;
&lt;li&gt;Postgres connections are finite. Each crawler process uses up to 4 (pool 2 + overflow 2), and every process shares one &lt;code&gt;max_connections&lt;/code&gt; budget.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What it fetches
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;No conditional recrawl. It doesn't send &lt;code&gt;ETag&lt;/code&gt; or &lt;code&gt;If-Modified-Since&lt;/code&gt;, so every recrawl downloads the full page. This was a deliberate deferral (EXP-0015) until validator ownership across redirects and content producers is specified.&lt;/li&gt;
&lt;li&gt;Exact duplicates only. SHA-256 catches identical copies. Mirrored or versioned docs need near-duplicate detection such as SimHash or MinHash.&lt;/li&gt;
&lt;li&gt;No JavaScript rendering, so single-page-app documentation sites don't crawl fully.&lt;/li&gt;
&lt;li&gt;No WARC output, so its crawls can't yet be reused by other archiving tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Design
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;One machine, one database. Nobody else can contribute crawling capacity.&lt;/li&gt;
&lt;li&gt;Not installable on its own. Drishti imports the Developer's Eye backend, so it can't run without the whole search engine.&lt;/li&gt;
&lt;li&gt;One open incident. Vocabulary lock contention (INC-0032) can still stall document finalization.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next: Drishti 2.0
&lt;/h2&gt;

&lt;p&gt;Drishti 2.0 is an evolution of this crawler, not a rewrite. The plan:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Its own repository, still connected to Developer's Eye, so contributors can run the crawler without the whole search engine.&lt;/li&gt;
&lt;li&gt;A dedicated advanced control panel for watching and steering crawls.&lt;/li&gt;
&lt;li&gt;Node-based, multi-user crawling into a shared database, so contributors can lend machines to the crawl.&lt;/li&gt;
&lt;li&gt;Updated crawl policies.&lt;/li&gt;
&lt;li&gt;Experimental &lt;code&gt;.onion&lt;/code&gt; support, with those links opening only in Tor Browser.&lt;/li&gt;
&lt;li&gt;A better quality model that keeps only documents worth indexing.&lt;/li&gt;
&lt;li&gt;A sustained target of 10 million pages a week, measured locally before it is promised anywhere else.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Get involved
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxa0qrbe22xjg1inv2eyd.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxa0qrbe22xjg1inv2eyd.webp" alt="Why are you not contributing yet? Don't forget to leave a star." width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Drishti and Developer's Eye are MIT-licensed and built in public. If you're interested in crawlers, search, compression or distributed systems, there is real work here and the reasoning behind every decision is written down.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code: &lt;a href="https://github.com/nishchup489-afk/developers_eye" rel="noopener noreferrer"&gt;github.com/nishchup489-afk/developers_eye&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live demo: &lt;a href="https://developers-eye.vercel.app" rel="noopener noreferrer"&gt;developers-eye.vercel.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Community: Discord&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start with the crawler's tech docs in &lt;code&gt;0_tech_docs/crawler/&lt;/code&gt;. Every ADR, incident and experiment mentioned in this post is there.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>ai</category>
      <category>postgres</category>
    </item>
    <item>
      <title>I knew a lot. I'd built a lot. And I had nothing to show.</title>
      <dc:creator>Nishchup</dc:creator>
      <pubDate>Mon, 22 Jun 2026 02:43:29 +0000</pubDate>
      <link>https://dev.to/nishchup_bb539161b3acc994/i-knew-a-lot-id-built-a-lot-and-i-had-nothing-to-show-3i0</link>
      <guid>https://dev.to/nishchup_bb539161b3acc994/i-knew-a-lot-id-built-a-lot-and-i-had-nothing-to-show-3i0</guid>
      <description>&lt;p&gt;When after some self learned coding knowledge, I sat down to put together an application and hit a wall I didn't expect.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonj9hg4o1galmc3xri6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonj9hg4o1galmc3xri6u.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd been coding non-stop for over a year. I knew Python, React, Next.js, FastAPI, Postgres. I'd touched authentication, APIs, databases, deployment. I'd shipped things. By any honest measure, I'd learned a &lt;em&gt;lot&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So I opened a blank doc to list my projects, and froze.&lt;/p&gt;

&lt;p&gt;Wait — I made so much. I know so much. Then why is there nothing here to show?&lt;/p&gt;

&lt;p&gt;That question is the entire reason DevManiac exists. But to explain why it hit so hard, I have to walk you back through how I got there. Because the gap between "I know a lot" and "I have something to show" didn't appear by accident. I built it, brick by brick, over a year of doing everything in the wrong order.&lt;/p&gt;

&lt;h2&gt;
  
  
  The heartbreak that started it
&lt;/h2&gt;

&lt;p&gt;I started where a lot of people start: HTML, CSS, JavaScript. Then login pages. I was proud of my login pages.&lt;/p&gt;

&lt;p&gt;Then ChatGPT casually generated a better UI than mine in about four seconds, and broke my heart.&lt;/p&gt;

&lt;p&gt;I was completely new. No knowledge of the stack landscape, no dev community, no mentor, nothing. Just some HTML, some CSS, and VS Code. So I made a decision that felt logical at the time and quietly shaped the next year of my life:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Everybody just wants the result. Nobody cares if it's AI-coded or hand-coded.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So I started vibe coding. Static projects first. Then I got ambitious.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chatterlite, or: how to over-engineer your way into 100,000 errors
&lt;/h2&gt;

&lt;p&gt;There was a protest going on in my country. People were nervous about using WhatsApp, so I decided I'd build a secure local messaging app. I called it Chatterlite.&lt;/p&gt;

&lt;p&gt;Here's my actual skill level at that moment: I didn't know stack names. I didn't know what "frontend" and "backend" meant. I didn't know basic terminal commands. My entire workflow was copy-pasting between the ChatGPT app and VS Code.&lt;/p&gt;

&lt;p&gt;And weirdly — it started working. Everything ran fine on localhost. Which was exactly the problem, because now my brain had room to flood with over-engineering.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why a web app? Why not mobile?&lt;/em&gt; Okay, let's use Kotlin. &lt;em&gt;No, I need both platforms&lt;/em&gt; — let's use Flutter. So I initialized Flutter inside a React project. I still don't fully know how I managed that. Result: 100,000 errors.&lt;/p&gt;

&lt;p&gt;I sat there arguing with ChatGPT. &lt;em&gt;Why so many errors, just solve them.&lt;/em&gt; Somehow I deleted Flutter. Somehow, following instructions I didn't understand, I set up Firebase, set up Cloudinary, installed Node.js.&lt;/p&gt;

&lt;p&gt;It was genuinely stressful. I was literally sweating at my desk. But vibe coding hands you dopamine in a steady drip, so I didn't want to get up.&lt;/p&gt;

&lt;p&gt;Then I discovered GitHub Copilot, which was even &lt;em&gt;better&lt;/em&gt; for vibe coding, and the real fun began. Coding got faster. The chat actually worked. I bolted on authentication, then third-party APIs, then a chatbot, an image generator, a recipe generator — whatever I could plug in. There were node modules everywhere. Copilot would say "cd into your project" and I'd think &lt;em&gt;just do it for me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This went on for a month. It never ended. A styling bug here, a logic bug there, forever. Eventually I gave up on fixing and decided to just host it.&lt;/p&gt;

&lt;p&gt;That's when reality showed up. No matter what I did, something broke. Just a 404, over and over. After a full week of frustration, I quit.&lt;/p&gt;

&lt;p&gt;I'd wasted a lot of time. But — and this matters — I had also, accidentally, learned something.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first time I actually shipped
&lt;/h2&gt;

&lt;p&gt;After Chatterlite, I decided to learn properly. I started Python. The plan was a clean straight line:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Python → NumPy/Pandas → data analysis → ML → DL → AI&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While learning Tkinter, I wanted to share a project with someone, and a GUI app makes that hard. So I went looking for an alternative and found Flask — HTML, CSS, the works. I learned it, built a few Python projects on it, and for the first time in my life I hosted a functional web app that actually worked.&lt;/p&gt;

&lt;p&gt;Then I realized Flask was a backend framework. Which meant if I sharpened my JavaScript and learned some React, I could build real websites.&lt;/p&gt;

&lt;p&gt;So I revised the roadmap with ChatGPT. (You already know how this goes — ChatGPT agrees with whatever you say to keep you happy.) The new plan:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;web dev → data analysis → ML → AI&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I learned React. Flask. Postgres.&lt;/p&gt;

&lt;h2&gt;
  
  
  NeuraAcademy, and the week that killed my momentum
&lt;/h2&gt;

&lt;p&gt;My next real project was NeuraAcademy — basically a Coursera clone. And early on, I was coding &lt;em&gt;well&lt;/em&gt;. I got two services talking to each other over an API. I learned what frontend/backend architecture actually meant. I felt like I was leveling up for real.&lt;/p&gt;

&lt;p&gt;Then I made the mistake that I now recognize as my signature mistake: I spent more than a week building authentication from scratch.&lt;/p&gt;

&lt;p&gt;A week. On auth. That week drained my motivation completely. Then instead of shipping a minimal version, I started over-engineering the plan. And out of pure frustration, I slid right back into vibe coding — except this time I had real knowledge, so it felt justified.&lt;/p&gt;

&lt;p&gt;I finished it. Somehow. I shipped it. The only thing I couldn't get working in production was — of course — the authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting better, quietly
&lt;/h2&gt;

&lt;p&gt;After that I learned Next.js and FastAPI, which became my main stack. I built CivicFlow for a hackathon — an AI-powered roadmap to help immigrants navigate the problems I was facing myself. I work at a café, so when something annoyed me there, I built a management system for it, frontend and backend. With every one of these I got a little more comfortable with full-stack work.&lt;/p&gt;

&lt;p&gt;But underneath all of it, two things were missing the whole time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A proper guideline. Some structure to learn against.&lt;/li&gt;
&lt;li&gt;Actual deliberate practice, instead of dopamine-chasing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's the gap that finally caught up with me in that internship doc. A year of motion. Real skills, genuinely earned. And no clean, visible artifact that said &lt;em&gt;here is what I can do.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So I built the thing I needed
&lt;/h2&gt;

&lt;p&gt;DevManiac is a platform where your build history &lt;em&gt;is&lt;/em&gt; your portfolio.&lt;/p&gt;

&lt;p&gt;You upload finished projects. You also post &lt;strong&gt;live projects&lt;/strong&gt; — what you're building right now, in the open. People can comment. And here's the part I care about most: you get a &lt;strong&gt;dev score from your work, not from your stack.&lt;/strong&gt; Not from how many trendy tools you can name. From what you actually shipped.&lt;/p&gt;

&lt;p&gt;Here's where I'm taking it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A terminal CLI.&lt;/strong&gt; Like &lt;code&gt;git push&lt;/code&gt;, but for your build journal. After a coding session you just run &lt;code&gt;devmaniac push -m "topic" -p "problem" -s "solution"&lt;/code&gt; and your day is logged. No switching to an app, no breaking flow. Write it manually, stay where you are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real repo analysis.&lt;/strong&gt; Not everything counts as a finished project. A website needs a live URL and a clear README to qualify. Then extra signals earn extra score — a demo video, a pitch deck, real user analytics, a custom domain. Proof, not vibes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A developer hub.&lt;/strong&gt; Everything a developer needs in one place — the way LinkedIn, GitHub, and a résumé builder &lt;em&gt;should&lt;/em&gt; have been combined. Hackathons, events, guidance, the works.&lt;/p&gt;

&lt;p&gt;There's only one goal behind all of it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The way vibe coding gives you dopamine, your &lt;em&gt;structured&lt;/em&gt; work should give you a long-term result — and turn you into an actual DevManiac.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because I learned the expensive way that motion isn't progress, and a year of effort can leave you with a blank portfolio doc and a hard question.&lt;/p&gt;

&lt;p&gt;I built the answer to that question. It's called DevManiac, and I'd love for you to try it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>I Built Devmaniac: A Build-in-Public Platform for Developers</title>
      <dc:creator>Nishchup</dc:creator>
      <pubDate>Mon, 15 Jun 2026 22:29:12 +0000</pubDate>
      <link>https://dev.to/nishchup_bb539161b3acc994/i-built-devmaniac-a-build-in-public-platform-for-developers-2o5l</link>
      <guid>https://dev.to/nishchup_bb539161b3acc994/i-built-devmaniac-a-build-in-public-platform-for-developers-2o5l</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjtp7gcnxet94bezigxj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjtp7gcnxet94bezigxj.jpg" alt=" " width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Link Preview : &lt;a href="https://devmaniac.com" rel="noopener noreferrer"&gt;https://devmaniac.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most developer portfolios show the final result.&lt;/p&gt;

&lt;p&gt;A polished project card.&lt;br&gt;
A GitHub link.&lt;br&gt;
Maybe a live demo.&lt;br&gt;
Maybe a screenshot.&lt;/p&gt;

&lt;p&gt;But they usually miss the most important part:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the developer actually built it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is the problem I wanted to solve with &lt;strong&gt;Devmaniac&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Devmaniac is a platform where developers can share finished projects, track live projects, write build logs, and turn their progress into proof of work.&lt;/p&gt;

&lt;p&gt;Instead of only saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Here is what I built.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Devmaniac helps developers show:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Here is how I think, how I debug, how I improve, and how I ship.”&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Why I Built It
&lt;/h2&gt;

&lt;p&gt;I’m a self-taught developer based in Brooklyn, NYC.&lt;/p&gt;

&lt;p&gt;I moved to the US in late 2025, and since then I’ve been learning, working, and building around a full-time job.&lt;/p&gt;

&lt;p&gt;Like many self-taught developers, I had the same problem:&lt;/p&gt;

&lt;p&gt;I was learning a lot.&lt;/p&gt;

&lt;p&gt;Python.&lt;br&gt;
JavaScript.&lt;br&gt;
React.&lt;br&gt;
Next.js.&lt;br&gt;
FastAPI.&lt;br&gt;
PostgreSQL.&lt;br&gt;
Authentication.&lt;br&gt;
Deployment.&lt;br&gt;
APIs.&lt;br&gt;
Backend architecture.&lt;/p&gt;

&lt;p&gt;But learning alone does not prove much.&lt;/p&gt;

&lt;p&gt;Tutorials do not prove much.&lt;/p&gt;

&lt;p&gt;Even finished projects sometimes do not tell the full story.&lt;/p&gt;

&lt;p&gt;A hiring manager, collaborator, or founder does not only want to know that you can copy a clean final result. They want to know whether you can stay consistent, solve problems, make decisions, and keep shipping when the project becomes messy.&lt;/p&gt;

&lt;p&gt;That is where the idea for Devmaniac came from.&lt;/p&gt;

&lt;p&gt;I wanted to build something for developers who are still in the building phase — not just people with perfect finished apps.&lt;/p&gt;


&lt;h2&gt;
  
  
  What Devmaniac Does
&lt;/h2&gt;

&lt;p&gt;Devmaniac currently has two main types of projects:&lt;/p&gt;
&lt;h3&gt;
  
  
  Finished Projects
&lt;/h3&gt;

&lt;p&gt;These are completed projects that developers can showcase with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;project title&lt;/li&gt;
&lt;li&gt;description&lt;/li&gt;
&lt;li&gt;tech stack&lt;/li&gt;
&lt;li&gt;GitHub link&lt;/li&gt;
&lt;li&gt;live demo link&lt;/li&gt;
&lt;li&gt;images or thumbnails&lt;/li&gt;
&lt;li&gt;stars, bookmarks, comments, and views&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the traditional portfolio side.&lt;/p&gt;

&lt;p&gt;But Devmaniac is not only about finished work.&lt;/p&gt;


&lt;h3&gt;
  
  
  Live Projects
&lt;/h3&gt;

&lt;p&gt;Live Projects are the main idea.&lt;/p&gt;

&lt;p&gt;A Live Project is an ongoing build that developers can update over time.&lt;/p&gt;

&lt;p&gt;You can share:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what you are building&lt;/li&gt;
&lt;li&gt;your goal&lt;/li&gt;
&lt;li&gt;current status&lt;/li&gt;
&lt;li&gt;progress percentage&lt;/li&gt;
&lt;li&gt;tech stack&lt;/li&gt;
&lt;li&gt;GitHub/live links&lt;/li&gt;
&lt;li&gt;build journals&lt;/li&gt;
&lt;li&gt;milestones&lt;/li&gt;
&lt;li&gt;bugs&lt;/li&gt;
&lt;li&gt;deployment updates&lt;/li&gt;
&lt;li&gt;architecture decisions&lt;/li&gt;
&lt;li&gt;failures and lessons&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your build history becomes part of your portfolio.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because sometimes the most valuable proof is not just the final app. It is the trail of decisions, problems, fixes, and progress behind it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Why Build History Matters
&lt;/h2&gt;

&lt;p&gt;A finished project can hide a lot.&lt;/p&gt;

&lt;p&gt;It does not show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how long it took&lt;/li&gt;
&lt;li&gt;what broke&lt;/li&gt;
&lt;li&gt;what you had to redesign&lt;/li&gt;
&lt;li&gt;what tradeoffs you made&lt;/li&gt;
&lt;li&gt;whether you understood the architecture&lt;/li&gt;
&lt;li&gt;whether you actually shipped consistently&lt;/li&gt;
&lt;li&gt;whether you gave up when things got hard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build logs show those things.&lt;/p&gt;

&lt;p&gt;If someone is hiring a developer, working with a collaborator, or checking whether a person can really build, the process matters.&lt;/p&gt;

&lt;p&gt;A developer who writes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Day 4: Refactored the auth flow because my first design caused duplicated user records.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;is showing more signal than someone who only posts:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Built a full-stack app.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the gap Devmaniac is trying to fill.&lt;/p&gt;


&lt;h2&gt;
  
  
  Current MVP Features
&lt;/h2&gt;

&lt;p&gt;Devmaniac is still early, but the MVP already includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;user profiles&lt;/li&gt;
&lt;li&gt;project posting&lt;/li&gt;
&lt;li&gt;live project tracking&lt;/li&gt;
&lt;li&gt;build journals&lt;/li&gt;
&lt;li&gt;tech stack display&lt;/li&gt;
&lt;li&gt;comments&lt;/li&gt;
&lt;li&gt;stars&lt;/li&gt;
&lt;li&gt;bookmarks&lt;/li&gt;
&lt;li&gt;views&lt;/li&gt;
&lt;li&gt;onboarding&lt;/li&gt;
&lt;li&gt;profile editing&lt;/li&gt;
&lt;li&gt;feedback and support pages&lt;/li&gt;
&lt;li&gt;admin dashboard&lt;/li&gt;
&lt;li&gt;app notices&lt;/li&gt;
&lt;li&gt;authentication&lt;/li&gt;
&lt;li&gt;image uploads&lt;/li&gt;
&lt;li&gt;production deployment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The platform is built to be useful now, but it is still far from the final vision.&lt;/p&gt;


&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;p&gt;For the frontend, I used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;li&gt;Clerk authentication&lt;/li&gt;
&lt;li&gt;GSAP for animations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the backend, I used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FastAPI&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;SQLAlchemy async&lt;/li&gt;
&lt;li&gt;Pydantic&lt;/li&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;Neon&lt;/li&gt;
&lt;li&gt;Render&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For deployment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vercel for the frontend&lt;/li&gt;
&lt;li&gt;Render for the backend&lt;/li&gt;
&lt;li&gt;Neon for the database&lt;/li&gt;
&lt;li&gt;Cloudinary for media&lt;/li&gt;
&lt;li&gt;Cloudflare for DNS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I chose a traditional REST API architecture because FastAPI is the main backend source of truth.&lt;/p&gt;

&lt;p&gt;The flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Next.js frontend → FastAPI REST API → PostgreSQL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I considered the modern Next.js Server Actions approach, but for this project REST made more sense.&lt;/p&gt;

&lt;p&gt;I wanted the backend to stay independent so that Devmaniac can support future clients like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mobile apps&lt;/li&gt;
&lt;li&gt;public APIs&lt;/li&gt;
&lt;li&gt;CLI tools&lt;/li&gt;
&lt;li&gt;AI integrations&lt;/li&gt;
&lt;li&gt;separate admin tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Server Actions are great when Next.js owns the backend, but for Devmaniac, FastAPI is the core backend.&lt;/p&gt;




&lt;h2&gt;
  
  
  Some Problems I Had to Solve
&lt;/h2&gt;

&lt;p&gt;Building Devmaniac was not just “make a CRUD app.”&lt;/p&gt;

&lt;p&gt;A few real problems came up:&lt;/p&gt;

&lt;h3&gt;
  
  
  Authentication and User Sync
&lt;/h3&gt;

&lt;p&gt;I used Clerk for authentication, but my backend also needed its own user records.&lt;/p&gt;

&lt;p&gt;That meant syncing Clerk users into PostgreSQL and making sure each authenticated user mapped correctly to an internal user profile.&lt;/p&gt;

&lt;p&gt;This sounds simple until you deal with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;duplicated emails&lt;/li&gt;
&lt;li&gt;missing usernames&lt;/li&gt;
&lt;li&gt;onboarding state&lt;/li&gt;
&lt;li&gt;profile updates&lt;/li&gt;
&lt;li&gt;avatar syncing&lt;/li&gt;
&lt;li&gt;production vs development auth keys&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Live Project Journals
&lt;/h3&gt;

&lt;p&gt;The journal system needed to support different kinds of updates.&lt;/p&gt;

&lt;p&gt;Not every update is the same.&lt;/p&gt;

&lt;p&gt;Some are progress logs.&lt;br&gt;
Some are bug fixes.&lt;br&gt;
Some are deployment notes.&lt;br&gt;
Some are architecture decisions.&lt;br&gt;
Some are failures.&lt;br&gt;
Some are milestones.&lt;/p&gt;

&lt;p&gt;So I designed journal entry types around the way developers actually build.&lt;/p&gt;




&lt;h3&gt;
  
  
  Bookmarks, Stars, and Social Actions
&lt;/h3&gt;

&lt;p&gt;Social features seem small until state management gets involved.&lt;/p&gt;

&lt;p&gt;You need to think about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;optimistic UI&lt;/li&gt;
&lt;li&gt;duplicate actions&lt;/li&gt;
&lt;li&gt;refresh persistence&lt;/li&gt;
&lt;li&gt;backend constraints&lt;/li&gt;
&lt;li&gt;user-specific state&lt;/li&gt;
&lt;li&gt;counts staying accurate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where a lot of “simple” features become less simple.&lt;/p&gt;




&lt;h3&gt;
  
  
  Deployment
&lt;/h3&gt;

&lt;p&gt;Devmaniac uses multiple services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vercel&lt;/li&gt;
&lt;li&gt;Render&lt;/li&gt;
&lt;li&gt;Neon&lt;/li&gt;
&lt;li&gt;Clerk&lt;/li&gt;
&lt;li&gt;Cloudinary&lt;/li&gt;
&lt;li&gt;Cloudflare&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each one has its own environment variables, production settings, domain setup, and failure points.&lt;/p&gt;

&lt;p&gt;Getting the app live taught me a lot about the difference between “it works locally” and “it works in production.”&lt;/p&gt;

&lt;p&gt;That difference is where real learning happens.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Want to Improve Next
&lt;/h2&gt;

&lt;p&gt;The MVP is only the first version.&lt;/p&gt;

&lt;p&gt;Some planned improvements:&lt;/p&gt;

&lt;h3&gt;
  
  
  Pause and Stuck Logs
&lt;/h3&gt;

&lt;p&gt;Real builders go quiet sometimes.&lt;/p&gt;

&lt;p&gt;They get busy.&lt;br&gt;
They get stuck.&lt;br&gt;
They have exams.&lt;br&gt;
They work jobs.&lt;br&gt;
They burn out.&lt;br&gt;
They come back later.&lt;/p&gt;

&lt;p&gt;I do not want Devmaniac to punish people for that.&lt;/p&gt;

&lt;p&gt;So I want to add better project states like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;active&lt;/li&gt;
&lt;li&gt;paused&lt;/li&gt;
&lt;li&gt;stuck&lt;/li&gt;
&lt;li&gt;researching&lt;/li&gt;
&lt;li&gt;rebuilding&lt;/li&gt;
&lt;li&gt;abandoned&lt;/li&gt;
&lt;li&gt;shipped&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also want users to be able to explain pauses instead of just looking inactive.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Paused for 10 days because I was redesigning the database schema.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is still useful context.&lt;/p&gt;




&lt;h3&gt;
  
  
  GitHub Automation
&lt;/h3&gt;

&lt;p&gt;Posting updates manually can become work.&lt;/p&gt;

&lt;p&gt;So one future goal is GitHub automation.&lt;/p&gt;

&lt;p&gt;When a developer pushes commits, Devmaniac could detect activity and suggest a build update automatically.&lt;/p&gt;

&lt;p&gt;The user could then edit it, approve it, and add it to their live project timeline.&lt;/p&gt;

&lt;p&gt;That would make building in public easier without turning it into another chore.&lt;/p&gt;




&lt;h3&gt;
  
  
  Better Proof-of-Work Profiles
&lt;/h3&gt;

&lt;p&gt;I want profiles to show more than just projects.&lt;/p&gt;

&lt;p&gt;Eventually, a Devmaniac profile should show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;shipped projects&lt;/li&gt;
&lt;li&gt;active builds&lt;/li&gt;
&lt;li&gt;consistency&lt;/li&gt;
&lt;li&gt;technologies used&lt;/li&gt;
&lt;li&gt;build history&lt;/li&gt;
&lt;li&gt;journal quality&lt;/li&gt;
&lt;li&gt;problem-solving patterns&lt;/li&gt;
&lt;li&gt;public progress over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a developer profile that feels alive.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not just a static resume.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;The biggest lesson:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building the product teaches you what the product should become.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I started Devmaniac because I needed it myself.&lt;/p&gt;

&lt;p&gt;I wanted a place to show my own learning and building process without pretending everything was perfect from day one.&lt;/p&gt;

&lt;p&gt;While building it, I learned more about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;backend design&lt;/li&gt;
&lt;li&gt;API structure&lt;/li&gt;
&lt;li&gt;database modeling&lt;/li&gt;
&lt;li&gt;authentication&lt;/li&gt;
&lt;li&gt;deployment&lt;/li&gt;
&lt;li&gt;product decisions&lt;/li&gt;
&lt;li&gt;user feedback&lt;/li&gt;
&lt;li&gt;MVP scope&lt;/li&gt;
&lt;li&gt;shipping under constraints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And honestly, that is the whole point.&lt;/p&gt;

&lt;p&gt;The process is the proof.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Devmaniac is still early.&lt;/p&gt;

&lt;p&gt;It is not perfect.&lt;br&gt;
It has rough edges.&lt;br&gt;
There are features I still need to improve.&lt;br&gt;
There are bugs I still need to fix.&lt;/p&gt;

&lt;p&gt;But it is real, it is live, and it is built around a problem I personally understand.&lt;/p&gt;

&lt;p&gt;I believe developers should be able to prove their ability through the way they build, not just through polished final screenshots.&lt;/p&gt;

&lt;p&gt;That is what Devmaniac is trying to become:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A place where your building process becomes your portfolio.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are a developer building something right now, I would love for you to try it, post a live project, and share honest feedback.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;— Nish&lt;/p&gt;

&lt;p&gt;Founder of Devmaniac&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
