April 21, 2024
|Dev
Serverless architecture has become trendy recently. If you’re late to the party, the basic idea is that instead of having a long-running server waiting for requests, you spin up short-lived cloud functions as requests come in. It’s gained popularity in part because the cloud has become expensive. This has led some to leave the cloud altogether, but for those not willing to go that far, there’s serverless.
The benefit of a serverless approach is that in addition to being able to scale up to serve a large spike in traffic, it can also scale down to zero. This way you’re not racking up bills when no one’s around.
Frontend meta-frameworks like NextJS that allow a client to live alongside thin API routes have led the way here. Serverless has its own pitfalls like the cold start problem*, and there’s a complexity overhead in deployment. But, hosting providers like Vercel, the developers of NextJS, will take care of this for you. If you’re happy with Vercel that’s great, but there’s a risk of vendor lock-in when you come to depend on the features of a particular platform. In contrast a containerized application is easily portable. If you’re not happy with your host, leave.
While serverless may have its merits, its popularity also likely stems from the fact that developers love to play with new tools, and at times this enthusiasm wins out over practical considerations. Though it had its moment in the sun, now the pendulum appears to be swinging back in favor of containerized applications. The cloud might be expensive for larger applications, but it’s not too bad for smaller ones. It’s become a meme that you can run anything on a $5 VPS. Sure, you’re paying when there’s no traffic. But it’s not that much, and the simplicity is worth it.
* Serverless functions experience a delay when they are first invoked after a period of inactivity. This can impact application performance and user experience.