0

More of a general question - Assume all my tech stack has to be on K8S (for example cloud vendor agnostic): When should I use serverless on top of K8S (e.g nuclio, kubeless) - and when to keep service as docker? I ask this because the "auto-scaling" I get for free for both of them - so I wonder when I should use another framework...

To simplify - assume everything is stateless...no sessions

user1025852
  • 2,684
  • 11
  • 36
  • 58

2 Answers2

1

I will start by saying that Serverless is more innovative technology than Docker Containers. However, they both have their advantages and disadvantages.

Serverless

Starting from Serverless, it is possible to build them for virtually any type of application or backend service, and everything required to run and scale your application with high availability is handled for you.

Pros:

  • Deployment simplicity. There’s no need to administrate infrastructure — just upload your functions, and that’s all. No Dockerfiles or Kubernetes configurations.

  • Almost all Serverless solutions support event triggers, which means they are great for pipelines and sequenced workflows.

  • As you pay per function execution, Serverless is cheaper than containers. When an application is not being used, it shuts down, and you don’t pay for the idle time (you have mentioned that you don't have to pay for auto-scaling).

Cons:

  • When the Serverless app grows, it is hard to troubleshoot because of the way the FaaS applications are designed to work.

  • Serverless always depends on a third party vendor, so that changing the cloud provider can be a headache.

Docker Containers

Docker is a containerization platform that packages your application and all its dependencies together in the docker container.

Pros:

  • Container technology enables you to scale your applications as much as you want.
  • Docker containers are vendor-agnostic, whereas going Serverless always depends on a third party.
  • You have full flexibility and control with Docker containers in terms of setting policies, managing resources, and security.

Cons:

  • Containers utilize resources more efficiently than virtual machines, but they are still subject to performance overhead due to overlay networking, interfacing between the container and the host system.
  • By default, all of the data inside a container disappears forever when the container shuts down unless you save it somewhere else first.

Conclusion

If you want to reduce application management and don’t care about the architecture - Serverless is the best option. If you want to deploy an application on specified system architecture with having control over it, then Docker containers are the best option. So when comparing Serverless vs Docker, it comes down to choosing what is better for your particular needs.

I encourage to read interesting article about it.

Denis Stafichuk
  • 2,415
  • 2
  • 16
  • 29
aga
  • 3,790
  • 3
  • 11
  • 18
  • >Serverless always depends on a third party vendor, so that changing the cloud provider can be a headache This is not true. There are plenty of open-source cloud agnostic serverless solutions: Nuclio, Knative, OpenFaaS, Kubeless, Apache OpenWhisk, Fission, Fn Project to name a few. – Denis Stafichuk Apr 19 '20 at 19:11
0

I was working with the serveless framework created for Kubernetes: Kubeless. Its great because you want to maintain your architecture agnostic from the Cloud vendor.

Kubeless functions are triggered when some event (HTTP call or some cron job) is raised. But, in your infrastructure, you should always have at least one container running to execute your code. That's the case for Kubeless, it will auto-scale based on demand just like other containers.

Some points to have in mind:

  • Don't expect to have different HTTP methods for the same function name. It means, once a function is created, it accepts GET, POST, PUT, etc. It just does not evaluate the HTTP verb, and it's right because we are talking about serverless functions, not API.
  • It's ideal for atomic operations. Ex: database update on some event, clean resources from AWS, send notifications, etc.

So, if you need something more advanced, supporting HTTP methods and with more business logic, I recommend to use a traditional API approach, easier to maintain and monitor.

Check this article based on how to implement serverless functions using Kubeless.

Diego Rojas
  • 237
  • 5
  • 11