June 3, 2026
9 min read
Infrastructure for Headless Ecommerce: Key Decisions Before Going to Production
What infrastructure a headless ecommerce needs before launch: hosting, database, CDN, observability, and security without over-engineering.
Leer en espanolInfrastructure decisions that cannot be deferred
In a headless ecommerce, the team is responsible for more infrastructure than on Shopify or managed WooCommerce. The backend engine, the database, the cache layer, job workers, and the frontend server are separate components that need to be operated, monitored, and updated.
Not all those decisions need to be perfect from day one, but some cannot be deferred: the production database, the secrets management strategy, and the logging system. Starting with SQLite in production or with credentials in unmanaged environment variables creates debt that is expensive to resolve later.
Frontend: CDN, SSR, and edge rendering
A Next.js or Astro ecommerce frontend can be served in several ways: fully static with CDN (maximum performance, content that changes rarely), SSR per request (personalized content, higher server load), or hybrid with ISR (static pages regenerated in the background). The choice affects cost, latency, and operational complexity.
For most ecommerce, the hybrid pattern is correct: category and product pages as static with periodic revalidation, cart and checkout fully dynamic. Vercel, Cloudflare Pages, and AWS CloudFront all support that pattern with minimal configuration.
- Catalog pages: SSG with revalidation (ISR) — low cost, high performance.
- Cart and checkout: SSR or client-side — always dynamic, no page cache.
- Product images: CDN with automatic optimization (Cloudinary, Imgix, or Next/Image).
Backend and database: right-sizing from the start
Medusa and similar engines run well on small instances if the database is well-indexed and cache is active. For an initial launch, a 2 vCPU and 4 GB RAM instance with PostgreSQL on RDS or Railway handles several thousand orders per month. The common mistake is over-provisioning compute and under-provisioning the database.
PostgreSQL needs automated backups, point-in-time recovery, and at least one read replica if reporting traffic competes with store traffic. Those three things matter more than the size of the primary instance.
Observability: logs, metrics, and alerts from day one
Operating without observability in a production ecommerce means operating blind. The three minimum instruments are: structured logs with clear severity levels (info for normal flows, error for exceptions, warn for unexpected but recoverable situations), latency and error rate metrics on critical endpoints, and alerts that notify when the error rate rises or checkout response time exceeds a threshold.
Datadog, Grafana Cloud, and Axiom are viable options with free tiers sufficient to start. The tool matters less than the habit of reviewing logs after every deploy and having alerts configured before receiving the first real order.
More articles
Back to articlesPayment Platforms in Mexico: Stripe, Conekta, Mercado Pago, and OpenPay
A technical and commercial comparison of the four most-used payment platforms for digital projects in Mexico.
June 3, 2026
7 min read
Shipping Platforms in Mexico: Skydropx, EnviosPerros, Pakke, and Enviame
How to choose between the main shipping aggregators for ecommerce in Mexico based on your volume, operations, and technical needs.
June 3, 2026
7 min read
Headless CMS in 2026: PayloadCMS, Strapi, Sanity, and Directus
Which headless CMS to choose based on project type, the level of technical control you need, and how you plan to model your content.
June 3, 2026
8 min read