Services

Accelerators

Resources

Company

Services

Accelerators

Resources

Company

Cover illustration for the case study: Autoscaling eKYC ML workloads to 2M requests a day at 90% lower cost

Case study

Case study

TrustingSocial logo

/

/

TrustingSocial

TrustingSocial

Autoscaling eKYC ML workloads to 2M requests a day at 90% lower cost

Autoscaling eKYC ML workloads to 2M requests a day at 90% lower cost

Autoscaling eKYC ML workloads to 2M requests a day at 90% lower cost

Autoscaling eKYC ML workloads to 2M requests a day at 90% lower cost

We got TrustingSocial’s GPU-heavy eKYC services ready for 20 to 30 times their pilot traffic. Our Nomad autoscaler keeps the bill under $10K a month.

We got TrustingSocial’s GPU-heavy eKYC services ready for 20 to 30 times their pilot traffic. Our Nomad autoscaler keeps the bill under $10K a month.

We got TrustingSocial’s GPU-heavy eKYC services ready for 20 to 30 times their pilot traffic. Our Nomad autoscaler keeps the bill under $10K a month.

Cover illustration for the case study: Autoscaling eKYC ML workloads to 2M requests a day at 90% lower cost

The results

The results

The results

<$10K

<$10K

Monthly cloud spend

Monthly cloud spend

<$10K

Monthly cloud spend

99%

99%

99%

Uptime in business hours

Uptime in business hours

Uptime in business hours

<3s

<3s

<3s

P95 API latency

P95 API latency

P95 API latency

One2N has been instrumental in holding the SRE and Infosec front at Trusting Social. They set up homogenous observability standards for our multi-cloud and on-prem data centre deployments, helped auto-scale our ML workloads and reduce our cloud costs massively. They have a great mix of flexibility and discipline, which is essential for a startup type of environment.

One2N has been instrumental in holding the SRE and Infosec front at Trusting Social. They set up homogenous observability standards for our multi-cloud and on-prem data centre deployments, helped auto-scale our ML workloads and reduce our cloud costs massively. They have a great mix of flexibility and discipline, which is essential for a startup type of environment.

One2N has been instrumental in holding the SRE and Infosec front at Trusting Social. They set up homogenous observability standards for our multi-cloud and on-prem data centre deployments, helped auto-scale our ML workloads and reduce our cloud costs massively. They have a great mix of flexibility and discipline, which is essential for a startup type of environment.

Siddharth Kohli

Siddharth Kohli

Head of India operations, TrustingSocial

Head of India operations, TrustingSocial

The context

The context

The client provides eKYC SaaS APIs (face matching, OCR and more) to B2B customers through an Android SDK. A deployment for a major Indian telecom had to scale to 2 million API requests a day.

The stack was a Go API, Python machine-learning models, RabbitMQ, MinIO blob storage and PostgreSQL, deployed with Docker on Google Cloud using Nomad and Consul.

The client provides eKYC SaaS APIs (face matching, OCR and more) to B2B customers through an Android SDK. A deployment for a major Indian telecom had to scale to 2 million API requests a day.

The stack was a Go API, Python machine-learning models, RabbitMQ, MinIO blob storage and PostgreSQL, deployed with Docker on Google Cloud using Nomad and Consul.

The challenge

The challenge

GPU costs at go-live: Pilot costs were $5K a month. Go-live traffic was expected to be 20 to 30 times higher, and GPU VMs made up 90% of the bill, which pointed to about $100K a month without autoscaling.

GPU costs at go-live: Pilot costs were $5K a month. Go-live traffic was expected to be 20 to 30 times higher, and GPU VMs made up 90% of the bill, which pointed to about $100K a month without autoscaling.

GPU costs at go-live: Pilot costs were $5K a month. Go-live traffic was expected to be 20 to 30 times higher, and GPU VMs made up 90% of the bill, which pointed to about $100K a month without autoscaling.

Business-hours availability: Services had to stay at 99% availability from 8 am to 10 pm.

Business-hours availability: Services had to stay at 99% availability from 8 am to 10 pm.

Business-hours availability: Services had to stay at 99% availability from 8 am to 10 pm.

The impact

The impact

90% lower cost: Monthly cloud spend stays under $10K, against about $100K without the autoscaler.

90% lower cost: Monthly cloud spend stays under $10K, against about $100K without the autoscaler.

90% lower cost: Monthly cloud spend stays under $10K, against about $100K without the autoscaler.

90% lower cost: Monthly cloud spend stays under $10K, against about $100K without the autoscaler.

2+ years in production: The system has run in production since go-live.

2+ years in production: The system has run in production since go-live.

2+ years in production: The system has run in production since go-live.

2+ years in production: The system has run in production since go-live.

The approach

The approach

In the final Auto Scaling solution, we needed a manual override option. At that time, both Nomad and Kubernetes did not provide this capability out of the box. Also, migrating to Kubernetes would have meant much rework for the entire team. Hence, we decided to build a custom auto-scaling solution on top of Nomad and existing toolchains used in the project.

Diagram: Custom autoscaler on Nomad

Autoscaler runs every 20 minutes, predicts the traffic for the next cycle and ensures that required ML workers are available. Same logic works for scale up as well as scale down.

Some of the other challenges we encountered were as follows:

  • Eliminate single points of failure

    • Run RabbitMQ in High Availability mode with queue replication across three zones in GCP.

    • Use GCloud Storage as a fallback for Minio. If Minio is unavailable, the application will transparently use GCloud Storage as an image store.

    • ML workers were split across two availability zones in an odd-even fashion.

    • For other components (PostgreSQL, Redis, API), we used SaaS offerings by GCP and ran redundant versions of those components.

  • GPU utilization bug in Nomad (​https://github.com/hashicorp/nomad/issues/6708)

    • We used Raw Exec driver from Nomad and launched multiple ML containers on a single VM using docker-compose.

    • We also implemented custom health checks and CPU stickiness for individual containers.

  • Capacity Planning

    • We figured out the optimal VM setup considering factors like GPU, RAM, and cost per hour.

    • We studied past request patterns and figured out a simple formula for predicting traffic based on a slope of the request growth line.

  • Automated Rolling Deployments during peak time

    • We pre-fetched the ML worker docker images (7GB+) on nodes to have a faster startup time during deployments.

    • The golden image would be updated on the first node. After it is successfully deployed, it would be updated on all remaining nodes, one at a time. This allowed us to deploy services even during peak load.

  • Monitoring, Alerting, and auto-healing

    • We made various SLI reports and latency dashboards available to all stakeholders.

    • Setup PagerDuty and on-call schedules.

    • Implemented scripted actions for common operation issues (example: Handling Live VM migration for GPU VMs)

  • Test the whole setup and fix issues

    • We Performed extensive, long-running Load tests with production-like traffic patterns to ensure the Autoscaler worked as expected.

    • Tested redundancies and HA setup by introducing chaos (shutting down of nodes and services like Minio) during load testing.

Tech stack used.

Watch this talk for a detailed understanding of the work, presented at HashiTalks India 2021.

In the final Auto Scaling solution, we needed a manual override option. At that time, both Nomad and Kubernetes did not provide this capability out of the box. Also, migrating to Kubernetes would have meant much rework for the entire team. Hence, we decided to build a custom auto-scaling solution on top of Nomad and existing toolchains used in the project.

Diagram: Custom autoscaler on Nomad

Autoscaler runs every 20 minutes, predicts the traffic for the next cycle and ensures that required ML workers are available. Same logic works for scale up as well as scale down.

Some of the other challenges we encountered were as follows:

  • Eliminate single points of failure

    • Run RabbitMQ in High Availability mode with queue replication across three zones in GCP.

    • Use GCloud Storage as a fallback for Minio. If Minio is unavailable, the application will transparently use GCloud Storage as an image store.

    • ML workers were split across two availability zones in an odd-even fashion.

    • For other components (PostgreSQL, Redis, API), we used SaaS offerings by GCP and ran redundant versions of those components.

  • GPU utilization bug in Nomad (​https://github.com/hashicorp/nomad/issues/6708)

    • We used Raw Exec driver from Nomad and launched multiple ML containers on a single VM using docker-compose.

    • We also implemented custom health checks and CPU stickiness for individual containers.

  • Capacity Planning

    • We figured out the optimal VM setup considering factors like GPU, RAM, and cost per hour.

    • We studied past request patterns and figured out a simple formula for predicting traffic based on a slope of the request growth line.

  • Automated Rolling Deployments during peak time

    • We pre-fetched the ML worker docker images (7GB+) on nodes to have a faster startup time during deployments.

    • The golden image would be updated on the first node. After it is successfully deployed, it would be updated on all remaining nodes, one at a time. This allowed us to deploy services even during peak load.

  • Monitoring, Alerting, and auto-healing

    • We made various SLI reports and latency dashboards available to all stakeholders.

    • Setup PagerDuty and on-call schedules.

    • Implemented scripted actions for common operation issues (example: Handling Live VM migration for GPU VMs)

  • Test the whole setup and fix issues

    • We Performed extensive, long-running Load tests with production-like traffic patterns to ensure the Autoscaler worked as expected.

    • Tested redundancies and HA setup by introducing chaos (shutting down of nodes and services like Minio) during load testing.

Tech stack used.

Watch this talk for a detailed understanding of the work, presented at HashiTalks India 2021.

In the final Auto Scaling solution, we needed a manual override option. At that time, both Nomad and Kubernetes did not provide this capability out of the box. Also, migrating to Kubernetes would have meant much rework for the entire team. Hence, we decided to build a custom auto-scaling solution on top of Nomad and existing toolchains used in the project.

Diagram: Custom autoscaler on Nomad

Autoscaler runs every 20 minutes, predicts the traffic for the next cycle and ensures that required ML workers are available. Same logic works for scale up as well as scale down.

Some of the other challenges we encountered were as follows:

  • Eliminate single points of failure

    • Run RabbitMQ in High Availability mode with queue replication across three zones in GCP.

    • Use GCloud Storage as a fallback for Minio. If Minio is unavailable, the application will transparently use GCloud Storage as an image store.

    • ML workers were split across two availability zones in an odd-even fashion.

    • For other components (PostgreSQL, Redis, API), we used SaaS offerings by GCP and ran redundant versions of those components.

  • GPU utilization bug in Nomad (​https://github.com/hashicorp/nomad/issues/6708)

    • We used Raw Exec driver from Nomad and launched multiple ML containers on a single VM using docker-compose.

    • We also implemented custom health checks and CPU stickiness for individual containers.

  • Capacity Planning

    • We figured out the optimal VM setup considering factors like GPU, RAM, and cost per hour.

    • We studied past request patterns and figured out a simple formula for predicting traffic based on a slope of the request growth line.

  • Automated Rolling Deployments during peak time

    • We pre-fetched the ML worker docker images (7GB+) on nodes to have a faster startup time during deployments.

    • The golden image would be updated on the first node. After it is successfully deployed, it would be updated on all remaining nodes, one at a time. This allowed us to deploy services even during peak load.

  • Monitoring, Alerting, and auto-healing

    • We made various SLI reports and latency dashboards available to all stakeholders.

    • Setup PagerDuty and on-call schedules.

    • Implemented scripted actions for common operation issues (example: Handling Live VM migration for GPU VMs)

  • Test the whole setup and fix issues

    • We Performed extensive, long-running Load tests with production-like traffic patterns to ensure the Autoscaler worked as expected.

    • Tested redundancies and HA setup by introducing chaos (shutting down of nodes and services like Minio) during load testing.

Tech stack used.

Watch this talk for a detailed understanding of the work, presented at HashiTalks India 2021.

Download this case study

Download this case study

A PDF version to read later or share with your team.

A PDF version to read later or share with your team.

Facing a similar problem?

Facing a similar problem?

Talk to the engineers who did this work at one2n.io/contact

Talk to the engineers who did this work at one2n.io/contact

Facing a similar problem?

Facing a similar problem?

Facing a similar problem?

Book a 30-minute call with the engineers who did this work. Bring your system and we’ll tell you what we’d try first.

Book a 30-minute call with the engineers who did this work. Bring your system and we’ll tell you what we’d try first.

More case studies

More case studies

Latest from the blog

Latest from the blog