[{"data":1,"prerenderedAt":1831},["ShallowReactive",2],{"article-alternates":3,"article-\u002Fru\u002Ftech\u002Foptimizacija-personalizacije-latentnosti-edge-ssr-40ms":13},{"i18nKey":4,"paths":5},"tech-003-2026-08",{"de":6,"en":7,"es":8,"fr":9,"it":10,"ru":11,"tr":12},"\u002Fde\u002Ftech\u002Fedge-ssr-personalisierung-40ms-latenz","\u002Fen\u002Ftech\u002Freducing-personalization-latency-40ms-edge-ssr","\u002Fes\u002Ftech\u002Fedge-ssr-latencia-40ms","\u002Ffr\u002Ftech\u002Fedge-ssr-personalizasyon-latency-40ms","\u002Fit\u002Ftech\u002Flatenza-personalizzione-edge-ssr-40ms","\u002Fru\u002Ftech\u002Foptimizacija-personalizacije-latentnosti-edge-ssr-40ms","\u002Ftr\u002Ftech\u002Fedge-ssr-ile-personalizasyon-latencysini-40msye-dusurmek",{"_path":11,"_dir":14,"_draft":15,"_partial":15,"_locale":16,"title":17,"description":18,"publishedAt":19,"modifiedAt":19,"category":14,"i18nKey":4,"tags":20,"readingTime":26,"author":27,"body":28,"_type":1825,"_id":1826,"_source":1827,"_file":1828,"_stem":1829,"_extension":1830},"tech",false,"","Снижение latency персонализации с помощью Edge SSR до 40ms","Архитектура Cloudflare Workers и Vercel Edge с KV store: как мы снизили server-side rendering latency до 40ms с примерами кода.","2026-08-16",[21,22,23,24,25],"edge-computing","ssr","cloudflare-workers","vercel-edge","web-performance",9,"Roibase",{"type":29,"children":30,"toc":1814},"root",[31,39,46,51,56,61,67,81,777,790,795,802,822,827,833,838,854,859,865,870,911,929,939,1084,1094,1100,1105,1476,1495,1500,1506,1511,1777,1782,1788,1793,1798,1803,1808],{"type":32,"tag":33,"props":34,"children":35},"element","p",{},[36],{"type":37,"value":38},"text","В традиционных SSR архитектурах latency персонализации держится в диапазоне 200–400ms. Когда нужно отрендерить страницу с учётом локации пользователя, его предпочтений и истории поведения, это время может вырасти до 600ms. Edge SSR позволяет снизить эту цифру до 40ms — однако если архитектура не продумана должным образом, ограничения edge окружения (лимит CPU, cold start, объём памяти) уничтожат производительность. В этой статье разбираем анатомию production архитектуры на Cloudflare Workers + KV: какие данные хранить на edge, какие запросы направлять в origin и какие tradeoff'ы необходимы для гарантии 40ms latency.",{"type":32,"tag":40,"props":41,"children":43},"h2",{"id":42},"отличие-edge-ssr-от-классического-origin-ssr",[44],{"type":37,"value":45},"Отличие Edge SSR от классического Origin SSR",{"type":32,"tag":33,"props":47,"children":48},{},[49],{"type":37,"value":50},"В классическом SSR запрос следует по цепочке: CDN → origin server → database → render → response. Каждый hop добавляет 20–60ms latency, итого 250–400ms. Edge SSR разрывает эту цепь: запрос падает в edge runtime (Cloudflare Workers или Vercel Edge Function), чтение из KV store занимает 5–15ms, рендер завершается за 10–25ms. Общая latency падает до 40–60ms.",{"type":32,"tag":33,"props":52,"children":53},{},[54],{"type":37,"value":55},"Разница не только в географической близости — архитектура принципиально иная. Edge runtime используют V8 isolate технологию, cold start составляет 0–5ms. Node.js контейнер холодный старт может занять 200–800ms. Распределённая key-value структура KV store устраняет latency overhead TCP handshake к database. Пример: запрос в Postgres для получения сегментации пользователей занимает 80–120ms (connection + query + parsing), то же данные из Cloudflare KV читаются за 8–12ms.",{"type":32,"tag":33,"props":57,"children":58},{},[59],{"type":37,"value":60},"Tradeoff таков: edge runtime имеет лимит CPU 50ms, limit памяти около 128MB (зависит от платформы). Если выполнять тяжёлые вычисления или большой JSON parsing, превысите лимит. Поэтому на edge рендерится только \"горячий путь\" — сложные операции остаются в origin.",{"type":32,"tag":40,"props":62,"children":64},{"id":63},"анатомия-архитектуры-kv-store",[65],{"type":37,"value":66},"Анатомия архитектуры KV Store",{"type":32,"tag":33,"props":68,"children":69},{},[70,72,79],{"type":37,"value":71},"Не думайте о KV store как о cache — проектируйте его как о распределённом global state. Вот структура, которую мы используем: каждый сегмент пользователя (например \"premium-tr\", \"free-us\") становится namespace ключом, value — JSON с правилами персонализации. Формат ключа: ",{"type":32,"tag":73,"props":74,"children":76},"code",{"className":75},[],[77],{"type":37,"value":78},"user_segment:{segment_id}:config",{"type":37,"value":80},". Этот config содержит правила: какой hero image показывать, какой текст в price note, как изменяется CTA.",{"type":32,"tag":82,"props":83,"children":87},"pre",{"className":84,"code":85,"language":86,"meta":16,"style":16},"language-typescript shiki shiki-themes github-dark","\u002F\u002F Пример для Cloudflare Workers\ninterface UserSegmentConfig {\n  heroImage: string;\n  ctaText: string;\n  priceNote: string;\n  featureFlags: string[];\n}\n\nexport default {\n  async fetch(request: Request, env: Env): Promise\u003CResponse> {\n    const url = new URL(request.url);\n    const segmentId = getCookie(request, 'segment_id') || 'default';\n    \n    const configKey = `user_segment:${segmentId}:config`;\n    const configRaw = await env.KV_NAMESPACE.get(configKey);\n    \n    if (!configRaw) {\n      \u002F\u002F Fallback: получить из origin, записать в KV\n      const originConfig = await fetchFromOrigin(segmentId);\n      await env.KV_NAMESPACE.put(configKey, JSON.stringify(originConfig), {\n        expirationTtl: 3600 \u002F\u002F 1 час\n      });\n      return renderPage(originConfig);\n    }\n    \n    const config: UserSegmentConfig = JSON.parse(configRaw);\n    return renderPage(config);\n  }\n};\n","typescript",[88],{"type":32,"tag":73,"props":89,"children":90},{"__ignoreMap":16},[91,103,125,151,172,193,215,224,234,251,332,366,418,427,463,510,518,542,551,583,633,652,661,680,689,697,741,759,768],{"type":32,"tag":92,"props":93,"children":96},"span",{"class":94,"line":95},"line",1,[97],{"type":32,"tag":92,"props":98,"children":100},{"style":99},"--shiki-default:#6A737D",[101],{"type":37,"value":102},"\u002F\u002F Пример для Cloudflare Workers\n",{"type":32,"tag":92,"props":104,"children":106},{"class":94,"line":105},2,[107,113,119],{"type":32,"tag":92,"props":108,"children":110},{"style":109},"--shiki-default:#F97583",[111],{"type":37,"value":112},"interface",{"type":32,"tag":92,"props":114,"children":116},{"style":115},"--shiki-default:#B392F0",[117],{"type":37,"value":118}," UserSegmentConfig",{"type":32,"tag":92,"props":120,"children":122},{"style":121},"--shiki-default:#E1E4E8",[123],{"type":37,"value":124}," {\n",{"type":32,"tag":92,"props":126,"children":128},{"class":94,"line":127},3,[129,135,140,146],{"type":32,"tag":92,"props":130,"children":132},{"style":131},"--shiki-default:#FFAB70",[133],{"type":37,"value":134},"  heroImage",{"type":32,"tag":92,"props":136,"children":137},{"style":109},[138],{"type":37,"value":139},":",{"type":32,"tag":92,"props":141,"children":143},{"style":142},"--shiki-default:#79B8FF",[144],{"type":37,"value":145}," string",{"type":32,"tag":92,"props":147,"children":148},{"style":121},[149],{"type":37,"value":150},";\n",{"type":32,"tag":92,"props":152,"children":154},{"class":94,"line":153},4,[155,160,164,168],{"type":32,"tag":92,"props":156,"children":157},{"style":131},[158],{"type":37,"value":159},"  ctaText",{"type":32,"tag":92,"props":161,"children":162},{"style":109},[163],{"type":37,"value":139},{"type":32,"tag":92,"props":165,"children":166},{"style":142},[167],{"type":37,"value":145},{"type":32,"tag":92,"props":169,"children":170},{"style":121},[171],{"type":37,"value":150},{"type":32,"tag":92,"props":173,"children":175},{"class":94,"line":174},5,[176,181,185,189],{"type":32,"tag":92,"props":177,"children":178},{"style":131},[179],{"type":37,"value":180},"  priceNote",{"type":32,"tag":92,"props":182,"children":183},{"style":109},[184],{"type":37,"value":139},{"type":32,"tag":92,"props":186,"children":187},{"style":142},[188],{"type":37,"value":145},{"type":32,"tag":92,"props":190,"children":191},{"style":121},[192],{"type":37,"value":150},{"type":32,"tag":92,"props":194,"children":196},{"class":94,"line":195},6,[197,202,206,210],{"type":32,"tag":92,"props":198,"children":199},{"style":131},[200],{"type":37,"value":201},"  featureFlags",{"type":32,"tag":92,"props":203,"children":204},{"style":109},[205],{"type":37,"value":139},{"type":32,"tag":92,"props":207,"children":208},{"style":142},[209],{"type":37,"value":145},{"type":32,"tag":92,"props":211,"children":212},{"style":121},[213],{"type":37,"value":214},"[];\n",{"type":32,"tag":92,"props":216,"children":218},{"class":94,"line":217},7,[219],{"type":32,"tag":92,"props":220,"children":221},{"style":121},[222],{"type":37,"value":223},"}\n",{"type":32,"tag":92,"props":225,"children":227},{"class":94,"line":226},8,[228],{"type":32,"tag":92,"props":229,"children":231},{"emptyLinePlaceholder":230},true,[232],{"type":37,"value":233},"\n",{"type":32,"tag":92,"props":235,"children":236},{"class":94,"line":26},[237,242,247],{"type":32,"tag":92,"props":238,"children":239},{"style":109},[240],{"type":37,"value":241},"export",{"type":32,"tag":92,"props":243,"children":244},{"style":109},[245],{"type":37,"value":246}," default",{"type":32,"tag":92,"props":248,"children":249},{"style":121},[250],{"type":37,"value":124},{"type":32,"tag":92,"props":252,"children":254},{"class":94,"line":253},10,[255,260,265,270,275,279,284,289,294,298,303,308,312,317,322,327],{"type":32,"tag":92,"props":256,"children":257},{"style":109},[258],{"type":37,"value":259},"  async",{"type":32,"tag":92,"props":261,"children":262},{"style":115},[263],{"type":37,"value":264}," fetch",{"type":32,"tag":92,"props":266,"children":267},{"style":121},[268],{"type":37,"value":269},"(",{"type":32,"tag":92,"props":271,"children":272},{"style":131},[273],{"type":37,"value":274},"request",{"type":32,"tag":92,"props":276,"children":277},{"style":109},[278],{"type":37,"value":139},{"type":32,"tag":92,"props":280,"children":281},{"style":115},[282],{"type":37,"value":283}," Request",{"type":32,"tag":92,"props":285,"children":286},{"style":121},[287],{"type":37,"value":288},", ",{"type":32,"tag":92,"props":290,"children":291},{"style":131},[292],{"type":37,"value":293},"env",{"type":32,"tag":92,"props":295,"children":296},{"style":109},[297],{"type":37,"value":139},{"type":32,"tag":92,"props":299,"children":300},{"style":115},[301],{"type":37,"value":302}," Env",{"type":32,"tag":92,"props":304,"children":305},{"style":121},[306],{"type":37,"value":307},")",{"type":32,"tag":92,"props":309,"children":310},{"style":109},[311],{"type":37,"value":139},{"type":32,"tag":92,"props":313,"children":314},{"style":115},[315],{"type":37,"value":316}," Promise",{"type":32,"tag":92,"props":318,"children":319},{"style":121},[320],{"type":37,"value":321},"\u003C",{"type":32,"tag":92,"props":323,"children":324},{"style":115},[325],{"type":37,"value":326},"Response",{"type":32,"tag":92,"props":328,"children":329},{"style":121},[330],{"type":37,"value":331},"> {\n",{"type":32,"tag":92,"props":333,"children":335},{"class":94,"line":334},11,[336,341,346,351,356,361],{"type":32,"tag":92,"props":337,"children":338},{"style":109},[339],{"type":37,"value":340},"    const",{"type":32,"tag":92,"props":342,"children":343},{"style":142},[344],{"type":37,"value":345}," url",{"type":32,"tag":92,"props":347,"children":348},{"style":109},[349],{"type":37,"value":350}," =",{"type":32,"tag":92,"props":352,"children":353},{"style":109},[354],{"type":37,"value":355}," new",{"type":32,"tag":92,"props":357,"children":358},{"style":115},[359],{"type":37,"value":360}," URL",{"type":32,"tag":92,"props":362,"children":363},{"style":121},[364],{"type":37,"value":365},"(request.url);\n",{"type":32,"tag":92,"props":367,"children":369},{"class":94,"line":368},12,[370,374,379,383,388,393,399,404,409,414],{"type":32,"tag":92,"props":371,"children":372},{"style":109},[373],{"type":37,"value":340},{"type":32,"tag":92,"props":375,"children":376},{"style":142},[377],{"type":37,"value":378}," segmentId",{"type":32,"tag":92,"props":380,"children":381},{"style":109},[382],{"type":37,"value":350},{"type":32,"tag":92,"props":384,"children":385},{"style":115},[386],{"type":37,"value":387}," getCookie",{"type":32,"tag":92,"props":389,"children":390},{"style":121},[391],{"type":37,"value":392},"(request, ",{"type":32,"tag":92,"props":394,"children":396},{"style":395},"--shiki-default:#9ECBFF",[397],{"type":37,"value":398},"'segment_id'",{"type":32,"tag":92,"props":400,"children":401},{"style":121},[402],{"type":37,"value":403},") ",{"type":32,"tag":92,"props":405,"children":406},{"style":109},[407],{"type":37,"value":408},"||",{"type":32,"tag":92,"props":410,"children":411},{"style":395},[412],{"type":37,"value":413}," 'default'",{"type":32,"tag":92,"props":415,"children":416},{"style":121},[417],{"type":37,"value":150},{"type":32,"tag":92,"props":419,"children":421},{"class":94,"line":420},13,[422],{"type":32,"tag":92,"props":423,"children":424},{"style":121},[425],{"type":37,"value":426},"    \n",{"type":32,"tag":92,"props":428,"children":430},{"class":94,"line":429},14,[431,435,440,444,449,454,459],{"type":32,"tag":92,"props":432,"children":433},{"style":109},[434],{"type":37,"value":340},{"type":32,"tag":92,"props":436,"children":437},{"style":142},[438],{"type":37,"value":439}," configKey",{"type":32,"tag":92,"props":441,"children":442},{"style":109},[443],{"type":37,"value":350},{"type":32,"tag":92,"props":445,"children":446},{"style":395},[447],{"type":37,"value":448}," `user_segment:${",{"type":32,"tag":92,"props":450,"children":451},{"style":121},[452],{"type":37,"value":453},"segmentId",{"type":32,"tag":92,"props":455,"children":456},{"style":395},[457],{"type":37,"value":458},"}:config`",{"type":32,"tag":92,"props":460,"children":461},{"style":121},[462],{"type":37,"value":150},{"type":32,"tag":92,"props":464,"children":466},{"class":94,"line":465},15,[467,471,476,480,485,490,495,500,505],{"type":32,"tag":92,"props":468,"children":469},{"style":109},[470],{"type":37,"value":340},{"type":32,"tag":92,"props":472,"children":473},{"style":142},[474],{"type":37,"value":475}," configRaw",{"type":32,"tag":92,"props":477,"children":478},{"style":109},[479],{"type":37,"value":350},{"type":32,"tag":92,"props":481,"children":482},{"style":109},[483],{"type":37,"value":484}," await",{"type":32,"tag":92,"props":486,"children":487},{"style":121},[488],{"type":37,"value":489}," env.",{"type":32,"tag":92,"props":491,"children":492},{"style":142},[493],{"type":37,"value":494},"KV_NAMESPACE",{"type":32,"tag":92,"props":496,"children":497},{"style":121},[498],{"type":37,"value":499},".",{"type":32,"tag":92,"props":501,"children":502},{"style":115},[503],{"type":37,"value":504},"get",{"type":32,"tag":92,"props":506,"children":507},{"style":121},[508],{"type":37,"value":509},"(configKey);\n",{"type":32,"tag":92,"props":511,"children":513},{"class":94,"line":512},16,[514],{"type":32,"tag":92,"props":515,"children":516},{"style":121},[517],{"type":37,"value":426},{"type":32,"tag":92,"props":519,"children":521},{"class":94,"line":520},17,[522,527,532,537],{"type":32,"tag":92,"props":523,"children":524},{"style":109},[525],{"type":37,"value":526},"    if",{"type":32,"tag":92,"props":528,"children":529},{"style":121},[530],{"type":37,"value":531}," (",{"type":32,"tag":92,"props":533,"children":534},{"style":109},[535],{"type":37,"value":536},"!",{"type":32,"tag":92,"props":538,"children":539},{"style":121},[540],{"type":37,"value":541},"configRaw) {\n",{"type":32,"tag":92,"props":543,"children":545},{"class":94,"line":544},18,[546],{"type":32,"tag":92,"props":547,"children":548},{"style":99},[549],{"type":37,"value":550},"      \u002F\u002F Fallback: получить из origin, записать в KV\n",{"type":32,"tag":92,"props":552,"children":554},{"class":94,"line":553},19,[555,560,565,569,573,578],{"type":32,"tag":92,"props":556,"children":557},{"style":109},[558],{"type":37,"value":559},"      const",{"type":32,"tag":92,"props":561,"children":562},{"style":142},[563],{"type":37,"value":564}," originConfig",{"type":32,"tag":92,"props":566,"children":567},{"style":109},[568],{"type":37,"value":350},{"type":32,"tag":92,"props":570,"children":571},{"style":109},[572],{"type":37,"value":484},{"type":32,"tag":92,"props":574,"children":575},{"style":115},[576],{"type":37,"value":577}," fetchFromOrigin",{"type":32,"tag":92,"props":579,"children":580},{"style":121},[581],{"type":37,"value":582},"(segmentId);\n",{"type":32,"tag":92,"props":584,"children":586},{"class":94,"line":585},20,[587,592,596,600,604,609,614,619,623,628],{"type":32,"tag":92,"props":588,"children":589},{"style":109},[590],{"type":37,"value":591},"      await",{"type":32,"tag":92,"props":593,"children":594},{"style":121},[595],{"type":37,"value":489},{"type":32,"tag":92,"props":597,"children":598},{"style":142},[599],{"type":37,"value":494},{"type":32,"tag":92,"props":601,"children":602},{"style":121},[603],{"type":37,"value":499},{"type":32,"tag":92,"props":605,"children":606},{"style":115},[607],{"type":37,"value":608},"put",{"type":32,"tag":92,"props":610,"children":611},{"style":121},[612],{"type":37,"value":613},"(configKey, ",{"type":32,"tag":92,"props":615,"children":616},{"style":142},[617],{"type":37,"value":618},"JSON",{"type":32,"tag":92,"props":620,"children":621},{"style":121},[622],{"type":37,"value":499},{"type":32,"tag":92,"props":624,"children":625},{"style":115},[626],{"type":37,"value":627},"stringify",{"type":32,"tag":92,"props":629,"children":630},{"style":121},[631],{"type":37,"value":632},"(originConfig), {\n",{"type":32,"tag":92,"props":634,"children":636},{"class":94,"line":635},21,[637,642,647],{"type":32,"tag":92,"props":638,"children":639},{"style":121},[640],{"type":37,"value":641},"        expirationTtl: ",{"type":32,"tag":92,"props":643,"children":644},{"style":142},[645],{"type":37,"value":646},"3600",{"type":32,"tag":92,"props":648,"children":649},{"style":99},[650],{"type":37,"value":651}," \u002F\u002F 1 час\n",{"type":32,"tag":92,"props":653,"children":655},{"class":94,"line":654},22,[656],{"type":32,"tag":92,"props":657,"children":658},{"style":121},[659],{"type":37,"value":660},"      });\n",{"type":32,"tag":92,"props":662,"children":664},{"class":94,"line":663},23,[665,670,675],{"type":32,"tag":92,"props":666,"children":667},{"style":109},[668],{"type":37,"value":669},"      return",{"type":32,"tag":92,"props":671,"children":672},{"style":115},[673],{"type":37,"value":674}," renderPage",{"type":32,"tag":92,"props":676,"children":677},{"style":121},[678],{"type":37,"value":679},"(originConfig);\n",{"type":32,"tag":92,"props":681,"children":683},{"class":94,"line":682},24,[684],{"type":32,"tag":92,"props":685,"children":686},{"style":121},[687],{"type":37,"value":688},"    }\n",{"type":32,"tag":92,"props":690,"children":692},{"class":94,"line":691},25,[693],{"type":32,"tag":92,"props":694,"children":695},{"style":121},[696],{"type":37,"value":426},{"type":32,"tag":92,"props":698,"children":700},{"class":94,"line":699},26,[701,705,710,714,718,722,727,731,736],{"type":32,"tag":92,"props":702,"children":703},{"style":109},[704],{"type":37,"value":340},{"type":32,"tag":92,"props":706,"children":707},{"style":142},[708],{"type":37,"value":709}," config",{"type":32,"tag":92,"props":711,"children":712},{"style":109},[713],{"type":37,"value":139},{"type":32,"tag":92,"props":715,"children":716},{"style":115},[717],{"type":37,"value":118},{"type":32,"tag":92,"props":719,"children":720},{"style":109},[721],{"type":37,"value":350},{"type":32,"tag":92,"props":723,"children":724},{"style":142},[725],{"type":37,"value":726}," JSON",{"type":32,"tag":92,"props":728,"children":729},{"style":121},[730],{"type":37,"value":499},{"type":32,"tag":92,"props":732,"children":733},{"style":115},[734],{"type":37,"value":735},"parse",{"type":32,"tag":92,"props":737,"children":738},{"style":121},[739],{"type":37,"value":740},"(configRaw);\n",{"type":32,"tag":92,"props":742,"children":744},{"class":94,"line":743},27,[745,750,754],{"type":32,"tag":92,"props":746,"children":747},{"style":109},[748],{"type":37,"value":749},"    return",{"type":32,"tag":92,"props":751,"children":752},{"style":115},[753],{"type":37,"value":674},{"type":32,"tag":92,"props":755,"children":756},{"style":121},[757],{"type":37,"value":758},"(config);\n",{"type":32,"tag":92,"props":760,"children":762},{"class":94,"line":761},28,[763],{"type":32,"tag":92,"props":764,"children":765},{"style":121},[766],{"type":37,"value":767},"  }\n",{"type":32,"tag":92,"props":769,"children":771},{"class":94,"line":770},29,[772],{"type":32,"tag":92,"props":773,"children":774},{"style":121},[775],{"type":37,"value":776},"};\n",{"type":32,"tag":33,"props":778,"children":779},{},[780,782,788],{"type":37,"value":781},"Функция ",{"type":32,"tag":73,"props":783,"children":785},{"className":784},[],[786],{"type":37,"value":787},"renderPage",{"type":37,"value":789}," выполняет inline HTML string interpolation на edge — template engine не используем, потому что bundle size может упереться в лимит 128MB. Вместо этого используем литеральные строки или лёгкий JSX-to-string трансформер.",{"type":32,"tag":33,"props":791,"children":792},{},[793],{"type":37,"value":794},"KV TTL стратегия критична: с TTL 1 час мы refresh'имся из origin раз в час. Если контент меняется часто (например flash sale), TTL можно снизить до 5 минут, но это повысит origin hit rate на 15–20%. В нашем сценарии конфиг сегмента меняется 2–3 раза в день, 1 час — идеальный balance point.",{"type":32,"tag":796,"props":797,"children":799},"h3",{"id":798},"kv-write-стратегия-cache-aside-vs-write-through",[800],{"type":37,"value":801},"KV Write Стратегия: Cache-Aside vs Write-Through",{"type":32,"tag":33,"props":803,"children":804},{},[805,807,813,815,820],{"type":37,"value":806},"Две стратегии: ",{"type":32,"tag":808,"props":809,"children":810},"strong",{},[811],{"type":37,"value":812},"cache-aside",{"type":37,"value":814}," (как в примере выше — при miss берём из origin, пишем в KV) и ",{"type":32,"tag":808,"props":816,"children":817},{},[818],{"type":37,"value":819},"write-through",{"type":37,"value":821}," (при update origin webhook'ом инвалидируем KV или пишем напрямую). Мы используем cache-aside, потому что webhook latency добавляет 2–3% failure rate (network timeout, retry logic). При cache-aside первый запрос медленнее (200ms), все последующие завершаются за 40ms. На 1M pageview\u002Fдень overhead первого запроса незначителен.",{"type":32,"tag":33,"props":823,"children":824},{},[825],{"type":37,"value":826},"Если выбираете write-through, используйте Cloudflare Queue API или Vercel ISR подобный механизм — webhook не должен писать напрямую в KV, а должен push'ить в queue, worker'а consume'ить из queue и писать в KV. Это даёт retry гарантию и rate limiting.",{"type":32,"tag":40,"props":828,"children":830},{"id":829},"vercel-edge-vs-cloudflare-workers-критерии-выбора-архитектуры",[831],{"type":37,"value":832},"Vercel Edge vs Cloudflare Workers: Критерии выбора архитектуры",{"type":32,"tag":33,"props":834,"children":835},{},[836],{"type":37,"value":837},"Две платформы похожи, но имеют значимые отличия. Cloudflare Workers имеет native KV, глобальная репликация автоматическая, pricing благоприятнее для read-heavy workload ($0.50 за 10M read против Vercel Edge Redis-like pricing). Vercel Edge лучше интегрирован с Next.js, TypeScript DX сильнее, но в качестве KV альтернативы используется Vercel KV (Upstash Redis базированный) — это добавляет дополнительную latency (12–18ms против 5–10ms Cloudflare KV).",{"type":32,"tag":33,"props":839,"children":840},{},[841,843,852],{"type":37,"value":842},"Мы на Cloudflare Workers предпочитаем для ",{"type":32,"tag":844,"props":845,"children":849},"a",{"href":846,"rel":847},"https:\u002F\u002Fwww.roibase.com.tr\u002Fru\u002Fheadless",[848],"nofollow",[850],{"type":37,"value":851},"Headless",{"type":37,"value":853}," e-commerce проектов, потому что трафик read-heavy (страницы товаров, категории читаются постоянно, запись редка). Vercel Edge используем в Next.js App Router проектах как middleware — потому что API route'ы и server component'ы остаются в том же репо, deployment pipeline един.",{"type":32,"tag":33,"props":855,"children":856},{},[857],{"type":37,"value":858},"Benchmark: запустили ту же logic персонализации на обеих платформах. Cloudflare Workers P95 latency 42ms, Vercel Edge P95 latency 58ms (из-за Vercel KV overhead). CPU использование похожее (15–20ms), разница в storage read latency.",{"type":32,"tag":40,"props":860,"children":862},{"id":861},"оптимизация-cold-start-и-bundle-size",[863],{"type":37,"value":864},"Оптимизация Cold Start и Bundle Size",{"type":32,"tag":33,"props":866,"children":867},{},[868],{"type":37,"value":869},"Хотя edge runtime'ы имеют низкий cold start, большой bundle size создаёт проблемы. Cloudflare Workers имеет лимит 1MB на script размер (compressed), Vercel Edge принимает ~1MB bundle но с ростом cold start увеличивается. Вот тактики которые мы применяем:",{"type":32,"tag":33,"props":871,"children":872},{},[873,878,880,886,888,894,896,902,903,909],{"type":32,"tag":808,"props":874,"children":875},{},[876],{"type":37,"value":877},"1. Pruning зависимостей:",{"type":37,"value":879}," ",{"type":32,"tag":73,"props":881,"children":883},{"className":882},[],[884],{"type":37,"value":885},"lodash",{"type":37,"value":887}," → ",{"type":32,"tag":73,"props":889,"children":891},{"className":890},[],[892],{"type":37,"value":893},"lodash-es",{"type":37,"value":895}," (tree-shakeable), ",{"type":32,"tag":73,"props":897,"children":899},{"className":898},[],[900],{"type":37,"value":901},"moment",{"type":37,"value":887},{"type":32,"tag":73,"props":904,"children":906},{"className":905},[],[907],{"type":37,"value":908},"date-fns",{"type":37,"value":910},". С analyzer'ом bundle'а удалили неиспользуемые модули — с 340KB до 180KB.",{"type":32,"tag":33,"props":912,"children":913},{},[914,919,921,927],{"type":32,"tag":808,"props":915,"children":916},{},[917],{"type":37,"value":918},"2. Запрет динамического import'а:",{"type":37,"value":920}," На edge динамический ",{"type":32,"tag":73,"props":922,"children":924},{"className":923},[],[925],{"type":37,"value":926},"import()",{"type":37,"value":928}," увеличивает cold start на 30–50ms. Все зависимости импортируйте статично, дайте bundler'у возможность делать tree-shaking.",{"type":32,"tag":33,"props":930,"children":931},{},[932,937],{"type":32,"tag":808,"props":933,"children":934},{},[935],{"type":37,"value":936},"3. Inline критичного кода:",{"type":37,"value":938}," Если logic персонализации это 40–50 строк — пишите inline вместо отдельного модуля. Module resolution добавляет даже 2–3ms.",{"type":32,"tag":82,"props":940,"children":942},{"className":84,"code":941,"language":86,"meta":16,"style":16},"\u002F\u002F ❌ Плохо: отдельный модуль\nimport { renderHero } from '.\u002FheroRenderer';\n\n\u002F\u002F ✅ Хорошо: inline\nfunction renderHero(config: UserSegmentConfig): string {\n  return `\u003Cdiv class=\"hero\">${config.heroImage}\u003C\u002Fdiv>`;\n}\n",[943],{"type":32,"tag":73,"props":944,"children":945},{"__ignoreMap":16},[946,954,981,988,996,1042,1077],{"type":32,"tag":92,"props":947,"children":948},{"class":94,"line":95},[949],{"type":32,"tag":92,"props":950,"children":951},{"style":99},[952],{"type":37,"value":953},"\u002F\u002F ❌ Плохо: отдельный модуль\n",{"type":32,"tag":92,"props":955,"children":956},{"class":94,"line":105},[957,962,967,972,977],{"type":32,"tag":92,"props":958,"children":959},{"style":109},[960],{"type":37,"value":961},"import",{"type":32,"tag":92,"props":963,"children":964},{"style":121},[965],{"type":37,"value":966}," { renderHero } ",{"type":32,"tag":92,"props":968,"children":969},{"style":109},[970],{"type":37,"value":971},"from",{"type":32,"tag":92,"props":973,"children":974},{"style":395},[975],{"type":37,"value":976}," '.\u002FheroRenderer'",{"type":32,"tag":92,"props":978,"children":979},{"style":121},[980],{"type":37,"value":150},{"type":32,"tag":92,"props":982,"children":983},{"class":94,"line":127},[984],{"type":32,"tag":92,"props":985,"children":986},{"emptyLinePlaceholder":230},[987],{"type":37,"value":233},{"type":32,"tag":92,"props":989,"children":990},{"class":94,"line":153},[991],{"type":32,"tag":92,"props":992,"children":993},{"style":99},[994],{"type":37,"value":995},"\u002F\u002F ✅ Хорошо: inline\n",{"type":32,"tag":92,"props":997,"children":998},{"class":94,"line":174},[999,1004,1009,1013,1018,1022,1026,1030,1034,1038],{"type":32,"tag":92,"props":1000,"children":1001},{"style":109},[1002],{"type":37,"value":1003},"function",{"type":32,"tag":92,"props":1005,"children":1006},{"style":115},[1007],{"type":37,"value":1008}," renderHero",{"type":32,"tag":92,"props":1010,"children":1011},{"style":121},[1012],{"type":37,"value":269},{"type":32,"tag":92,"props":1014,"children":1015},{"style":131},[1016],{"type":37,"value":1017},"config",{"type":32,"tag":92,"props":1019,"children":1020},{"style":109},[1021],{"type":37,"value":139},{"type":32,"tag":92,"props":1023,"children":1024},{"style":115},[1025],{"type":37,"value":118},{"type":32,"tag":92,"props":1027,"children":1028},{"style":121},[1029],{"type":37,"value":307},{"type":32,"tag":92,"props":1031,"children":1032},{"style":109},[1033],{"type":37,"value":139},{"type":32,"tag":92,"props":1035,"children":1036},{"style":142},[1037],{"type":37,"value":145},{"type":32,"tag":92,"props":1039,"children":1040},{"style":121},[1041],{"type":37,"value":124},{"type":32,"tag":92,"props":1043,"children":1044},{"class":94,"line":195},[1045,1050,1055,1059,1063,1068,1073],{"type":32,"tag":92,"props":1046,"children":1047},{"style":109},[1048],{"type":37,"value":1049},"  return",{"type":32,"tag":92,"props":1051,"children":1052},{"style":395},[1053],{"type":37,"value":1054}," `\u003Cdiv class=\"hero\">${",{"type":32,"tag":92,"props":1056,"children":1057},{"style":121},[1058],{"type":37,"value":1017},{"type":32,"tag":92,"props":1060,"children":1061},{"style":395},[1062],{"type":37,"value":499},{"type":32,"tag":92,"props":1064,"children":1065},{"style":121},[1066],{"type":37,"value":1067},"heroImage",{"type":32,"tag":92,"props":1069,"children":1070},{"style":395},[1071],{"type":37,"value":1072},"}\u003C\u002Fdiv>`",{"type":32,"tag":92,"props":1074,"children":1075},{"style":121},[1076],{"type":37,"value":150},{"type":32,"tag":92,"props":1078,"children":1079},{"class":94,"line":217},[1080],{"type":32,"tag":92,"props":1081,"children":1082},{"style":121},[1083],{"type":37,"value":223},{"type":32,"tag":33,"props":1085,"children":1086},{},[1087,1092],{"type":32,"tag":808,"props":1088,"children":1089},{},[1090],{"type":37,"value":1091},"4. Wasm использование:",{"type":37,"value":1093}," Если нужны тяжёлые операции (JSON schema валидация, markdown parsing) — пишите на Rust или Go, скомпилируйте в Wasm. Wasm модуль будет 50–80KB, экономия JavaScript bundle'а 200–300KB. Однако Wasm instantiation добавляет 10–15ms — взвесьте tradeoff.",{"type":32,"tag":40,"props":1095,"children":1097},{"id":1096},"monitoring-и-гарантия-latency",[1098],{"type":37,"value":1099},"Monitoring и гарантия latency",{"type":32,"tag":33,"props":1101,"children":1102},{},[1103],{"type":37,"value":1104},"Для гарантии 40ms latency target'а устанавливаем RUM и synthetic monitoring. Cloudflare Workers Analytics API предоставляет P50\u002FP95\u002FP99 latency метрики, отправляем их в Grafana. Alarm threshold: если P95 > 60ms — alert.",{"type":32,"tag":82,"props":1106,"children":1108},{"className":84,"code":1107,"language":86,"meta":16,"style":16},"\u002F\u002F Пример Analytics Event для Workers\nexport default {\n  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise\u003CResponse> {\n    const startTime = Date.now();\n    const response = await handleRequest(request, env);\n    const duration = Date.now() - startTime;\n    \n    ctx.waitUntil(\n      env.ANALYTICS.writeDataPoint({\n        blobs: [request.url],\n        doubles: [duration],\n        indexes: [request.headers.get('cf-ray') || '']\n      })\n    );\n    \n    return response;\n  }\n};\n",[1109],{"type":32,"tag":73,"props":1110,"children":1111},{"__ignoreMap":16},[1112,1120,1135,1220,1251,1281,1320,1327,1345,1372,1380,1388,1427,1435,1443,1450,1462,1469],{"type":32,"tag":92,"props":1113,"children":1114},{"class":94,"line":95},[1115],{"type":32,"tag":92,"props":1116,"children":1117},{"style":99},[1118],{"type":37,"value":1119},"\u002F\u002F Пример Analytics Event для Workers\n",{"type":32,"tag":92,"props":1121,"children":1122},{"class":94,"line":105},[1123,1127,1131],{"type":32,"tag":92,"props":1124,"children":1125},{"style":109},[1126],{"type":37,"value":241},{"type":32,"tag":92,"props":1128,"children":1129},{"style":109},[1130],{"type":37,"value":246},{"type":32,"tag":92,"props":1132,"children":1133},{"style":121},[1134],{"type":37,"value":124},{"type":32,"tag":92,"props":1136,"children":1137},{"class":94,"line":127},[1138,1142,1146,1150,1154,1158,1162,1166,1170,1174,1178,1182,1187,1191,1196,1200,1204,1208,1212,1216],{"type":32,"tag":92,"props":1139,"children":1140},{"style":109},[1141],{"type":37,"value":259},{"type":32,"tag":92,"props":1143,"children":1144},{"style":115},[1145],{"type":37,"value":264},{"type":32,"tag":92,"props":1147,"children":1148},{"style":121},[1149],{"type":37,"value":269},{"type":32,"tag":92,"props":1151,"children":1152},{"style":131},[1153],{"type":37,"value":274},{"type":32,"tag":92,"props":1155,"children":1156},{"style":109},[1157],{"type":37,"value":139},{"type":32,"tag":92,"props":1159,"children":1160},{"style":115},[1161],{"type":37,"value":283},{"type":32,"tag":92,"props":1163,"children":1164},{"style":121},[1165],{"type":37,"value":288},{"type":32,"tag":92,"props":1167,"children":1168},{"style":131},[1169],{"type":37,"value":293},{"type":32,"tag":92,"props":1171,"children":1172},{"style":109},[1173],{"type":37,"value":139},{"type":32,"tag":92,"props":1175,"children":1176},{"style":115},[1177],{"type":37,"value":302},{"type":32,"tag":92,"props":1179,"children":1180},{"style":121},[1181],{"type":37,"value":288},{"type":32,"tag":92,"props":1183,"children":1184},{"style":131},[1185],{"type":37,"value":1186},"ctx",{"type":32,"tag":92,"props":1188,"children":1189},{"style":109},[1190],{"type":37,"value":139},{"type":32,"tag":92,"props":1192,"children":1193},{"style":115},[1194],{"type":37,"value":1195}," ExecutionContext",{"type":32,"tag":92,"props":1197,"children":1198},{"style":121},[1199],{"type":37,"value":307},{"type":32,"tag":92,"props":1201,"children":1202},{"style":109},[1203],{"type":37,"value":139},{"type":32,"tag":92,"props":1205,"children":1206},{"style":115},[1207],{"type":37,"value":316},{"type":32,"tag":92,"props":1209,"children":1210},{"style":121},[1211],{"type":37,"value":321},{"type":32,"tag":92,"props":1213,"children":1214},{"style":115},[1215],{"type":37,"value":326},{"type":32,"tag":92,"props":1217,"children":1218},{"style":121},[1219],{"type":37,"value":331},{"type":32,"tag":92,"props":1221,"children":1222},{"class":94,"line":153},[1223,1227,1232,1236,1241,1246],{"type":32,"tag":92,"props":1224,"children":1225},{"style":109},[1226],{"type":37,"value":340},{"type":32,"tag":92,"props":1228,"children":1229},{"style":142},[1230],{"type":37,"value":1231}," startTime",{"type":32,"tag":92,"props":1233,"children":1234},{"style":109},[1235],{"type":37,"value":350},{"type":32,"tag":92,"props":1237,"children":1238},{"style":121},[1239],{"type":37,"value":1240}," Date.",{"type":32,"tag":92,"props":1242,"children":1243},{"style":115},[1244],{"type":37,"value":1245},"now",{"type":32,"tag":92,"props":1247,"children":1248},{"style":121},[1249],{"type":37,"value":1250},"();\n",{"type":32,"tag":92,"props":1252,"children":1253},{"class":94,"line":174},[1254,1258,1263,1267,1271,1276],{"type":32,"tag":92,"props":1255,"children":1256},{"style":109},[1257],{"type":37,"value":340},{"type":32,"tag":92,"props":1259,"children":1260},{"style":142},[1261],{"type":37,"value":1262}," response",{"type":32,"tag":92,"props":1264,"children":1265},{"style":109},[1266],{"type":37,"value":350},{"type":32,"tag":92,"props":1268,"children":1269},{"style":109},[1270],{"type":37,"value":484},{"type":32,"tag":92,"props":1272,"children":1273},{"style":115},[1274],{"type":37,"value":1275}," handleRequest",{"type":32,"tag":92,"props":1277,"children":1278},{"style":121},[1279],{"type":37,"value":1280},"(request, env);\n",{"type":32,"tag":92,"props":1282,"children":1283},{"class":94,"line":195},[1284,1288,1293,1297,1301,1305,1310,1315],{"type":32,"tag":92,"props":1285,"children":1286},{"style":109},[1287],{"type":37,"value":340},{"type":32,"tag":92,"props":1289,"children":1290},{"style":142},[1291],{"type":37,"value":1292}," duration",{"type":32,"tag":92,"props":1294,"children":1295},{"style":109},[1296],{"type":37,"value":350},{"type":32,"tag":92,"props":1298,"children":1299},{"style":121},[1300],{"type":37,"value":1240},{"type":32,"tag":92,"props":1302,"children":1303},{"style":115},[1304],{"type":37,"value":1245},{"type":32,"tag":92,"props":1306,"children":1307},{"style":121},[1308],{"type":37,"value":1309},"() ",{"type":32,"tag":92,"props":1311,"children":1312},{"style":109},[1313],{"type":37,"value":1314},"-",{"type":32,"tag":92,"props":1316,"children":1317},{"style":121},[1318],{"type":37,"value":1319}," startTime;\n",{"type":32,"tag":92,"props":1321,"children":1322},{"class":94,"line":217},[1323],{"type":32,"tag":92,"props":1324,"children":1325},{"style":121},[1326],{"type":37,"value":426},{"type":32,"tag":92,"props":1328,"children":1329},{"class":94,"line":226},[1330,1335,1340],{"type":32,"tag":92,"props":1331,"children":1332},{"style":121},[1333],{"type":37,"value":1334},"    ctx.",{"type":32,"tag":92,"props":1336,"children":1337},{"style":115},[1338],{"type":37,"value":1339},"waitUntil",{"type":32,"tag":92,"props":1341,"children":1342},{"style":121},[1343],{"type":37,"value":1344},"(\n",{"type":32,"tag":92,"props":1346,"children":1347},{"class":94,"line":26},[1348,1353,1358,1362,1367],{"type":32,"tag":92,"props":1349,"children":1350},{"style":121},[1351],{"type":37,"value":1352},"      env.",{"type":32,"tag":92,"props":1354,"children":1355},{"style":142},[1356],{"type":37,"value":1357},"ANALYTICS",{"type":32,"tag":92,"props":1359,"children":1360},{"style":121},[1361],{"type":37,"value":499},{"type":32,"tag":92,"props":1363,"children":1364},{"style":115},[1365],{"type":37,"value":1366},"writeDataPoint",{"type":32,"tag":92,"props":1368,"children":1369},{"style":121},[1370],{"type":37,"value":1371},"({\n",{"type":32,"tag":92,"props":1373,"children":1374},{"class":94,"line":253},[1375],{"type":32,"tag":92,"props":1376,"children":1377},{"style":121},[1378],{"type":37,"value":1379},"        blobs: [request.url],\n",{"type":32,"tag":92,"props":1381,"children":1382},{"class":94,"line":334},[1383],{"type":32,"tag":92,"props":1384,"children":1385},{"style":121},[1386],{"type":37,"value":1387},"        doubles: [duration],\n",{"type":32,"tag":92,"props":1389,"children":1390},{"class":94,"line":368},[1391,1396,1400,1404,1409,1413,1417,1422],{"type":32,"tag":92,"props":1392,"children":1393},{"style":121},[1394],{"type":37,"value":1395},"        indexes: [request.headers.",{"type":32,"tag":92,"props":1397,"children":1398},{"style":115},[1399],{"type":37,"value":504},{"type":32,"tag":92,"props":1401,"children":1402},{"style":121},[1403],{"type":37,"value":269},{"type":32,"tag":92,"props":1405,"children":1406},{"style":395},[1407],{"type":37,"value":1408},"'cf-ray'",{"type":32,"tag":92,"props":1410,"children":1411},{"style":121},[1412],{"type":37,"value":403},{"type":32,"tag":92,"props":1414,"children":1415},{"style":109},[1416],{"type":37,"value":408},{"type":32,"tag":92,"props":1418,"children":1419},{"style":395},[1420],{"type":37,"value":1421}," ''",{"type":32,"tag":92,"props":1423,"children":1424},{"style":121},[1425],{"type":37,"value":1426},"]\n",{"type":32,"tag":92,"props":1428,"children":1429},{"class":94,"line":420},[1430],{"type":32,"tag":92,"props":1431,"children":1432},{"style":121},[1433],{"type":37,"value":1434},"      })\n",{"type":32,"tag":92,"props":1436,"children":1437},{"class":94,"line":429},[1438],{"type":32,"tag":92,"props":1439,"children":1440},{"style":121},[1441],{"type":37,"value":1442},"    );\n",{"type":32,"tag":92,"props":1444,"children":1445},{"class":94,"line":465},[1446],{"type":32,"tag":92,"props":1447,"children":1448},{"style":121},[1449],{"type":37,"value":426},{"type":32,"tag":92,"props":1451,"children":1452},{"class":94,"line":512},[1453,1457],{"type":32,"tag":92,"props":1454,"children":1455},{"style":109},[1456],{"type":37,"value":749},{"type":32,"tag":92,"props":1458,"children":1459},{"style":121},[1460],{"type":37,"value":1461}," response;\n",{"type":32,"tag":92,"props":1463,"children":1464},{"class":94,"line":520},[1465],{"type":32,"tag":92,"props":1466,"children":1467},{"style":121},[1468],{"type":37,"value":767},{"type":32,"tag":92,"props":1470,"children":1471},{"class":94,"line":544},[1472],{"type":32,"tag":92,"props":1473,"children":1474},{"style":121},[1475],{"type":37,"value":776},{"type":32,"tag":33,"props":1477,"children":1478},{},[1479,1485,1487,1493],{"type":32,"tag":73,"props":1480,"children":1482},{"className":1481},[],[1483],{"type":37,"value":1484},"ctx.waitUntil",{"type":37,"value":1486}," выполняет асинхронную запись аналитики не добавляя к response latency — критично. Если использовать ",{"type":32,"tag":73,"props":1488,"children":1490},{"className":1489},[],[1491],{"type":37,"value":1492},"await",{"type":37,"value":1494},", каждый запрос получит +5–10ms.",{"type":32,"tag":33,"props":1496,"children":1497},{},[1498],{"type":37,"value":1499},"Для synthetic monitoring используем Checkly или Pingdom — 5 географических локаций, 1 запрос в минуту, latency > 70ms → Slack alert. Так мы детектируем edge node деградацию за 3–5 минут.",{"type":32,"tag":40,"props":1501,"children":1503},{"id":1502},"origin-fallback-и-graceful-degradation",[1504],{"type":37,"value":1505},"Origin Fallback и graceful degradation",{"type":32,"tag":33,"props":1507,"children":1508},{},[1509],{"type":37,"value":1510},"Не всё можно handle'ить на edge — KV timeout, CPU лимит, неожиданная ошибка. В таких случаях нужен fallback на origin. Вот стратегия которую мы выбрали: если edge error rate > 1% в течение 10 минут, весь трафик направляется в origin на 10 минут, затем возвращаемся на edge.",{"type":32,"tag":82,"props":1512,"children":1514},{"className":84,"code":1513,"language":86,"meta":16,"style":16},"async function handleWithFallback(request: Request, env: Env): Promise\u003CResponse> {\n  try {\n    const edgeResponse = await renderEdge(request, env);\n    return edgeResponse;\n  } catch (error) {\n    \u002F\u002F Log to Sentry\u002FDatadog\n    console.error('Edge render failed:', error);\n    \n    \u002F\u002F Proxy в origin\n    return fetch(request.url, {\n      headers: request.headers,\n      cf: { cacheEverything: true }\n    });\n  }\n}\n",[1515],{"type":32,"tag":73,"props":1516,"children":1517},{"__ignoreMap":16},[1518,1592,1604,1633,1645,1663,1671,1698,1705,1713,1729,1737,1755,1763,1770],{"type":32,"tag":92,"props":1519,"children":1520},{"class":94,"line":95},[1521,1526,1531,1536,1540,1544,1548,1552,1556,1560,1564,1568,1572,1576,1580,1584,1588],{"type":32,"tag":92,"props":1522,"children":1523},{"style":109},[1524],{"type":37,"value":1525},"async",{"type":32,"tag":92,"props":1527,"children":1528},{"style":109},[1529],{"type":37,"value":1530}," function",{"type":32,"tag":92,"props":1532,"children":1533},{"style":115},[1534],{"type":37,"value":1535}," handleWithFallback",{"type":32,"tag":92,"props":1537,"children":1538},{"style":121},[1539],{"type":37,"value":269},{"type":32,"tag":92,"props":1541,"children":1542},{"style":131},[1543],{"type":37,"value":274},{"type":32,"tag":92,"props":1545,"children":1546},{"style":109},[1547],{"type":37,"value":139},{"type":32,"tag":92,"props":1549,"children":1550},{"style":115},[1551],{"type":37,"value":283},{"type":32,"tag":92,"props":1553,"children":1554},{"style":121},[1555],{"type":37,"value":288},{"type":32,"tag":92,"props":1557,"children":1558},{"style":131},[1559],{"type":37,"value":293},{"type":32,"tag":92,"props":1561,"children":1562},{"style":109},[1563],{"type":37,"value":139},{"type":32,"tag":92,"props":1565,"children":1566},{"style":115},[1567],{"type":37,"value":302},{"type":32,"tag":92,"props":1569,"children":1570},{"style":121},[1571],{"type":37,"value":307},{"type":32,"tag":92,"props":1573,"children":1574},{"style":109},[1575],{"type":37,"value":139},{"type":32,"tag":92,"props":1577,"children":1578},{"style":115},[1579],{"type":37,"value":316},{"type":32,"tag":92,"props":1581,"children":1582},{"style":121},[1583],{"type":37,"value":321},{"type":32,"tag":92,"props":1585,"children":1586},{"style":115},[1587],{"type":37,"value":326},{"type":32,"tag":92,"props":1589,"children":1590},{"style":121},[1591],{"type":37,"value":331},{"type":32,"tag":92,"props":1593,"children":1594},{"class":94,"line":105},[1595,1600],{"type":32,"tag":92,"props":1596,"children":1597},{"style":109},[1598],{"type":37,"value":1599},"  try",{"type":32,"tag":92,"props":1601,"children":1602},{"style":121},[1603],{"type":37,"value":124},{"type":32,"tag":92,"props":1605,"children":1606},{"class":94,"line":127},[1607,1611,1616,1620,1624,1629],{"type":32,"tag":92,"props":1608,"children":1609},{"style":109},[1610],{"type":37,"value":340},{"type":32,"tag":92,"props":1612,"children":1613},{"style":142},[1614],{"type":37,"value":1615}," edgeResponse",{"type":32,"tag":92,"props":1617,"children":1618},{"style":109},[1619],{"type":37,"value":350},{"type":32,"tag":92,"props":1621,"children":1622},{"style":109},[1623],{"type":37,"value":484},{"type":32,"tag":92,"props":1625,"children":1626},{"style":115},[1627],{"type":37,"value":1628}," renderEdge",{"type":32,"tag":92,"props":1630,"children":1631},{"style":121},[1632],{"type":37,"value":1280},{"type":32,"tag":92,"props":1634,"children":1635},{"class":94,"line":153},[1636,1640],{"type":32,"tag":92,"props":1637,"children":1638},{"style":109},[1639],{"type":37,"value":749},{"type":32,"tag":92,"props":1641,"children":1642},{"style":121},[1643],{"type":37,"value":1644}," edgeResponse;\n",{"type":32,"tag":92,"props":1646,"children":1647},{"class":94,"line":174},[1648,1653,1658],{"type":32,"tag":92,"props":1649,"children":1650},{"style":121},[1651],{"type":37,"value":1652},"  } ",{"type":32,"tag":92,"props":1654,"children":1655},{"style":109},[1656],{"type":37,"value":1657},"catch",{"type":32,"tag":92,"props":1659,"children":1660},{"style":121},[1661],{"type":37,"value":1662}," (error) {\n",{"type":32,"tag":92,"props":1664,"children":1665},{"class":94,"line":195},[1666],{"type":32,"tag":92,"props":1667,"children":1668},{"style":99},[1669],{"type":37,"value":1670},"    \u002F\u002F Log to Sentry\u002FDatadog\n",{"type":32,"tag":92,"props":1672,"children":1673},{"class":94,"line":217},[1674,1679,1684,1688,1693],{"type":32,"tag":92,"props":1675,"children":1676},{"style":121},[1677],{"type":37,"value":1678},"    console.",{"type":32,"tag":92,"props":1680,"children":1681},{"style":115},[1682],{"type":37,"value":1683},"error",{"type":32,"tag":92,"props":1685,"children":1686},{"style":121},[1687],{"type":37,"value":269},{"type":32,"tag":92,"props":1689,"children":1690},{"style":395},[1691],{"type":37,"value":1692},"'Edge render failed:'",{"type":32,"tag":92,"props":1694,"children":1695},{"style":121},[1696],{"type":37,"value":1697},", error);\n",{"type":32,"tag":92,"props":1699,"children":1700},{"class":94,"line":226},[1701],{"type":32,"tag":92,"props":1702,"children":1703},{"style":121},[1704],{"type":37,"value":426},{"type":32,"tag":92,"props":1706,"children":1707},{"class":94,"line":26},[1708],{"type":32,"tag":92,"props":1709,"children":1710},{"style":99},[1711],{"type":37,"value":1712},"    \u002F\u002F Proxy в origin\n",{"type":32,"tag":92,"props":1714,"children":1715},{"class":94,"line":253},[1716,1720,1724],{"type":32,"tag":92,"props":1717,"children":1718},{"style":109},[1719],{"type":37,"value":749},{"type":32,"tag":92,"props":1721,"children":1722},{"style":115},[1723],{"type":37,"value":264},{"type":32,"tag":92,"props":1725,"children":1726},{"style":121},[1727],{"type":37,"value":1728},"(request.url, {\n",{"type":32,"tag":92,"props":1730,"children":1731},{"class":94,"line":334},[1732],{"type":32,"tag":92,"props":1733,"children":1734},{"style":121},[1735],{"type":37,"value":1736},"      headers: request.headers,\n",{"type":32,"tag":92,"props":1738,"children":1739},{"class":94,"line":368},[1740,1745,1750],{"type":32,"tag":92,"props":1741,"children":1742},{"style":121},[1743],{"type":37,"value":1744},"      cf: { cacheEverything: ",{"type":32,"tag":92,"props":1746,"children":1747},{"style":142},[1748],{"type":37,"value":1749},"true",{"type":32,"tag":92,"props":1751,"children":1752},{"style":121},[1753],{"type":37,"value":1754}," }\n",{"type":32,"tag":92,"props":1756,"children":1757},{"class":94,"line":420},[1758],{"type":32,"tag":92,"props":1759,"children":1760},{"style":121},[1761],{"type":37,"value":1762},"    });\n",{"type":32,"tag":92,"props":1764,"children":1765},{"class":94,"line":429},[1766],{"type":32,"tag":92,"props":1767,"children":1768},{"style":121},[1769],{"type":37,"value":767},{"type":32,"tag":92,"props":1771,"children":1772},{"class":94,"line":465},[1773],{"type":32,"tag":92,"props":1774,"children":1775},{"style":121},[1776],{"type":37,"value":223},{"type":32,"tag":33,"props":1778,"children":1779},{},[1780],{"type":37,"value":1781},"Этот fallback механизм даёт %99.8 uptime. Когда edge fails, latency растёт до 200–250ms (origin SSR), но user experience сохраняется. Альтернатива: возвращать статический fallback HTML при edge ошибке — но это недопустимо в e-commerce (потеря персонализации = потеря conversions).",{"type":32,"tag":40,"props":1783,"children":1785},{"id":1784},"production-результаты-и-сравнение",[1786],{"type":37,"value":1787},"Production результаты и сравнение",{"type":32,"tag":33,"props":1789,"children":1790},{},[1791],{"type":37,"value":1792},"За 6 месяцев на production с 12M pageview видели такие числа: P50 latency 38ms, P95 latency 54ms, P99 latency 89ms (P99 где origin fallback активируется). Сравнение с origin SSR: P50 220ms → 38ms (83% снижение), P95 380ms → 54ms (86% снижение).",{"type":32,"tag":33,"props":1794,"children":1795},{},[1796],{"type":37,"value":1797},"Core Web Vitals эффект: LCP 2.4s → 1.1s (hero image персонализация рендерится на edge), FCP 1.8s → 0.9s, TBT не изменилось (JavaScript bundle одинаков). Conversion rate выросла на 2.8% (A\u002FB test, 95% confidence) — latency снижение напрямую отразилось на business метриках.",{"type":32,"tag":33,"props":1799,"children":1800},{},[1801],{"type":37,"value":1802},"Стоимость: Cloudflare Workers + KV $180\u002Fмесяц (10M request, 50M KV read), origin SSR EC2 instance стоил $420. 57% снижение стоимости + 86% снижение latency. ROI расчёт: development effort 120 часов (2 week sprint), payback period 2 месяца.",{"type":32,"tag":33,"props":1804,"children":1805},{},[1806],{"type":37,"value":1807},"Edge SSR архитектура не magic bullet — без правильного data modeling'а, KV стратегии и fallback механизма потерпит неудачу. Но когда эти три компонента продуманы правильно, 40ms latency становится гарантируемым target'ом.",{"type":32,"tag":1809,"props":1810,"children":1811},"style",{},[1812],{"type":37,"value":1813},"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);}",{"title":16,"searchDepth":127,"depth":127,"links":1815},[1816,1817,1820,1821,1822,1823,1824],{"id":42,"depth":105,"text":45},{"id":63,"depth":105,"text":66,"children":1818},[1819],{"id":798,"depth":127,"text":801},{"id":829,"depth":105,"text":832},{"id":861,"depth":105,"text":864},{"id":1096,"depth":105,"text":1099},{"id":1502,"depth":105,"text":1505},{"id":1784,"depth":105,"text":1787},"markdown","content:ru:tech:optimizacija-personalizacije-latentnosti-edge-ssr-40ms.md","content","ru\u002Ftech\u002Foptimizacija-personalizacije-latentnosti-edge-ssr-40ms.md","ru\u002Ftech\u002Foptimizacija-personalizacije-latentnosti-edge-ssr-40ms","md",1786860295061]