[{"data":1,"prerenderedAt":246},["ShallowReactive",2],{"term-c\u002Fcold-start":3,"related-c\u002Fcold-start":225},{"id":4,"title":5,"acronym":6,"body":7,"category":205,"description":206,"difficulty":207,"extension":208,"letter":209,"meta":210,"navigation":88,"path":211,"related":212,"seo":219,"sitemap":220,"stem":223,"subcategory":6,"__hash__":224},"terms\u002Fterms\u002Fc\u002Fcold-start.md","Cold Start",null,{"type":8,"value":9,"toc":199},"minimark",[10,15,19,23,26,30,188,192,195],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"A cold start is the delay you get when a serverless function hasn't been used for a while and the cloud needs to spin up a fresh container to run it. It's like a restaurant that closes between lunch and dinner — you're the first customer after the break and have to wait for them to reopen and prep the kitchen.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A cold start occurs when a serverless function receives a request but no warm container is available. The runtime must provision a new container, initialize the environment, load dependencies, and run initialization code before handling the request. Cold starts add hundreds of milliseconds to seconds of latency depending on the runtime and bundle size.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Reduce cold starts: keep the handler lean,\n\u002F\u002F move heavy init outside the handler function\nconst db = initializeDatabaseConnection(); \u002F\u002F runs once on cold start\n\nexport const handler = async (event) => {\n  \u002F\u002F db is already warm on subsequent invocations\n  const result = await db.query('SELECT ...');\n  return result;\n};\n","javascript","",[38,39,40,49,55,83,90,124,130,172,182],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"sHwdD","\u002F\u002F Reduce cold starts: keep the handler lean,\n",[41,50,52],{"class":43,"line":51},2,[41,53,54],{"class":47},"\u002F\u002F move heavy init outside the handler function\n",[41,56,58,62,66,70,74,77,80],{"class":43,"line":57},3,[41,59,61],{"class":60},"spNyl","const",[41,63,65],{"class":64},"sTEyZ"," db ",[41,67,69],{"class":68},"sMK4o","=",[41,71,73],{"class":72},"s2Zo4"," initializeDatabaseConnection",[41,75,76],{"class":64},"()",[41,78,79],{"class":68},";",[41,81,82],{"class":47}," \u002F\u002F runs once on cold start\n",[41,84,86],{"class":43,"line":85},4,[41,87,89],{"emptyLinePlaceholder":88},true,"\n",[41,91,93,97,100,103,105,108,111,115,118,121],{"class":43,"line":92},5,[41,94,96],{"class":95},"s7zQu","export",[41,98,99],{"class":60}," const",[41,101,102],{"class":64}," handler ",[41,104,69],{"class":68},[41,106,107],{"class":60}," async",[41,109,110],{"class":68}," (",[41,112,114],{"class":113},"sHdIc","event",[41,116,117],{"class":68},")",[41,119,120],{"class":60}," =>",[41,122,123],{"class":68}," {\n",[41,125,127],{"class":43,"line":126},6,[41,128,129],{"class":47},"  \u002F\u002F db is already warm on subsequent invocations\n",[41,131,133,136,139,142,145,148,151,154,158,161,165,167,169],{"class":43,"line":132},7,[41,134,135],{"class":60},"  const",[41,137,138],{"class":64}," result",[41,140,141],{"class":68}," =",[41,143,144],{"class":95}," await",[41,146,147],{"class":64}," db",[41,149,150],{"class":68},".",[41,152,153],{"class":72},"query",[41,155,157],{"class":156},"swJcz","(",[41,159,160],{"class":68},"'",[41,162,164],{"class":163},"sfazB","SELECT ...",[41,166,160],{"class":68},[41,168,117],{"class":156},[41,170,171],{"class":68},";\n",[41,173,175,178,180],{"class":43,"line":174},8,[41,176,177],{"class":95},"  return",[41,179,138],{"class":64},[41,181,171],{"class":68},[41,183,185],{"class":43,"line":184},9,[41,186,187],{"class":68},"};\n",[11,189,191],{"id":190},"when-youll-hear-this","When You'll Hear This",[16,193,194],{},"\"The cold start is adding 2 seconds to the first request after inactivity.\" \u002F \"Use provisioned concurrency to avoid cold starts for latency-sensitive functions.\"",[196,197,198],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":51,"depth":51,"links":200},[201,202,203,204],{"id":13,"depth":51,"text":14},{"id":21,"depth":51,"text":22},{"id":28,"depth":51,"text":29},{"id":190,"depth":51,"text":191},"cloud","A cold start is the delay you get when a serverless function hasn't been used for a while and the cloud needs to spin up a fresh container to run it.","intermediate","md","c",{},"\u002Fterms\u002Fc\u002Fcold-start",[213,214,215,216,217,218],"Serverless","Lambda","FaaS","Warm Start","Edge Function","Cloud Function",{"title":5,"description":206},{"changefreq":221,"priority":222},"weekly",0.7,"terms\u002Fc\u002Fcold-start","KF3mCVexcLBVt7uZjciDDLAr8nyjzfcgT-UkcLr0i60",[226,230,233,237,240,243],{"title":218,"path":227,"acronym":6,"category":205,"difficulty":228,"description":229},"\u002Fterms\u002Fc\u002Fcloud-function","beginner","A cloud function is a piece of code you deploy to the cloud that runs when triggered — by an HTTP request, a file upload, a timer, or another event.",{"title":217,"path":231,"acronym":6,"category":205,"difficulty":228,"description":232},"\u002Fterms\u002Fe\u002Fedge-function","Edge functions run your code at the CDN edge — meaning close to the user, not in some faraway data center.",{"title":215,"path":234,"acronym":235,"category":205,"difficulty":207,"description":236},"\u002Fterms\u002Ff\u002Ffaas","Function as a Service","FaaS is when you write a tiny function and deploy it to the cloud, and it only runs (and charges you) when someone calls it.",{"title":214,"path":238,"acronym":6,"category":205,"difficulty":207,"description":239},"\u002Fterms\u002Fl\u002Flambda","AWS Lambda is where you upload a function and AWS runs it when something happens — an HTTP request, a file upload, a database change.",{"title":213,"path":241,"acronym":6,"category":205,"difficulty":228,"description":242},"\u002Fterms\u002Fs\u002Fserverless","Serverless doesn't mean there are no servers — it means YOU don't have to think about servers. Someone else manages them, scales them, and patches them.",{"title":216,"path":244,"acronym":6,"category":205,"difficulty":207,"description":245},"\u002Fterms\u002Fw\u002Fwarm-start","A warm start is when your serverless function gets a request and a container is already running from a previous invocation — so it responds instantly witho...",1776518267323]