While using Next.js for some time, one thing was always in my mind because it uses serverless and edge functions. But I was always curious about what actually happens behind the scenes.
So I started exploring a bit deeper just to understand the idea.
First I tried to understand how CDN works. I learned how content is cached in different locations and how systems like AWS CloudFront serve users from the nearest location. That helped me understand why modern apps try to move logic closer to the user.
Then I started reading about serverless architecture. The idea itself is quite interesting. In a normal backend server, something is always running. But in serverless the function runs only when a request comes.
If nobody is using it, nothing is running. When a request comes, a small environment is created and the function runs. That is why sometimes the first request can take a little time because the environment needs to start. The concept of scale to zero was something I found really interesting.
After that I explored a bit about edge computing. I read about how Cloudflare Workers run code near the user using the V8 engine. Instead of going to a single central server, the logic can run at edge locations.
While reading all this I also came across how platforms try to optimize these systems. For example how instances are reused, how environments stay lightweight, and how cold start delays are reduced.
I also learned about how Vercel tries to improve this with things like fluid compute where instances can be reused more efficiently instead of always creating a completely new environment.
Another interesting thing I noticed is how important serverless databases are becoming today. If your compute is serverless but the database is not designed for that architecture, it can create problems. That is why many modern databases are also trying to support serverless scaling and distributed access.
Earlier I used to think frameworks like Next.js are doing some magic. But after reading a bit about CDN, serverless compute, edge functions and infrastructure optimization, things started making more sense.
I am still learning and exploring these topics.
Top comments (0)