<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Malika Bakhtiyorova on Medium]]></title>
        <description><![CDATA[Stories by Malika Bakhtiyorova on Medium]]></description>
        <link>https://medium.com/@queenwhocodes?source=rss-4951c849c70d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oO8MruOy54krsZje.jpg</url>
            <title>Stories by Malika Bakhtiyorova on Medium</title>
            <link>https://medium.com/@queenwhocodes?source=rss-4951c849c70d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 13:07:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@queenwhocodes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RESP: A protocol helps Redis to handle 1M+ req/sec]]></title>
            <link>https://medium.com/@queenwhocodes/resp-a-protocol-helps-redis-to-handle-1m-req-sec-43a9295b6681?source=rss-4951c849c70d------2</link>
            <guid isPermaLink="false">https://medium.com/p/43a9295b6681</guid>
            <category><![CDATA[resp]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Malika Bakhtiyorova]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 07:07:05 GMT</pubDate>
            <atom:updated>2026-02-23T07:07:05.941Z</atom:updated>
            <content:encoded><![CDATA[<p>RESP <strong>(Redis Serialization Protocol)</strong> protocol mainly used with Redis, but not only. It’s a text based serialization protocol over TCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ndSozH9Nq3uyT578R010WQ.png" /></figure><p>Let’s understand it on the protocol level:</p><p>It’s very simple, having following data types:<br><strong>RESP2 </strong>(original): Simple String, Error, Integer, Bulk String, Array, Null<br><strong>RESP3</strong> (Redis 6, 2020): Map, Set, Double, Boolean, Blob Error, Verbatim String, Big Number</p><p>That’s it! No headers, schema, and handshake, just prefixed strings with \r\n as a delimeter.</p><p><strong>Advantages:</strong><br>- No headers (nothing wasted on metadata)<br>- No Schema (zero overhead to parse)<br>- No Handshake (first byte you send is already work)<br>- No request-response synchronization required</p><p>Works like streaming and Receiver knows how many bytes to expect before reading! This means: <strong>length-prefixed framing means the receiver knows exactly how many bytes to read before loading anything into memory.</strong>This is what prevents buffer overflow — not streaming in a vague sense, but the specific design of $N\r\n telling the client precisely how much is coming.</p><p><strong>Disadvantages:</strong><br>- No headers (no built-in auth, versioning, or content negotiation)<br>- No Schema (no contract enforcement)<br>- No Hanshake (no checksum, it trusts whatever connects to it)<br>- String (not binary) data<br>- <em>No structured</em> error handling — no error codes, no retry semantics<br>- No congestion control<br>- Not browser facing<br>- No request multiplexing</p><p><strong>Differences with HTTP</strong>:</p><p>HTTP/1.1 is a request-response protocol — you send a request, wait for the response, then send the next. Even with pipelining enabled, responses must be returned in order, meaning a slow response <strong>blocks</strong> everything behind it. Add verbose headers <strong>repeated</strong> on every request (often 500–800 bytes of metadata for a 20-byte payload), and you have a protocol designed for <strong>flexibility, not raw speed</strong>.</p><p>RESP has none of that structure. <strong>No headers, no ordering constraint, no waiting</strong>. You push commands continuously and responses come back <strong>as they’re ready</strong>. When delivering large data, HTTP builds the full response in memory before sending — RESP <strong>sends</strong> the <strong>array size upfront</strong> (*1000000\r\n) and streams items <strong>immediately</strong>, so neither side ever holds the full dataset.</p><p>BUT there’s a tradeoff though: HTTP/1.1 gives you caching, authentication, content negotiation, and universal client support for free. RESP gives you none of that. HTTP is a protocol for the open web. <strong>RESP is a protocol for when you control both ends of the wire and need to move data fast.</strong></p><p><strong>Use Cases:</strong></p><p><strong>Redis</strong>. Every SET, GET, HSET we ever called went over RESP. The protocol is why Redis achieves sub-millisecond latency at a million requests per second.</p><p><strong>Internal bulk data transfer</strong> — when a service that needs to stream 5 million product records to a downstream indexing service on deploy. HTTP would require buffering the full response or implementing chunked transfer manually. With RESP, the sender streams records one by one, the receiver reads them one by one, and memory stays flat on both sides throughout.</p><p><strong>Migration pipelines</strong> — redis-cli — pipe accepts raw RESP on stdin and fires it at Redis at wire speed. This makes RESP a natural format for database migrations: generate RESP from any source, pipe it in, done. No ORM, no connection pool, just bytes.</p><p><strong>Should You Use It Outside Redis?</strong></p><p>When <strong>internal service-to-service streaming where both sides are yours and you need results fast.</strong></p><p>The real argument for it isn’t performance — gRPC is close enough for most workloads. The argument is that every language already has a Redis client library. If you build a custom RESP server, you get free, battle-tested client implementations in <strong>Python, Go, Java, Node, Rust</strong>, and a dozen others without writing a line of client code. You can debug it live with redis-cli.</p><p>For a public API, preferred to use gRPC or REST — consumers expect schemas, versioning, and documentation. For a browser-facing API, RESP is a non-starter. But for an internal data pipeline where need to move large volumes fast, don’t want to stand up a full gRPC infrastructure, and want every language to just work out of the box — a custom RESP server is a legitimate, underused option might not be considered assuming RESP is Redis-only. <strong>But It isn’t.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43a9295b6681" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximum Network Rank 1615]]></title>
            <link>https://medium.com/@queenwhocodes/maximum-network-rank-1615-f866828dad5c?source=rss-4951c849c70d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f866828dad5c</guid>
            <dc:creator><![CDATA[Malika Bakhtiyorova]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 05:16:02 GMT</pubDate>
            <atom:updated>2025-04-12T05:16:02.864Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxQpDRUYotD55Jwn4522lg.png" /></figure><p>Question:<br>There is an infrastructure (graph) of n cities with some number of roads (edges) connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi.</p><p>The <strong>network rank</strong><em> </em>of <strong>two different cities</strong> is defined as the total number of <strong>directly</strong> connected roads to <strong>either </strong>city. If a road is directly connected to both cities, it is only counted <strong>once</strong>.</p><p>The <strong>maximal network rank </strong>of the infrastructure is the <strong>maximum network rank</strong> of all pairs of different cities.</p><p>Given the integer n and the array roads, return <em>the </em><strong><em>maximal network rank</em></strong><em> of the entire infrastructure</em>.</p><blockquote>Intuition:<br>1. Counting every node’s degree (connected nodes)<br>2. Calculate for each pair of nodes’ connected rank (degree) that : rank(i, j) = degree[i] + degree[j] — (1 if direct road exists)<br>3. Keep track of maximum rank</blockquote><p>Step 1: Counting every node’s degree (connected nodes)</p><pre>let degree = new Array(n).fill(0) //to count connected nodes for each node<br>let connected = Array.from({length: n}, () =&gt; new Array(n).fill(false))<br>//to store connecitvity of the node pairs (helps to calculate the rank)<br>for (let [u, v] of roads) {<br>  //nodes are bidrectional connected so increase both nodes&#39; degree<br>  degree[u]++<br>  degree[v]++<br>  //biderectional marking if pair of nodes connected<br>  connected[u][v] = true<br>  connected[v][u] = true<br>}</pre><p>Step 2: Calculate for each pair of nodes’ connected rank (degree) that : rank(i, j) = degree[i] + degree[j] — (1 if direct road exists)</p><pre>for(let i=0;i&lt;n;i++){<br>let curDegree; //current degree of pairs<br>   for(let j=i+1;j&lt;n;j++){<br>      if(connected[i][j]){<br>          //if connected<br>          curDegree = (degree[i]+degree[j]-1,max) <br>      //if not directedly connected<br>      }else curDegree=Math.max(max, degree[i]+degree[j]) <br>   }<br>}</pre><p>Step 3: Keep track of maximum rank</p><pre> let max=0; //maximum variable<br>    for(let i=0;i&lt;n;i++){<br>        for(let j=i+1;j&lt;n;j++){<br>           if(connected[i][j]){<br>                max=Math.max(degree[i]+degree[j]-1,max) //keep track of max<br>        }else max=Math.max(max, degree[i]+degree[j]) //keep track of max<br>    }<br> }</pre><p>Final Code:</p><pre>var maximalNetworkRank = function(n, roads) {<br>    let degree = new Array(n).fill(0)<br>    let connected = Array.from({length: n}, () =&gt; new Array(n).fill(false))<br>    for (let [u, v] of roads) {<br>        degree[u]++<br>        degree[v]++<br>        connected[u][v] = true<br>        connected[v][u] = true<br>    }<br><br>    let max=0;<br>    for(let i=0;i&lt;n;i++){<br>        for(let j=i+1;j&lt;n;j++){<br>            if(connected[i][j]){<br>                max=Math.max(degree[i]+degree[j]-1,max)<br>            }else max=Math.max(max, degree[i]+degree[j])<br>        }<br>    }<br><br>    return max<br>};</pre><p>Voila!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f866828dad5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>