Run Serverless Functions at half the cost with Spotinst & Serverless Framework

Written by David WellsEdit this post

We've seen it time and time again: companies get tremendous cost savings when they port over into the serverless realm.

Some real world examples:

What if I told you...it just got even cheaper?

#Serverless & Spotinst team up

Introducing the latest serverless provider integration, Spotinst.

Spotinst Functions enables users to deploy multi-cloud functions at Spot Prices. By leveraging spot instances, you could save 50 to 80% over standard serverless FaaS pricing.

#Spotinst supported runtimes

Spotinst currently supports Node (4, 6, & 8.3), Java, Python, Ruby, Go as function runtimes.

#Cross-cloud deployments

Spotinst functions can be deployed simultaneously in AWS, Azure and Google Cloud Platform.

This ability to deploy across clouds improves SLA and offers higher function availability. If one cloud provider goes down (or pricing is cheaper elsewhere), Spotinst handles this for you under the hood.

#Edge location support

Reduce data transfer costs with edge location support. Unlike other edge FaaS solutions, Spotinst Functions doesn’t have limitations on external api calls or execution time limits.

They are currently supporting 15 different locations around the US and 10+ locations in APAC, SEA & Europe.

#Function Analytics

  • Invocation count & latency metrics, errors & HTTP response codes analytics
  • Geo Location analytics
  • Easy log debugging

#Pricing Example (Compute Only):

Lets see how pricing stacks up with an example.

With 500,000 Requests per Minute (21,600,000,000 Monthly) with 256MB of RAM & <10ms execution time, the prices would break down like so:

  • Google Functions: ~$10,000 compute time
  • Amazon Lambda: ~$9,000 compute time
  • Microsoft Azure: ~$8,500
  • IBM Bluemix (Open Whisk): ~$9,000
  • Spotinst Functions: ~$2,000 (!)

#Demo

#Getting started

Here’s what you need to get started with the Spotinst plug-in now:

Start here in our docs.

Or continue reading for step by step instructions on how to set up and deploy your first service on Spotinst.

Pre-requisites: Make sure you have the latest version of serverless installed on your machine.

# install serverless in your command line
npm install serverless -g

#1. Sign up for Spotinst Account

You can sign up for a Spotinst account here

#2. Head into the functions console

Inside of Spotinst, head into the Functions console.

https://console.spotinst.com/functions

#3. Create a new Spotinst application

Create a new app and give it a name.

An application in Spotinst is a logical group of several environments. Most commonly, it stores environments that share the same business application (e.g., testing and production of a specific function). More on Spotinst applications in the Spotinst docs

#4. Create a new environment in the Spotinst application

Name the Environment and choose which regions and providers you want to run the function in.

This is where you can choose to run your function across cloud providers and within multiple regions. 🎉

Inside Spotinst, the environment refers to a configuration group that contains actual Functions. Learn more in the spotinst docs

#5a. Grab an API token in Spotinst settings

Now head into spotinst setting. We need to grab an API key!

#5b. Generate Spotinst API token

Click on API in settings and then on Generate Token. Generate SpotInst API tokens here

#5c. Name your API token

Name your token and click generate.

https://console.spotinst.com/#/settings/tokens/permanent

#5d.Copy Token for sls credentials

Now copy the token, we will need to use it with the sls config credentials command in our terminal.

https://console.spotinst.com/#/settings/tokens/permanent

#6. Grab Account Id

We also need your Spotinst account ID. You can grab that here: https://console.spotinst.com/#/settings/account/general

#7. Use sls create and create a Spotinst service

Back in your terminal, create a new Spotinst service.

#8. Configure your Spotinst credentials on your machine

sls config credentials -p spotinst -t hhhhhhhh -a act-73192739

#9a. Grab environment ID from Spotinst UI

You will need your spotInst environment ID from the UI to deploy your functions.

Grab the environment ID and drop it in the serverless.yml of the service.

#9b. Add your SpotInst environment key to serverless.yml

#10. Deploy your functions

Run serverless deploy

The serverless framework will read your config from serverless.yml, package up the function and deploy the code to your Spotinst function environment

#11. Get info about service

Run sls info for information and live endpoints of your service.

#You can view your functions in UI

or via the sls info command in your terminal.

#Multi-Cloud & Multi-region functions

🎉 Congrats you are now leveraging spot instance prices and running your functions across multiple clouds.

If you have questions or comments about the integration, we'd love to hear from you in the comments below or over on the serverless forums.

About David Wells

David is a Full Stack JavaScript Developer, entrepreneur, past life marketer. Developer @ serverless

Serverless Blog

The blog on serverless & event-driven compute

New to serverless?

To get started, pop open your terminal & run

npm install serverless -g

how? learn more

Subscribe

Join 12,000+ other serverless devs & keep up to speed on the latest serverless trends

Comments