<?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: Nitheesh gaddam</title>
    <description>The latest articles on DEV Community by Nitheesh gaddam (@nitheesh_gaddam_e36ec4aa4).</description>
    <link>https://dev.to/nitheesh_gaddam_e36ec4aa4</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%2F3690765%2Fab0f0263-51fa-4092-a1d4-ac53ab211c0f.png</url>
      <title>DEV Community: Nitheesh gaddam</title>
      <link>https://dev.to/nitheesh_gaddam_e36ec4aa4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nitheesh_gaddam_e36ec4aa4"/>
    <language>en</language>
    <item>
      <title>A Deep Dive into Amazon Bedrock Prompt Caching for Claude 4.6</title>
      <dc:creator>Nitheesh gaddam</dc:creator>
      <pubDate>Sun, 26 Jul 2026 12:43:47 +0000</pubDate>
      <link>https://dev.to/nitheesh_gaddam_e36ec4aa4/a-deep-dive-into-amazon-bedrock-prompt-caching-for-claude-46-28ob</link>
      <guid>https://dev.to/nitheesh_gaddam_e36ec4aa4/a-deep-dive-into-amazon-bedrock-prompt-caching-for-claude-46-28ob</guid>
      <description>&lt;p&gt;Have you ever noticed that your GenAI applications are spending massive amounts of time and money re-reading the exact same setup text?&lt;br&gt;
Every time a user asks a short question in a chatbot, the Large Language Model (LLM) must re-read your entire 2,000-word corporate playbook, your agent's system rules, and the full chat history from scratch. &lt;br&gt;
This phase is called the pre-fill math phase, and it drives up both your cloud bill and your user latency (Time-to-First-Token).With Amazon Bedrock Prompt Caching for Claude 4.6 (both Sonnet 4.6 and Opus 4.6), this problem is completely solved. You can achieve up to a 90% cost reduction on input tokens and an 85% drop in latency by using a clever architectural shortcut.&lt;/p&gt;

&lt;p&gt;Here is exactly how it works under the hood, how AWS maintains it across API requests, and how to implement it using Python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Secret Architecture: Model Inference vs. AWS Infrastructure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prompt caching is a beautiful team effort between the AI model hardware and the AWS cloud infrastructure.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Model Level (The Brains): Inside Claude 4.6, text is processed through mathematical matrices called KV (Key-Value) Caches. Instead of re-reading text, the GPUs calculate the meaning of your system instructions once and build a "mathematical profile." When a cache point is triggered, the model freezes this calculated KV state inside the GPU memory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.The AWS Bedrock Level (The Manager): Normally, an LLM wipes its memory the millisecond an API call finishes. AWS Bedrock changes this. It takes your static prompt, creates a secure, unique cryptographic hash (fingerprint), and pins that KV memory block alive.&lt;/p&gt;

&lt;p&gt;When your next API request comes in, AWS Bedrock instantly hashes the new incoming prompt text. If the top section matches a saved fingerprint, Bedrock's router bypasses the standard pre-fill setup and routes your request directly to the GPU holding your frozen mathematical profile.&lt;/p&gt;

&lt;p&gt;It is exactly like loading a "Save Game" file instead of restarting a video game from Level 1 on every single turn!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Golden Rules of Bedrock Caching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before writing the code, keep these rules in mind to ensure your cache actually hits:&lt;/p&gt;

&lt;p&gt;1.The Thresholds: Your cached text must meet minimum size requirements. For Claude Sonnet 4.6, your static content must be at least 1,024 tokens. For Claude Opus 4.6, it requires 4,096 tokens.&lt;/p&gt;

&lt;p&gt;2.The 5-Minute Window: The cache stays alive for a default Time-To-Live (TTL) of 5 minutes. However, every time a user makes a new request and hits the cache, that 5-minute countdown timer resets back to zero.&lt;/p&gt;

&lt;p&gt;3.Order Matters: AWS reads your prompts sequentially. You must put your heavy, fixed instructions first, drop your cache bookmark, and append your changing user messages at the very end. If a single character changes before your cache marker, the cache breaks!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation: Prompt Caching with Python (Boto3)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The cleanest way to handle a multi-turn chatbot with prompt caching is using AWS Bedrock's Converse API. By putting a cachePoint at the end of your system configuration, your fixed instructions stay frozen while your dynamic chat messages grow freely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize the Bedrock Runtime client
&lt;/span&gt;&lt;span class="n"&gt;bedrock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bedrock-runtime&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;us-east-1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Target Model: Claude Sonnet 4.6 (Minimum threshold: 1,024 tokens)
&lt;/span&gt;&lt;span class="n"&gt;MODEL_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;anthropic.claude-sonnet-4-6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# 1. DEFINE FIXED SYSTEM INSTRUCTIONS (Ensure this exceeds 1,024 tokens)
&lt;/span&gt;&lt;span class="n"&gt;BASE_SYSTEM_PROMPT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
You are a highly specialized corporate HR assistant for Acme Corp.
You must adhere strictly to the following guidelines:
1. Always maintain a professional tone.
2. Rely only on company procedures outlined below.
&lt;/span&gt;&lt;span class="gp"&gt;...&lt;/span&gt; &lt;span class="n"&gt;Imagine&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;000&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;corporate&lt;/span&gt; &lt;span class="n"&gt;documentation&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;policies&lt;/span&gt; &lt;span class="n"&gt;placed&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt; &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# 2. STRUCTURE SYSTEM PARAMETER WITH A CACHE POINT
# We place the cachePoint marker IMMEDIATELY following our static text block.
&lt;/span&gt;&lt;span class="n"&gt;system_configuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BASE_SYSTEM_PROMPT&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cachePoint&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;default&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Track our growing chat conversation history
&lt;/span&gt;&lt;span class="n"&gt;conversation_history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_chat_turn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;conversation_history&lt;/span&gt;

    &lt;span class="c1"&gt;# Append the newest user message to our history tracking
