Published in


Azure Functions helps us to alleviate the frustration of unknown waiting time for thousands of minibus passengers in Hong Kong

The frustration

In Hong Kong, Green Minibus is one of the major public transportation that helps people to commute from place to place. Nearly 2 million passengers are served by the minibuses every day. However, there is always a pain point that the minibus passengers never know when is the minibus arriving. A ton of time is wasted for waiting the minibus.

SOCIF comes in

Our co-founders are the alumni of the Hong Kong University of Science and Technology (HKUST). Many HKUST staff and students rely on the minibus to commute to the campus. To eliminate the frustrations, we decided to provide the Estimated Time of Arrival (ETA) service to the HKUST community.

USTransit, the transit app for HKUST, was born in 2019 and achieved 14k downloads and 4+ stars of rating. Passengers can check the ETA of the minibuses and the information of the routes via USTransit.

Demand spikes

As an ETA provider for the Hong Kong green minibus, we are always facing the spikes in demand for our ETA service during peak hours. In order to provide a reliable service to our clients, we spent lots of effort to design our system for scalability. Azure Functions is one of the great fit for us to deal with “happy trouble”.

Why Azure Functions

Azure Functions is a managed serverless compute service that allows developers to run their applications in a scalable manner without setting up complicated scale-in and scale-out architecture. Azure Functions will automatically detect the application usage to scale-in and scale-out instances to handle the requests. The bill is very predictable since it is calculated in terms of execution time and the memory used.

The SOCIF Engineering team can then focus on the application development and fulfilling clients’ goals by shifting the workload of achieving system scalability to Azure.

Adopting Azure Functions

The first thing to do is to make sure the components that facing the variable user demand are stateless, which allows Azure Functions to replicate the application onto different popcorn instances. We used azure-functions-core-tools, which is a great starting point to create an “Azure Function Friendly” application. After migrating the application into Azure Functions, we set up a CI/CD pipeline using Azure DevOps to automate the deployment procedures.

After migrating to Azure Functions, our service can handle the usage surge of USTransit during peak hours (8 — 10am and 4 — 6am) without incurring additional latency and execution error.

Things to pay attention

Cold start

For the consumption plan of Azure Functions, there is no always-on instance to handle the incoming requests immediately. The instance will only be allocated when it is needed. During the scale-out operation, the additional instances need some time to spin up before ready for requests. The latency between instance allocation and service ready is called “cold start”. To reduce the cold start latency, we set up a cronjob that constantly runs every 15 minutes, which can keep an instance warmth. We make sure there is at least one instance ready to serve the requests at any time.

Why 15 minutes? According to the documentation from Microsoft, computation resources will be deallocated after 20 minutes of inactivity.

Execution time

The cost of Azure Functions is expected to be predictable. However, we were charged 300% more than usual last December. We were shocked and we thought that there was some issue with the Azure billing system. After hours of investigation, we found that one of our functions didn’t return correctly. The faulty function kept causing an error and hanged until timeout, which is 5 minutes. The main portion of the billing was incurred by the execution time of the function.

After the lesson, we learned to ensure the function returning correctly before deployment.


Thanks to Azure Functions, SOCIF can provide reliable and scalable solutions for the clients from the transportation and logistic industries. If you identify any existing problem in your industry, please feel free to reach us and we will try our best to help with it.

PS: We are expanding our engineering team. Shoot us an email at if you are interested to work with our awesome SOCIF Engineering team.




The footage of a startup that solves daily problems, specialized in the field of transportation

Recommended from Medium

Rust once and share it with Android, iOS and Flutter

Five Reasons to Move Your DevOps Architecture to the Cloud

How Does On-demand Food Delivery Work?

Studies In Program Composition: 3 — Beginning A Golf Program

Naming the Shape of Things

Using Automation in Finance — Gleematic A.I

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
Simon Tsang

Simon Tsang

Software Engineer, exploring the possibilities of software development

More from Medium

Climate change induces additional challenges as forecasting models fail and extreme weather events…

The best lighting for the environment

Shortages of Plant-Essential Nutrients Threaten to Hasten Climate Change

We CAN stop the climate crisis as individuals. Here’s how…