Kubernetes and Serverless are currently the two most popular computing options to build modern cloud-native applications. Both options have pros and cons and it depends on your needs which option you should choose. This article describes when to use Serverless and when to use Kubernetes.
If you want to find out more about this topic, visit us at the IBM booth, attend our session and our workshop at the WeAreDevelopers Conference
Here is a summary when to use Serverless or Kubernetes:

Use Serverless if you have the following needs

1) Variable and irregular Workloads

A good Serverless scenario is a local website which doesn’t get much or any traffic during nights. Since Serverless platforms only charge for the duration your code runs, this can lead to significantly lower costs. The longer applications don’t do anything, the better are the chances that Serverless is cheaper.
However Serverless doesn’t automatically mean lower costs, for example when your applications need to run 24/7. There can also be some hidden costs like extra costs for API management or the costs for the function invocations for tests.

2) Developer Productivity For First Time Experience

If you neither have experience in Serverless nor in Kubernetes, it’s easier to get a first hello world application running on Serverless platforms. When you use Kubernetes, you typically have to wait some time to create a cluster, configure Kubernetes to get a public IP address and deploy your first container. With Serverless platforms you can simply use web tooling provided by the cloud providers to get started in minutes.
However Serverless isn’t always easier than Kubernetes. Building and managing a Serverless application with a bunch of functions is more difficult than a simple Kubernetes application with only one container. In fact, it might be easier to use Kubernetes for more complex applications because the platform is more mature (see below for more).

3) Inherent Auto-Scalability

One of the great capabilities of Serverless is the inherent auto-scalability of functions since as a developer you don’t have to do anything to leverage this functionality. With Kubernetes you can also use auto-scalability of your pods and even nodes, but it requires some configuration and it is a little slower since this process is only triggered when certain rules apply.
However, Kubernetes might provide better scalability features than some Serverless platforms, since Kubernetes is more mature and provides even HA (high availability) between different zones which not all Serverless platforms provide yet.

Use Kubernetes if you have the following needs

1) Mature Deployment Options

I’m not aware of any Serverless platform that supports A/B testing which I consider a key capability for building cloud-native applications. Additionally, the monitoring capabilities of Kubernetes applications are much more mature. For example with Istio, you can see the execution time of microservices, which service invoked which other services and whether there are bottlenecks. Serverless platforms don’t really have this yet and started only rather recently to add features like Amazon Step Functions and OpenWhisk Composer to define flows between functions.
However if your application is rather simple, for example only one function to provide an API, Serverless might be a better option for you, since the deployment would be easier and monitoring for single functions is provided by the various Serverless platforms.

2) Minimal Response Latency

When using Serverless platforms the first invocation of a function takes some time since the code needs to be initialized. For example, in OpenWhisk you can use Docker containers which can run Java applications that take some time to start. If you need as fast as possible and reliable response times, you should use Kubernetes.
However, Serverless platforms like OpenWhisk have improved significantly recently by doing a lot of caching. After the very first cold start, you don’t see these longer response times anymore which might be sufficient for your applications.

3) High-Performance Computing without Resource Restrictions

Serverless platforms typically have certain resource restrictions, for example, functions cannot use more than 512 MB RAM and cannot take longer than 5 minutes. If these restrictions are too strict for your applications, you need to use Kubernetes.
However, sometimes it might be possible to break up your applications in smaller functions. In some cases, this might even be desirable, for example when moving an existing monolithic application into the cloud.

Visit us at the IBM booth at the WeAreDevelopers Conference

If you want to find out more about this topic and the broad capabilities for developers including more than 170 services for AI, IoT, Data, Analytics, Open Source (eg. Kubernertes, Cloud Foundry), Blockchain and much more, visit us at the IBM booth, attend our session and our workshop.

At the booth, we’ll also demonstrate how the Cozmo robot can recognize objects via TensorFlow, Kubernetes and OpenWhisk (Click here) and how cars can drive autonomously by tracking their positions in the cloud (Click here).
Sign up now and build on IBM Cloud for free with no time restrictions!
IBM’s resource for developers: Here and here