A More In-Depth Article on Serverless

  • 0

  • 0

  • 0

A More In-Depth Article on Serverless

A More In-Depth Article on Serverless

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.

Did you find this article helpful?
  • No

  • Neutral

  • Yes

Comments
DMCA.com Protection Status