Crowdbotics
Published in

Crowdbotics

Photo by Siora Photography on Unsplash

The easiest way to scale the brand new Azure SignalR service

A couple of months ago we migrated our push notification for the website to the brand new Azure SignalR service. In this post I am going to quickly give the steps to create a simple task that scales up and down the service in order to save money in your Azure account.

The Problem

This service is quite new so the pricing tiers and scale settings are still not very well designed for all customers cases.

In our case we have peaks of traffic during Europe business hours and during the night and weekends the traffic goes down. So the users connected to the push service vary through the day. Right now there is no an automatic scale system built for SignalR service as we have in App Services.

I have found a couple of post (this and this one) that goes deeper in details but we have created an easier way when using Devops Pipelines together with Azure CLI in a bash script.

Prices and tiers

Right now the SignalR service has 2 tiers: Basic and Standard.

SignalR tiers

With the Standard Tier you can scale 1,2,5,20, 50, 100 thanks to this page (Scale Option):

SignalR Units

To give an overview 100 units cost almost $5000 per month

The Solution

The code we use to scale:

#!/bin/bashResourceGroupName=$2SignalRName=$1CurrentDayOfWeek=$(date +%u)echo $CurrentDayOfWeekCurrentHour=$(date +%H)echo $CurrentHourif (( $CurrentDayOfWeek <= 5 ))thenif (($CurrentHour >= 6 && $CurrentHour < 22))thenecho is week morning.az signalr update -n $SignalRName — resource-group $ResourceGroupName — sku Standard_S1 — unit-count 2elseecho is week night.az signalr update -n $SignalRName — resource-group $ResourceGroupName — sku Standard_S1 — unit-count 1fielseecho is weekend.az signalr update -n $SignalRName — resource-group $ResourceGroupName — sku Standard_S1 — unit-count 1fi

At FXStreet we manage all the Azure maintenance task from Azure devops, probably is not the best way but is very versatile because you can execute scripts in the steps.

An example of the things we manage:

So how to scale SignalR service? We use Azure cli step in Azure dev ops

That’s it! less than 24 lines of code. In case you don’t use Azure devops you just need to add az login in order to login into your azure account and you can use the very same code.

--

--

--

The fastest way to build your next app.

Recommended from Medium

Measuring audio-video quality in our online learning tool

December in Review

What is Performance testing?

For All My Life I’ll Feel It: Lack of Empathy Kills User Adoption

“What you do isn’t wrong; I’m just adding to your toolkit.”

Using Daily’s video chat API with Anvil

What Is DevOps And Its Key Principles

Tokapi Public Beta is around the corner — $2500 rewards, free NFTs, and more.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Javier Hertfelder

Javier Hertfelder

More from Medium

How We Migrate Legacy Authentication OAuth 1.0 Using JWT And Redis

Feature Flag workflow with Split.IO and Azure DevOps

Stateless vs. Stateful Microservices: Addressing the Benefits and Quandaries

Big Picture Eventstorming: A Guide on How to Explore with a Fast Learning Curve