When a high-traffic Costa Rican marketplace needed sub-100ms response times across Latin America, we moved their Next.js middleware to Vercel Edge Functions — cutting time-to-first-byte by 40% without re-architecting the monolith.
The client operated a B2C marketplace processing over 12,000 concurrent sessions during peak hours. Their existing Next.js application ran on a single-region Node.js deployment in us-east-1, which meant users in San José, Bogotá, and Mexico City were consistently hitting 280ms+ TTFB on server-rendered pages. For a commerce platform where every 100ms of latency correlates with measurable cart abandonment, this was a revenue problem disguised as an infrastructure problem.
Our approach was surgical. Rather than migrating the entire application to an edge-first architecture, we identified the critical rendering paths — product listing pages, search results, and the authentication middleware — and isolated them into Edge Functions. The key insight was that these routes were already doing lightweight computation: reading cookies, applying geolocation-based pricing logic, and rewriting URLs for A/B tests. None of them needed a full Node.js runtime. By rewriting these as Edge Middleware running on Vercel’s global network, we moved the computation from a single data center to 23 edge locations across the Americas. The remaining API routes — cart operations, checkout, inventory writes — stayed on the origin server where they needed transactional database access.
The migration itself took three two-week sprints. Sprint one focused on auditing every middleware function for Node.js API dependencies that the Edge Runtime doesn’t support — we replaced three uses of the crypto module with the Web Crypto API and swapped a Buffer-based JWT decoder for a pure Web API implementation. Sprint two was the incremental rollout: we deployed edge middleware behind feature flags, routing 5% of traffic through the new path while monitoring error rates and response times in Datadog. By sprint three, 100% of eligible traffic was running at the edge, and the team shifted focus to performance tuning — implementing stale-while-revalidate caching headers and optimizing the geolocation pricing lookup from a database call to an in-memory KV store on Vercel Edge Config.
Results landed hard. Median TTFB dropped from 274ms to 164ms globally, with Costa Rican users seeing 89ms — a 68% improvement for the home market. The marketplace reported a 12% increase in pages-per-session and a 7% lift in conversion rate during the first 30 days post-deployment. Infrastructure costs actually decreased by 15% because the origin server was handling significantly fewer requests, allowing the team to scale down from three ECS tasks to two. The entire project validated a principle we apply across engagements at Gianko: you don’t always need a rewrite — sometimes the highest-leverage move is deploying the right 200 lines of code to the right place on the network.



