A More In-Depth Article on Serverless

A More In-Depth Article on Serverless

Daily short news for you
  • A software that converts text to speech created by a Vietnamese programmer - J2TEAM - Text to Speech (Free). You can convert dozens of languages into dozens of different natural voices. The special thing is that it is free.

    In preliminary evaluation, the conversion of long texts or texts in pure Vietnamese is very good. However, when it includes English words, it sounds a bit funny 😅

    » Read more
  • How terrifying, Codeium - known as a competitor to Github Copilot, as it allows users to use it for free without limits. Recently, they introduced the Windsurf Editor - no longer just a VSCode Extension but a full Editor now - directly competing with Cursor. And the main point is that it... is completely free 🫣.

    » Read more
  • There is a rather interesting study that I came across: "Users never bother to read things they don't want to." (That's a bold statement, but it's more true than not. 😅)

    Don't believe it? I bet you've encountered situations where you've clicked on a button repeatedly and it doesn't respond, but in reality, it has displayed an error message somewhere. Or you've filled out everything and then when you hit the submit button, it doesn't go through. Frustrated, you scroll up or down to read and find out... oh, it turns out there's an extra step or two you need to take, right?

    It’s not far from the blog here. I thought that anyone who cares about the blog would click on the "Allow notifications" button just below the post. But the truth is, no one bothers to click it. Is it because they don't want to receive notifications? Probably not! I think it's because they just didn’t read that line.

    The evidence is that only when a notification pops up and takes up half the screen, or suddenly appears to grab attention, do they actually read it—and of course, it attracts a few more subscribers—something that was never achieved before.

    » Read more

The Problem

Serverless is a concept that is not unfamiliar to many. When we talk about Serverless, we often think of "no servers" just as its name suggests. Hmm… no servers, what does that mean?

I don't know why people came up with that name, but it seems to me that they wanted to emphasize the fact that you don't need servers to run your code. We all know that running code usually requires a server to deploy everything on. From source code to databases to message queues... for the tech stacks being used.

There are two types of servers, Cloud and physical. While Cloud is easy to rent, physical servers require more time and money to set up. But regardless of the type, we still need someone to operate them. Operations mean installation, monitoring, and troubleshooting... which requires a lot of knowledge and time to ensure the system operates smoothly.

Serverless eliminates that step, no need for operations because "there are no servers"!? That's from the customer's perspective, meaning when we talk about users of Serverless, they don't need to care about servers as long as the service they rent works well. As for the provider, of course they need to operate servers. You could say they "carry" the risks during the operation process, they need to have in-depth knowledge of operations to ensure the service is maintained stable. Otherwise, nobody would dare use their services.

For example, say you want to have a PostgreSQL database server. You can rent a $5/month VPS somewhere, then install Postgres on it, and that's it. You can use it however you like, why bother using a third-party service? One day, suddenly you can't connect to the database anymore, you SSH into the server and find out that Postgres is turned off, you turn it back on, an error occurs, you fix it, another error comes up... annoyed, you reboot, the server keeps reporting 100% CPU, you angrily bang on the keyboard... That's just an example of the risks of self-operating servers.

However, Serverless wasn't created to replace traditional servers. It just adds richness to our technology choices. In today's article, let's delve into what Serverless is and what it can do!

What is Serverless?

Serverless is a cloud computing model that hides or reduces the management of infrastructure for developers. No need to manage servers, saves resource costs, operated by a professional team, and only pays for what is used. Additionally, Serverless allows for significant horizontal scaling.

No need to manage servers, that's clear. What about saving resource costs and only paying for what is used? If you rent a server, that means you're spending money to rent it every second, every minute the server is alive. Imagine that there may be a time when your server is idle, like at night, but you still have to spend money on them. With Serverless, many providers have billing based on the number of service calls, meaning you pay for as much as you call, not calling means not paying.

A characteristic of Serverless is "stateless", meaning it does not store state. Therefore, we are not heavily dependent on session, cookies... thereby increasing scalability by creating more similar services to increase processing capacity.

What Makes it Different from Traditional Servers?

The most obvious difference is that we don't have to manage servers in Serverless. No need or very little concern for resource management like CPU, memory, and network.

VPS is a virtual server created from a physical server, providing specific resources such as CPU, memory, and network. In contrast, Serverless does not require specific servers and runs functions when activated by events.

Resource management is another important difference. While VPS requires administrators to manage resources, Serverless automatically manages them, reducing the burden on developers.

The cost of renting servers is usually calculated based on the allocated resources, for example, 1 CPU, 2GB RAM, 30GB SSD... On the other hand, Serverless charges based on the actual usage, for example, if you make 100 requests, you pay for those 100 requests.

In general, servers are suitable for applications with stable resource requirements and large projects, while Serverless is a good choice for applications that have variable load over time. The difference between them provides unique benefits, meeting the diverse needs of modern technology projects.

When to Use Serverless?

In general, whatever servers can do can also be deployed through Serverless, but the level of support may not be the same or better than traditional servers because they were not created to replace each other.

First and foremost, Serverless is an efficient choice for API Gateway deployment, where costs only occur when API requests are made. This helps minimize unnecessary costs when there is no interaction.

Handling images and media is also a flexible application of Serverless. Using it for tasks such as image, video, and audio processing and conversion helps reduce processing costs focused on critical tasks.

Serverless is also suitable for handling system events, where functions are only triggered when needed, reducing load and related costs.

In addition, Serverless is useful for processing information from IoT devices, helping to reduce the cost of maintaining continuous servers and increase flexibility.

Integrating with Webhooks and external services through Serverless also brings cost benefits and reduces the burden of integration.

These applications illustrate the clear opportunities that Serverless brings in terms of cost savings and infrastructure optimization in real-world environments.

Serverless with Cloudflare Worker

Cloudflare Workers provide a Serverless solution that allows you to build applications without worrying about servers. Backed by Cloudflare, Workers are available globally, which means your application benefits from being based on a CDN.

Workers support multiple programming languages, with the most popular being JavaScript and Rust. While JS runs based on Chrome's V8 engine, Rust is also compiled into WebAssembly and runs in V8.

In addition, Cloudflare provides many services that allow us to recreate our own "technology stack" such as R2, Pub/Sub, Queue, D1, Pages, AI...

Conclusion

Serverless brings simplicity and flexibility by removing the burden of server management, reducing resource costs, and only paying for actual usage. Serverless is not a replacement but an additional choice, expanding the technological capabilities for projects. At the same time, Serverless can deploy API Gateway, process media, handle system events, IoT, and integrate with Webhooks. Cloudflare Worker provides a flexible Serverless application with multiple programming languages and global network support, offering us a highly reliable choice.

Premium
Hello

The secret stack of Blog

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.
Author

Hello, my name is Hoai - a developer who tells stories through writing ✍️ and creating products 🚀. With many years of programming experience, I have contributed to various products that bring value to users at my workplace as well as to myself. My hobbies include reading, writing, and researching... I created this blog with the mission of delivering quality articles to the readers of 2coffee.dev.Follow me through these channels LinkedIn, Facebook, Instagram, Telegram.

Did you find this article helpful?
NoYes

Comments (1)

Leave a comment...
Avatar
Trịnh Cường8 months ago
cảm ơn bạn đã cung cấp thông tin này ;)
Reply
Avatar
Xuân Hoài Tống8 months ago
Cảm ơn bạn Cường đã quan tâm :D