DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Deploying a Scalable Golang Application on Kubernetes: A Practical Guide
  • Serverless vs Containers: Choosing the Right Architecture for Your Application
  • 7 Ways of Containerizing Your Node.js Application
  • Auto-Scaling a Spring Boot Native App With Nomad

Trending

  • Feature Flag Debt: Performance Impact in Enterprise Applications
  • Compliance Automated Standard Solution (COMPASS), Part 10: How OSCAL Mapping Paves the Way for Continuous Compliance Scalability
  • A System Cannot Protect What It Does Not Understand
  • Multi-Scale Feature Learning in CNN and U-Net Architectures
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. When to Use Serverless, and When to Use Kubernetes

When to Use Serverless, and When to Use Kubernetes

If you are stuck at a crossroads and need some help deciding, here are some conditions which might help you make your selection.

By 
Niklas Heidloff user avatar
Niklas Heidloff
·
Updated Feb. 12, 18 · Review
Likes (12)
Comment
Save
Tweet
Share
32.0K Views

Join the DZone community and get the full member experience.

Join For Free

a question that i get asked very often is: should i use serverless or kubernetes to build cloud-native applications? both computing options have pros and cons and it depends on your needs which option you should choose.

ansgar schmidt and i will give a session next week about this topic. we are still finalizing our slides, but have finished the slide which summarizes when to use kubernetes and when to use serverless.

serverless-kube2

note that we don’t compare serverless with containers, but with kubernetes. with the open source serverless platform openwhisk you can build functions with docker containers as well. we also don’t compare one simple serverless function with a sophisticated microservices application on kubernetes, but applications with similar complexities.

use serverless if...

you have 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, like 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.

you need 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 then 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).

you need 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 need 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, with perhaps 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.

you require 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 fast and reliable response times, you should use kubernetes.

serverless platforms like openwhisk have improved significantly recently by doing a lot of caching. after the very first cold start you shouldn’t see these longer response times anymore which might be sufficient for your applications.

you want 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.

closing thoughts

i think it will be interesting to observe how these technologies will evolve this year. i’ve heard about several activities to make kubernetes easier as well as several activities to make serverless more mature.

if you want to try out serverless and kubernetes, you can get a free lite account (no credit card required) on the ibm cloud .

Kubernetes application Docker (software)

Opinions expressed by DZone contributors are their own.

Related

  • Deploying a Scalable Golang Application on Kubernetes: A Practical Guide
  • Serverless vs Containers: Choosing the Right Architecture for Your Application
  • 7 Ways of Containerizing Your Node.js Application
  • Auto-Scaling a Spring Boot Native App With Nomad

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook