---
title: Handling Burst Scale-Out With 'Function as a Service' - Optibus
description: Handling Burst Scale-Out With 'Function as a Service' - At Optibus, we created a cloud-based platform that solves a very challenging problem of planning and scheduling public transportation (mass transit). Our platform is used to plan citywide networks of routes and timetables, and then schedule the movement of every vehicle and driver during every minute of the day. This can result in thousands of daily service trips, vehicles, and drivers being scheduled.
image: https://blog.optibus.com/hubfs/Imported_Blog_Media/header-image-technology.jpg
---

[![optibus-logo-2019](https://blog.optibus.com/hs-fs/hubfs/optibus-logo-2019.png?width=180&height=49&name=optibus-logo-2019.png "optibus-logo-2019")](https://www.optibus.com/)

[![optibus-dark-logo](https://blog.optibus.com/hubfs/optibus-dark-logo.svg "optibus-dark-logo")](https://www.optibus.com/)

- Product 
    - [Platform](https://www.optibus.com/product/platform/)
    - [Passenger Information](https://optibus.com/product/passenger-information/)
    - [Planning](https://www.optibus.com/product/planning/)
    - [Control & Monitoring](https://optibus.com/product/control/)
    - [MagicEye - Driver Safety](https://optibus.com/product/magic-eye/)
    - [Operations](https://www.optibus.com/product/operations/)
    - [Scheduling](https://www.optibus.com/product/scheduling/)
    - [Driver App](https://www.optibus.com/product/driver-app/)
    - [Rostering](https://www.optibus.com/product/rostering/)
    - [Optibus AI](https://optibus.com/product/ai/)
- Solutions 
    - [Agencies](https://optibus.com/solutions/optibus-for-agencies/)
    - [Win Tenders](https://optibus.com/solutions/optibus-for-tenders/)
    - [Operators](https://optibus.com/solutions/optibus-for-operators/)
    - [Electrify Fleet](https://optibus.com/solutions/optibus-for-electrical-vehicles/)
    - [Consultancies](https://optibus.com/solutions/optibus-for-consultancies/)
    - [Enhance Passenger Experience](https://optibus.com/enhance-passenger-experience/)
    - [Reduce Costs](https://optibus.com/solutions/reduce-operating-costs/)
- Resources 
    - [Blog](https://blog.optibus.com/)
    - [eBooks](https://www.optibus.com/resources/ebooks/)
    - [Webinars](https://www.optibus.com/resources/webinars/)
    - [Case Studies](https://www.optibus.com/resources/case-studies/)
    - [Videos](https://www.optibus.com/resources/videos/)
- Company 
    - [About](https://www.optibus.com/about-the-company/)
    - [Careers](https://www.optibus.com/careers/)
    - [Contact Us](https://www.optibus.com/about/contacts/)
    - [Events](https://www.optibus.com/events/)
    - [Media](https://www.optibus.com/news-events/media-coverage/)
- EN 
    - [English](https://blog.optibus.com/)
    - [Español América Latina](https://blog.optibus.com/es/)
    - [Español Europa](https://blog.optibus.com/es-es/)
    - [Deutsch](https://blog.optibus.com/de/)
    - [Français](https://blog.optibus.com/fr/)
    - [Português Brasil](https://blog.optibus.com/pt-br/)
    - [Português Portugal](https://blog.optibus.com/pt-pt/)
    - [日本語](https://blog.optibus.com/ja/)
    - [Italiano](https://blog.optibus.com/it/)
    - [Русский](https://blog.optibus.com/ru/)
    - [Türkçe](https://blog.optibus.com/tr/)
    - [български](https://blog.optibus.com/bg/)
    - <https://blog.optibus.com/engineering/handling-burst-scale-out-with-function-as-a-service#empty>

[Request a demo](https://optibus.com/request-a-demo/)

# Handling Burst Scale-Out With ‘Function as a Service’

![Eitan Yanovsky](https://blog.optibus.com/hs-fs/hubfs/0.jpg?width=100&height=100&name=0.jpg)

#### Eitan Yanovsky

April 22, 2021

[![Share on Facebook](https://blog.optibus.com/hubfs/fb_social_icon.svg)](http://www.facebook.com/share.php?u=https%3A%2F%2Fblog.optibus.com%2Fengineering%2Fhandling-burst-scale-out-with-function-as-a-service%3Futm_medium%3Dsocial%26utm_source%3Dfacebook) [![Share on LinkedIn](https://blog.optibus.com/hubfs/linkedin%20logo_icon.svg)](http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fblog.optibus.com%2Fengineering%2Fhandling-burst-scale-out-with-function-as-a-service%3Futm_medium%3Dsocial%26utm_source%3Dlinkedin) [![Share on Twitter](https://blog.optibus.com/hubfs/twitter%20logo_icon.svg)](https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fblog.optibus.com%2Fengineering%2Fhandling-burst-scale-out-with-function-as-a-service%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&url=https%3A%2F%2Fblog.optibus.com%2Fengineering%2Fhandling-burst-scale-out-with-function-as-a-service%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&source=tweetbutton&text=Handling%20Burst%20Scale-Out%20With%20%27Function%20as%20a%20Service%27%20-%20Optibus) [![Share on Email](https://blog.optibus.com/hs-fs/hubfs/email_icon-1.png?width=24&name=email_icon-1.png)](mailto:?subject=Check%20out%20https%3A%2F%2Fblog.optibus.com%2Fengineering%2Fhandling-burst-scale-out-with-function-as-a-service%3Futm_medium%3Dsocial%26utm_source%3Demail%20&body=Check%20out%20https%3A%2F%2Fblog.optibus.com%2Fengineering%2Fhandling-burst-scale-out-with-function-as-a-service%3Futm_medium%3Dsocial%26utm_source%3Demail)

At Optibus, we’ve created a cloud-based platform that solves the [very challenging problem of planning and scheduling public transportation](https://blog.optibus.com/?p=8895&hsLang=en) (mass transit). Our platform is used to [plan citywide networks of routes](https://blog.optibus.com/?page_id=6103&hsLang=en) and timetables, and then [schedule the movement of every vehicle and driver](https://blog.optibus.com/?page_id=6108&hsLang=en) during every minute of the day. This can result in thousands of daily service trips, vehicles, and drivers being scheduled. We have developed many capabilities to solve these challenges, including the development of distributed optimization algorithms that require immense computational power. These algorithms are triggered ad hoc when such complex optimization tasks are requested.

In our case, such tasks are triggered in response to a transportation planner setting up their rules and preferences, applying their expertise, and requesting to create an optimized plan. This will happen hundreds or thousands of times during the day, but as you can imagine, the usage pattern is very volatile and unpredictable. This makes capacity planning very difficult because the demand for resources fluctuates rapidly, creating multiple spread bursts of CPU demand.

Applying the classic scale-out approach using industry standards, such as Kubernetes, is not well-suited when a burst of computational power is required for a very short period that does not have constant or predicted usage patterns. The reasons being:

- Either you must have many nodes standing by waiting to absorb the burst, which is a significant cost waste
- Or you need to spawn many nodes at the same time, which requires waiting (and paying) for the boot time of the machines and the time during the scaling down of the nodes once the pods have been removed

On top of that, Kubernetes was not built to manage instant increases and decreases of tens or hundreds of pods required for only a few tens of seconds. It is more suited for typical scale requirements that rely on metrics, such as CPU, memory load, task queue backlog, etc. These metrics are spread across multiple machines that serve thousands of parallel requests. As a result, they don’t tend to have a sudden sharp steep curve (for the math fans this means a [uniformly continuous function](https://en.wikipedia.org/wiki/Uniform_continuity)) as the load each new request creates is amortized. However, in our case, a new task can be viewed as the equivalent of having an increase of 10,000 new parallel requests within a few seconds, which requires a different kind of scaling logic.

This is [why we chose to use AWS Lambda (Function as a Service)](https://blog.optibus.com/?p=6258&hsLang=en), applying a producer-consumer pattern that works very well for this case. The advantages of using Lambda for this purpose includes:

- Fast “cold start” start time – the time it takes to spawn a new instance is sub-second, unlike when spawning a new node (and all the pods on it) in Kubernetes, which can take even 30 seconds
- Immediate tear down – once the work is done you stop paying for resources. When using Kubernetes, terminating pods and nodes is not immediate, it is planned for more constant demand, so it doesn’t make sense to take down the instances right after the work is done
- All scaling considerations are hidden away and handled by AWS – even though Kubernetes simplifies this as well, at the end of the day non-trivial tuning is still required to manage the cluster

We have planned this task in a way that we can have one data set, and the computational work can be done on small chunks and aggregated together as a single result (scatter-gather pattern).

The outline of the steps goes like this:

1. Upload the required optimization task data once to S3
2. Calculate the optimal number of distribution of tasks and the optimal number of Lambda workers
3. Populate a stack index SQS queue with integers matching the optimal number of tasks, where each integer represents the index of the task the consumer of this event should do. The code of the task execution only requires this index and the uploaded data in order to execute
4. Create an empty task result SQS queue
5. Spawn the optimal number of Lambda instances using invoke (which can be thousands), passing the information required to find the uploaded data in S3, the task index SQS queue, and the task result SQS queue
6. The Lambda instances are downloading the task data from S3
7. The Lambda instances start taking tasks from the queue (index), runs its calculation, and returns the result through the SQS queue. It does so until the task queue is empty
8. The client side that invoked the Lambda instances and created the queues is pulling results from the task result queue as they come and aggregates the results

 

![](https://blog.optibus.com/hs-fs/hubfs/Imported_Blog_Media/Eytan-Optibus-Blog.jpg?width=471&height=459&name=Eytan-Optibus-Blog.jpg)

 

Using this flow, we are able to pay for exactly the required computational time and take advantage of AWS Lambda “cold start” (spin-up time) of sub seconds.

One thing to notice is that this pattern stops being effective when the execution time becomes significantly high, in a way that makes the overhead time it takes to spawn new nodes (“cold start”) and pods and the corresponding tear down overhead minor in the process. As clearly AWS Lambda has its cost, and it is significantly higher than paying for EC2 instances, especially when you take spot instances into account.

**Read more:**

[➤Continuous Deployment in Mission-Critical Enterprise SaaS Software](https://blog.optibus.com/?p=16183&hsLang=en)  
[➤Can We Optimize City Transportation Better Than A Museum Robber Could?](https://blog.optibus.com/?p=8895&hsLang=en)  
[➤](https://blog.optibus.com/?p=15980&hsLang=en)[Optibus Raises $107 Million and Launches Geospatial Suite to Help Cities Shape the Future of Urban Mobility](https://blog.optibus.com/?p=15980&hsLang=en)  
[➤](https://blog.optibus.com/?p=15980&hsLang=en)[Optibus Engineering Blog](https://blog.optibus.com/?cat_ID=259&hsLang=en)

 Topics: [Engineering](https://blog.optibus.com/topic/engineering?hsLang=en)

![](https://blog.optibus.com/hubfs/new%20design%20blog/illustration.svg)

### Get transportation industry updates

(But not too often, don't worry!)

Sign up for insights

## Recent Posts

- #### [Optibus and Carahsoft Partner to Deliver AI-Powered Public Transportation Solutions to the Public Sector](https://blog.optibus.com/carahsoft-partnership-public-sector?hsLang=en)
  
  [Read More](https://blog.optibus.com/carahsoft-partnership-public-sector?hsLang=en)
- #### [Optibus Launches Digital Vacation Bidding to Answer Bus Driver Demands for Self-Service Time-Off Control](https://blog.optibus.com/optibus-launches-digital-vacation-bidding-to-answer-bus-driver-demands-for-self-service-time-off-control?hsLang=en)
  
  [Read More](https://blog.optibus.com/optibus-launches-digital-vacation-bidding-to-answer-bus-driver-demands-for-self-service-time-off-control?hsLang=en)
- #### [Optibus Battles Driver Turnover and Overtime Expenditure with New Intelligent Driver and Vehicle Allocation](https://blog.optibus.com/new-intelligent-driver-and-vehicle-allocation?hsLang=en)
  
  [Read More](https://blog.optibus.com/new-intelligent-driver-and-vehicle-allocation?hsLang=en)

## Popular Content

[![How We Use FaaS To Optimize Mass Transit: Running Distributed Algorithms At “Infinite” Scale](https://blog.optibus.com/hubfs/Imported_Blog_Media/Optibize.png)](https://blog.optibus.com/engineering/how-to-use-faas-to-optimize-mass-transit-running-distributed-algorithms-at-infinite-scale?hsLang=en)

## [How We Use FaaS To Optimize Mass Transit: Running Distributed Algorithms At “Infinite” Scale](https://blog.optibus.com/engineering/how-to-use-faas-to-optimize-mass-transit-running-distributed-algorithms-at-infinite-scale?hsLang=en)

[Read More](https://blog.optibus.com/engineering/how-to-use-faas-to-optimize-mass-transit-running-distributed-algorithms-at-infinite-scale?hsLang=en)

[![Relief Vehicle Scheduling: The Forgotten Optimization Dimension](https://blog.optibus.com/hubfs/Imported_Blog_Media/iStock-1038335490-1024x683-1.jpg)](https://blog.optibus.com/transportation/relief-vehicle-scheduling-the-forgotten-optimization-dimension?hsLang=en)

## [Relief Vehicle Scheduling: The Forgotten Optimization Dimension](https://blog.optibus.com/transportation/relief-vehicle-scheduling-the-forgotten-optimization-dimension?hsLang=en)

[Read More](https://blog.optibus.com/transportation/relief-vehicle-scheduling-the-forgotten-optimization-dimension?hsLang=en)

[![The State Of Digital Transformation In Public Transportation – 5 Key Takeaways For 2024 And Beyond](https://blog.optibus.com/hubfs/ebook-The-State-of-Digital-Transformation-in-Public-Transportation-2024-1024x597-4.png)](https://optibus.com/ebook/2024-digital-transformation-public-transportation/)

## [The State Of Digital Transformation In Public Transportation – 5 Key Takeaways For 2024 And Beyond](https://optibus.com/ebook/2024-digital-transformation-public-transportation/)

[Read More](https://optibus.com/ebook/2024-digital-transformation-public-transportation/)

[![Shuttle Operator Grupo Mimo to Optimize Vehicle Scheduling using Optibus](https://blog.optibus.com/hubfs/Imported_Blog_Media/Grupo-Mimo_blog-1399-%C3%97-839-px-1.png)](https://blog.optibus.com/announcements/shuttle-operator-grupo-mimo-to-optimize-vehicle-scheduling-using-optibus?hsLang=en)

## [Shuttle Operator Grupo Mimo to Optimize Vehicle Scheduling using Optibus](https://blog.optibus.com/announcements/shuttle-operator-grupo-mimo-to-optimize-vehicle-scheduling-using-optibus?hsLang=en)

[Read More](https://blog.optibus.com/announcements/shuttle-operator-grupo-mimo-to-optimize-vehicle-scheduling-using-optibus?hsLang=en)

[![New York’s Nassau Inter County Express (NICE) Chooses Optibus For Its Scheduling Platform](https://blog.optibus.com/hubfs/Imported_Blog_Media/Screen-Shot-2019-03-12-at-10_17_25.png)](https://blog.optibus.com/announcements/new-yorks-nassau-inter-county-express-nice-chooses-optibus-for-its-scheduling-platform?hsLang=en)

## [New York’s Nassau Inter County Express (NICE) Chooses Optibus For Its Scheduling Platform](https://blog.optibus.com/announcements/new-yorks-nassau-inter-county-express-nice-chooses-optibus-for-its-scheduling-platform?hsLang=en)

[Read More](https://blog.optibus.com/announcements/new-yorks-nassau-inter-county-express-nice-chooses-optibus-for-its-scheduling-platform?hsLang=en)

[![Supertram Brings Time-Saving Optibus System to South Yorkshire](https://blog.optibus.com/hubfs/Supertram%20UK_DriverApp_07%20%281%29.jpeg)](https://blog.optibus.com/supertram-brings-time-saving-optibus-system-to-south-yorkshire?hsLang=en)

## [Supertram Brings Time-Saving Optibus System to South Yorkshire](https://blog.optibus.com/supertram-brings-time-saving-optibus-system-to-south-yorkshire?hsLang=en)

[Read More](https://blog.optibus.com/supertram-brings-time-saving-optibus-system-to-south-yorkshire?hsLang=en)

[![Flint, Michigan’s MTA tackles driver shortages and manual scheduling with Optibus](https://blog.optibus.com/hubfs/Imported_Blog_Media/MTA_blog-1399-x-839-1-1.png)](https://blog.optibus.com/announcements/flint-michigans-mta-tackles-driver-shortages-and-manual-scheduling-with-optibus?hsLang=en)

## [Flint, Michigan’s MTA tackles driver shortages and manual scheduling with Optibus](https://blog.optibus.com/announcements/flint-michigans-mta-tackles-driver-shortages-and-manual-scheduling-with-optibus?hsLang=en)

[Read More](https://blog.optibus.com/announcements/flint-michigans-mta-tackles-driver-shortages-and-manual-scheduling-with-optibus?hsLang=en)

## See the power of Optibus for yourself

[Request a demo](https://www.optibus.com/request-a-demo/)

#### Get transportation industry updates

#### Product

- [Platform](https://www.optibus.com/product/platform/)
- [Planning](https://www.optibus.com/product/planning/)
- [Scheduling](https://www.optibus.com/product/scheduling/)
- [Rostering](https://www.optibus.com/product/rostering/)
- [Operations](https://www.optibus.com/product/operations/)
- [Driver App](https://www.optibus.com/product/driver-app/)
- [Passenger information](https://optibus.com/product/passenger-information/)
- [MagicEye – Driver Safety](https://optibus.com/product/magic-eye/)
- [Control & Monitoring](https://optibus.com/product/control/)
- [Optibus AI](https://optibus.com/product/control/)

#### Solutions

- [Agencies](https://www.optibus.com/solutions/optibus-for-agencies/)
- [Operators](https://www.optibus.com/solutions/optibus-for-operators/)
- [Consultancies](https://www.optibus.com/solutions/optibus-for-consultancies/)
- [Electrical Vehicles](https://www.optibus.com/solutions/optibus-for-electrical-vehicles/)
- [Tenders](https://www.optibus.com/solutions/optibus-for-tenders/)
- [Enhance Passenger Experience](https://optibus.com/enhance-passenger-experience/)
- [Reduce Costs](https://optibus.com/solutions/reduce-operating-costs/)

#### Resources

- [Blog](https://blog.optibus.com)
- [eBooks](https://www.optibus.com/resources/ebooks/)
- [Webinars](https://www.optibus.com/resources/webinars/)
- [Case Studies](https://www.optibus.com/resources/case-studies/)
- [Videos](https://www.optibus.com/resources/videos/)

#### Company

- [About](https://www.optibus.com/about-the-company/)
- [Careers](https://www.optibus.com/careers/)
- [Media](https://www.optibus.com/news-events/media-coverage/)
- [Events](https://www.optibus.com/events/)
- [Contact Us](https://www.optibus.com/about/contacts/)
- [Partnership Program](https://optibus.com/company/global-partnership-program/)
- [Academy Program](https://optibus.com/company/academy-program/)
- [Sustainability & ESG](https://optibus.com/esg/)
- [Security Whitepaper](https://optibus.com/company/security/)

#### Content

- Recentes
- Populares
- Categorias

### Lists by Topic

- [Transportation (174)](https://blog.optibus.com/tag/transportation)
- [Announcements (159)](https://blog.optibus.com/tag/announcements)
- [Public Transportation (59)](https://blog.optibus.com/tag/public-transportation)
- [Blog (55)](https://blog.optibus.com/tag/blog)
- [Corporate (49)](https://blog.optibus.com/tag/corporate)
- [Product (40)](https://blog.optibus.com/tag/product)
- [People (33)](https://blog.optibus.com/tag/people)
- [Technology (32)](https://blog.optibus.com/tag/technology)
- [Solutions (26)](https://blog.optibus.com/tag/solutions)
- [Engineering (24)](https://blog.optibus.com/tag/engineering)
- [Company (17)](https://blog.optibus.com/tag/company)
- [Latin America (15)](https://blog.optibus.com/tag/latin-america)
- [North America (15)](https://blog.optibus.com/tag/north-america)
- [Women (15)](https://blog.optibus.com/tag/women)
- [AI (12)](https://blog.optibus.com/tag/ai)
- [Passenger (10)](https://blog.optibus.com/tag/passenger)
- [case study (10)](https://blog.optibus.com/tag/case-study)
- [Drivers (9)](https://blog.optibus.com/tag/drivers)
- [Electric Buses (9)](https://blog.optibus.com/tag/electric-buses)
- [values (9)](https://blog.optibus.com/tag/values)
- [APAC (8)](https://blog.optibus.com/tag/apac)
- [Algorithms (8)](https://blog.optibus.com/tag/algorithms)
- [driver shortage (8)](https://blog.optibus.com/tag/driver-shortage)
- [Innovation (6)](https://blog.optibus.com/tag/innovation)
- [Operations (6)](https://blog.optibus.com/tag/operations)
- [Partnerships (6)](https://blog.optibus.com/tag/partnerships)
- [Planning (6)](https://blog.optibus.com/tag/planning)
- [Driver retention (5)](https://blog.optibus.com/tag/driver-retention)
- [impact (5)](https://blog.optibus.com/tag/impact)
- [Control (4)](https://blog.optibus.com/tag/control)
- [ebuses (4)](https://blog.optibus.com/tag/ebuses)
- [Automation (3)](https://blog.optibus.com/tag/automation)
- [Driver Portal (3)](https://blog.optibus.com/tag/driver-portal)
- [GTFS (3)](https://blog.optibus.com/tag/gtfs)
- [Security (3)](https://blog.optibus.com/tag/security)
- [covid-19 (3)](https://blog.optibus.com/tag/covid-19)
- [efficiency (3)](https://blog.optibus.com/tag/efficiency)
- [Billboards (2)](https://blog.optibus.com/tag/billboards)
- [Data (2)](https://blog.optibus.com/tag/data)
- [Digital Transformation (2)](https://blog.optibus.com/tag/digital-transformation)
- [cloud (2)](https://blog.optibus.com/tag/cloud)
- [digital bidding (2)](https://blog.optibus.com/tag/digital-bidding)
- [performance (2)](https://blog.optibus.com/tag/performance)
- [Africa (1)](https://blog.optibus.com/tag/africa)
- [Allocation Optimization (1)](https://blog.optibus.com/tag/allocation-optimization)
- [BRT (1)](https://blog.optibus.com/tag/brt)
- [Bidding (1)](https://blog.optibus.com/tag/bidding)
- [Cybersecurity (1)](https://blog.optibus.com/tag/cybersecurity)
- [Demand response (1)](https://blog.optibus.com/tag/demand-response)
- [Demand response transport (1)](https://blog.optibus.com/tag/demand-response-transport)
- [GTFS-Flex (1)](https://blog.optibus.com/tag/gtfs-flex)
- [India (1)](https://blog.optibus.com/tag/india)
- [Optibus Agent (1)](https://blog.optibus.com/tag/optibus-agent)
- [Passenger Information (1)](https://blog.optibus.com/tag/passenger-information)
- [Shuttles (1)](https://blog.optibus.com/tag/shuttles)
- [Trillium (1)](https://blog.optibus.com/tag/trillium)
- [design (1)](https://blog.optibus.com/tag/design)
- [punctuality (1)](https://blog.optibus.com/tag/punctuality)

see all

## Get transportation industry updates

(But not too often, don’t worry!)

[info@optibus.com](mailto:info@optibus.com) | [Privacy Policy](https://www.optibus.com/optibus-privacy-policy/) | [Cookies Policy](https://www.optibus.com/optibus-cookie-policy/) | [ISO 27001 certified](https://www.optibus.com/wp-content/uploads/2023/02/ISO-27001-Optibus-certification.pdf) | © Optibus 2026

<https://twitter.com/optibus> <https://www.facebook.com/Optibusltd/> <https://www.linkedin.com/company/optibus-ltd/>