Website Performance

Edge Computing Explained: How It Lowers Latency and When You Need It

By NileVPS Team · Published · 4 min read

اقرأ المقال بالعربي

Edge computing means running code close to the people or devices that use it, rather than in one central data center. The goal is simple: fewer kilometres between the user and the computation means less waiting. It covers a wide range, from small functions running on a CDN's servers, to compute in a telecom operator's facility, to a server placed in a factory next to its machines. For website owners, the practical question is narrower: which parts of my application benefit from running near visitors, and which should stay in one place?

Why distance adds latency

Light in optical fibre travels at roughly two thirds of its speed in a vacuum, about 200 km per millisecond. A round trip therefore costs around 1 ms for every 100 km of cable, before routing detours, queues and processing are added. Real paths are rarely straight lines, so measured latency is usually higher than the theoretical minimum.

That cost repeats. Opening a new HTTPS connection needs a TCP handshake and a TLS handshake before the first byte of the page is requested, and each is at least one round trip. A page that then makes several sequential API calls pays the distance again for each one. Moving the work closer shortens every one of those trips. For a deeper look at measurement, see server latency.

What "the edge" can mean

LayerExampleTypical use
CDN edgefunctions or workers on CDN serversredirects, headers, A/B routing, auth checks, cached responses
Regional clouda VPS or cloud server in a nearby regionfull application, database, APIs
Network edgecompute inside telecom or ISP facilitieslow-latency media, gaming, mobile services
On-premises edgesmall servers in a shop, factory or officelocal processing, working through internet outages

Edge caching, where the CDN stores responses, is the simplest form and needs no code. Our edge caching guide explains it.

What runs well at the edge

  • Request routing: redirects, language or country based routing, rewriting URLs.
  • Header manipulation: adding security headers, normalising cache keys.
  • Lightweight authentication: verifying a signed token before forwarding a request.
  • Personalisation from cached parts: assembling a page from cached fragments.
  • Image resizing and format conversion offered by some CDNs.
  • Bot filtering and rate limiting before traffic reaches your server.

These jobs are short, stateless and do not need the main database.

Where the edge struggles

The hard part is data. Code can run in hundreds of locations; a consistent database usually cannot. If an edge function needs to read from a database in Frankfurt for every request, a visitor in Singapore still pays the round trip to Frankfurt, now from the edge instead of the browser. Common limits:

  • Execution time, memory and CPU per request are usually restricted.
  • Not every library or language runtime is available.
  • Writes need one source of truth; replicating them worldwide is complex.
  • Debugging and logging are spread across many locations.
  • Costs are often per request, which is harder to predict than a fixed server.

A practical architecture for most sites

For the majority of websites and APIs, a simple layered setup works well:

  1. Origin: one VPS, or a small group, in the region closest to most users, running the application and database.
  2. CDN with caching for static files and public pages.
  3. Optional edge logic for redirects, headers and simple checks.
  4. A second region only if a large share of users is far away, typically with read replicas or a separate deployment.

Picking the right region for the origin is often the biggest single latency win. Visitors in Egypt and much of the Middle East generally reach European data centers faster than ones in the Americas; users in South and Southeast Asia are often better served from Singapore. Measure from where your users are:

ping -c 10 your-server-ip
mtr --report --report-cycles 20 your-server-ip
curl -o /dev/null -s -w 'connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer}\n' https://example.com/

NileVPS offers locations in Europe, the USA and Singapore; the comparison is on the pricing page.

Edge computing checklist

  • Is the problem network latency, or a slow application? Check TTFB first.
  • Can the work be done without the main database?
  • Is the logic small and stateless?
  • Would caching alone solve it?
  • Can you monitor and debug code running in many locations?

If most answers point to data and heavy processing, a well-placed server will help more than edge functions.

FAQ

Is edge computing the same as a CDN?

Not exactly. A classic CDN stores and delivers copies of content. Edge computing runs your own code at those locations or at other places near users. Many CDNs now offer both, so the terms overlap, but caching alone is not computation.

Will edge computing make my slow website fast?

Only if the slowness comes from distance. If your server takes a long time to generate pages because of slow queries or missing caches, running a little code at the edge will not fix it. Measure TTFB and server processing time before changing the architecture.

Do I still need a VPS if I use edge functions?

Usually yes. Edge functions handle small, stateless tasks, while the application, database, background jobs and file storage normally live on a server. The edge reduces how often requests reach that server, it does not replace it.

Related guides