1

We have a TCP socket server that retrieves data from various IoT devices, processes it and outputs it to an azure database. Right now it's being hosted on an Azure Linux VM. However would putting it in a function app or container service be more cost efficient?

Isaac
  • 113
  • 3

1 Answers1

2

Both the option of shifting to a container and the option of creating a serverless function architecture should be more cost efficient than the vm.

Function

I would say that in the vast majority of cases, a function architecture will be significantly cheaper. But for your specific case, it depends on the frequency of your IoT messages.

With a function, you're not paying a set price for running a server around the clock. Your code will only be running each time the function is called, and you're only paying for the resources you use each time the function runs. This leads to significant savings in situations where apps have periods of inactivity, as there is no charge whatsoever during periods of disuse.

But in an IoT situation, if you're receiving messages nonstop, you may not find the cost benefits to be as significant (but that'll still really depend on the volume).

That being said there are other pros and cons to consider outside of the cost:

  • Pros
    • Scalability - With functions you'll be able to automatically and seamlessly scale your applications compute component without any worries as to vm or container instances or management
    • Resilience - With functions, you don't have to worry about vms or containers failing, you don't need an orchestration solution, the cloud your code is running on will handle that all on their back end. All that's surfaced to you is a working reliable function as a service.
  • Cons
    • Development - Switching over to a function architecture isn't as simple as shifting from a VM to a container, you can't just transfer your existing solution and will need to put in some dev time to create the appropriate functions you'll need.

Container

Containers are an incremental step forward from running a VM. They offer increased efficiency by running containers on the docker engine and host os, rather than creating a new guest os for each instance like VMs have done. Link to Visual of Container/VM difference

A container will be cheaper, but the cost savings really kick in when you're dealing with transitioning a large number of VMs. For a single VM, I don't know that it'll make an immense cost difference.

That being said, in this case the useful benefit outside of cost is startup time. Containers, thanks to not launching a new guest os like VMs are much quicker to startup, which can be particularly useful in scaling or recovery scenarios.

TL;DR

Functions have potential to be much cheaper, but this could be lessened by very high frequency calls. They still offer benefits outside of cost, but require non trivial effort to shift to.

Containers will be cheaper (especially for high VM counts), but if cost is your only driving factor, and you are only running 1 VM, it may not be enough of a price drop to be worth your time.

user9975441
  • 195
  • 9