&lt;/span&gt;    &lt;span class="n"&gt;conversation_history&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;--- Processing Chat Request (Turns: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conversation_history&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;) ---&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Invoke the Bedrock Converse API
&lt;/span&gt;    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bedrock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;converse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;modelId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;MODEL_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;system_configuration&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# The fixed cached system instructions
&lt;/span&gt;        &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;conversation_history&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# The growing dynamic chat history
&lt;/span&gt;        &lt;span class="n"&gt;inferenceConfig&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;maxTokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;temperature&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Save the assistant's reply back to history
&lt;/span&gt;    &lt;span class="n"&gt;assistant_message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;output&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;conversation_history&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;assistant_message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Extract usage metrics to verify cache hits!
&lt;/span&gt;    &lt;span class="n"&gt;metrics&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;usage&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;read_from_cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cacheReadInputTokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;written_to_cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cacheWriteInputTokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;standard_input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;inputTokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AI Response snippet: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;assistant_message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; 💾 Tokens Written to Cache (First Turn): &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;written_to_cache&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; 🔥 Tokens Read From Cache (Discounted!): &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;read_from_cache&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; 📝 Standard Input Tokens Processed: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;standard_input&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# ==========================================================
# SIMULATING THE CONVERSATION
# ==========================================================
&lt;/span&gt;
&lt;span class="c1"&gt;# Turn 1: Cache Miss / Cache Write
# Bedrock reads the instructions fully, builds the KV cache, and saves it.
&lt;/span&gt;&lt;span class="nf"&gt;run_chat_turn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello! What are the official office hours for the engineering team?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Turn 2: Cache Hit!
# The system instructions are read directly from cache memory. Only new text is computed.
&lt;/span&gt;&lt;span class="nf"&gt;run_chat_turn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Great. And what is the standard protocol if I need to request time off?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The VerdictBy keeping your architecture split cleanly between fixed inputs (cached) and dynamic inputs (uncached), you shift the heavy lifting away from continuous, expensive compute cycles and onto smart cloud routing.If you are building RAG applications, enterprise chatbots, or complex agent workflows on AWS, prompt caching isn't just an optimization feature—it is a production requirement for building fast, cost-effective AI systems.&lt;/p&gt;

&lt;h1&gt;
  
  
  AWS #AmazonBedrock #GenerativeAI #Claude #Python #CloudComputing
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>aws</category>
      <category>llm</category>
      <category>performance</category>
    </item>
    <item>
      <title>How Instagram Scales Tagging for Billions of Users</title>
      <dc:creator>Nitheesh gaddam</dc:creator>
      <pubDate>Sat, 17 Jan 2026 06:40:31 +0000</pubDate>
      <link>https://dev.to/nitheesh_gaddam_e36ec4aa4/how-instagram-scales-tagging-for-billions-of-users-3p79</link>
      <guid>https://dev.to/nitheesh_gaddam_e36ec4aa4/how-instagram-scales-tagging-for-billions-of-users-3p79</guid>
      <description>&lt;p&gt;Have you ever wondered what happens in the milliseconds between hitting "Share" on a photo and your friend receiving a notification that they’ve been tagged? On the surface, tagging is a simple feature. At Instagram’s scale, it is a masterclass in distributed systems design.&lt;/p&gt;

&lt;p&gt;To handle millions of tags per minute, Instagram moves away from a single "do-it-all" database and instead uses a specialized Microservices Tech Stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Core Architecture:&lt;/strong&gt; A Four-Pillar Approach&lt;br&gt;
The secret to Instagram's speed lies in using the right tool for the right job. Here is how the four main components work in harmony:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Source of Truth: Sharded PostgreSQL&lt;/strong&gt;&lt;br&gt;
Every tag needs a permanent home. Instagram uses PostgreSQL, but with a twist: Logical Sharding.&lt;/p&gt;

&lt;p&gt;How it works: Your data isn’t in one giant table; it’s partitioned across hundreds of databases based on your User_ID.&lt;/p&gt;

&lt;p&gt;The Benefit: When you view a post, the system knows exactly which shard to query, ensuring that retrieving tag coordinates and usernames is lightning-fast and consistent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The Speed Demon: Redis Caching&lt;/strong&gt;&lt;br&gt;
When a hashtag like #nature goes viral, thousands of writes happen every second.&lt;/p&gt;

&lt;p&gt;The Role of Redis: Instead of hammering the main database to update "post counts," Instagram uses Redis—an in-memory data store.&lt;/p&gt;

&lt;p&gt;The Benefit: It acts as a high-speed scoreboard, incrementing hashtag counts and storing "Hot Post" lists so the Explore page loads instantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The Search Engine: Elasticsearch&lt;/strong&gt;&lt;br&gt;
Standard databases are terrible at text search. If you search for "summ," a SQL database would struggle to find "#summer" among billions of rows.&lt;/p&gt;

&lt;p&gt;The Solution: Instagram pipes caption data into Elasticsearch.&lt;/p&gt;

&lt;p&gt;The Benefit: It builds an Inverted Index (mapping words to Post IDs), allowing for fuzzy matching and near-instant discovery of trending topics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The Reliable Messenger: Apache Kafka&lt;/strong&gt;&lt;br&gt;
Tagging a friend triggers a chain reaction: a notification is sent, the "Photos of You" section updates, and the search index is refreshed.&lt;/p&gt;

&lt;p&gt;The Role of Kafka: It acts as a Message Queue. The main app simply "drops a note" in Kafka and moves on.&lt;/p&gt;

&lt;p&gt;The Benefit: This "asynchronous" processing ensures that if the notification service is busy, your photo upload isn't slowed down. The work happens reliably in the background.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways for Developers&lt;/strong&gt;&lt;br&gt;
Decouple your services: Use queues (Kafka) so your main API stays fast.&lt;/p&gt;

&lt;p&gt;Pick the right DB: Use SQL for consistency, but NoSQL or Search Engines (Elasticsearch) for discovery.&lt;/p&gt;

&lt;p&gt;Shard early: Horizontal scaling is the only way to survive "Instagram-level" traffic.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>microservices</category>
      <category>postgres</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>How GraphRAG Works</title>
      <dc:creator>Nitheesh gaddam</dc:creator>
      <pubDate>Sat, 03 Jan 2026 04:51:50 +0000</pubDate>
      <link>https://dev.to/nitheesh_gaddam_e36ec4aa4/how-graphrag-works-2d33</link>
      <guid>https://dev.to/nitheesh_gaddam_e36ec4aa4/how-graphrag-works-2d33</guid>
      <description>&lt;p&gt;GraphRAG has two main phases: Indexing (preprocessing the dataset) and Querying (answering questions).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Indexing Phase (Offline, Expensive but Done Once)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Text Chunking — Split the input text into manageable chunks.&lt;br&gt;
Entity Extraction — Use an LLM to identify entities (people, places, organizations, concepts) and relationships from each chunk.&lt;br&gt;
Build Knowledge Graph — Create a graph where nodes are entities and edges are relationships (with descriptions).&lt;br&gt;
Community Detection — Apply graph algorithms (e.g., Leiden algorithm) to identify clusters of closely related entities (communities).&lt;br&gt;
Hierarchical Summarization — Generate summaries for each community at multiple levels (bottom-up hierarchy: detailed low-level communities → higher-level aggregated summaries).&lt;br&gt;
The result is a structured index: the graph + pre-generated community summaries.&lt;/p&gt;

&lt;p&gt;This captures implicit connections across the entire dataset that vector embeddings alone miss.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Querying Phase&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Local Queries (specific details): Retrieve relevant subgraphs or text chunks near mentioned entities.&lt;br&gt;
Global Queries (broad understanding):&lt;br&gt;
Select relevant community summaries (based on similarity to the query).&lt;br&gt;
Use the LLM to generate partial answers from each summary.&lt;br&gt;
Aggregate and summarize the partial answers into a final coherent response.&lt;/p&gt;

&lt;p&gt;This "map-reduce" style over communities enables holistic reasoning.&lt;br&gt;
Why It's Better Than Standard RAG&lt;/p&gt;

&lt;p&gt;Comprehensiveness: Captures broader themes and connections → answers are more complete.&lt;br&gt;
Diversity: Reduces repetition and surfaces varied perspectives.&lt;br&gt;
Empowerment: Provides grounded, evidence-based insights for complex datasets (e.g., conflicting news sources).&lt;br&gt;
Experiments in the paper (on datasets ~1 million tokens) show GraphRAG outperforming baseline RAG by 70-80% on metrics like comprehensiveness and diversity for global questions.&lt;/p&gt;

&lt;p&gt;Practical Details&lt;/p&gt;

&lt;p&gt;Open-source implementation: Available on GitHub (microsoft/graphrag).&lt;br&gt;
Costs: Indexing is LLM-intensive (many calls for extraction and summarization), but querying is efficient.&lt;br&gt;
Later improvements (post-paper): Things like LazyGraphRAG (more cost-efficient), DRIFT search, dynamic community selection, and auto-tuning for new domains.&lt;/p&gt;

&lt;p&gt;In summary, GraphRAG represents a major advancement in making LLMs reason over large, private, narrative-rich datasets by leveraging graph structures for "global sensemaking." It's particularly useful when standard RAG gives incomplete or superficial answers.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>genai</category>
    </item>
  </channel>
</rss>
