Cost Optimization: How We Slashed $500K Using IaC, Containers, and More

Cost Optimization: How We Slashed $500K Using IaC, Containers, and More

 

Controlling cloud infrastructure costs is critical for any company, but especially in the early stages of a startup. As you scale, cloud costs can easily spiral out of control if not properly managed. We learned this lesson early on when our AWS bill unexpectedly jumped 20% one month due to inefficient resource utilization.

After some research, we realized that using Infrastructure as Code (IaC) tools like Terraform could help abstract away the underlying cloud provider and allow us to seamlessly transition across AWS, Azure, and GCP. The key benefit was avoiding vendor lock-in – if one provider’s costs increased, we could easily switch to another without rewriting all our infrastructure code.

In this blog, We will walk through how we leveraged Terraform and related tooling to setup easy portability across cloud providers. This has been one of our best return on investment (ROI) decisions, already saving us over $500K in costs while retaining full flexibility to switch providers if needed.

Some key benefits we realized by using Terraform were:

Increased efficiency
Minimized configuration drift
Cost optimization
Collaboration
Reproducibility

Overall, adopting Terraform allowed us to implement IaC principles for provisioning and managing infrastructure efficiently. This increased our agility while reducing risks and costs associated with configuration drift.

Containerization with Kubernetes

By containerizing our application and adopting Kubernetes orchestration, we gain granular control over resource allocation and scalability. Kubernetes’ efficient resource management allows us to pack more workloads onto fewer resources, maximizing utilization and minimizing idle capacity.

Some key benefits we saw from using Kubernetes:

Dynamic resource allocation – We can specify resource requests and limits for each container, and Kubernetes will allocate cluster resources accordingly. This ensures containers get the resources they need without overprovisioning.

Horizontal scaling – We can easily scale our applications up and down by changing the number of pod replicas. Need to handle more users? Simply increase the number of pods.

Optimized hardware utilization – Kubernetes efficiently packs containers onto nodes, maximizing resource utilization. Features like bin packing ensure high density of containers per node.

Automatic bin packing – Kubernetes will automatically schedule containers based on resource requirements and availability, packing them efficiently onto available nodes.

Auto-scaling – Kubernetes allows scaling up or down based on metrics like CPU usage. This ensures we have just enough resources to meet demand.

Service discovery – Containers can easily find and talk to each other using Kubernetes services for discovery. This simplifies things and avoids manual IP address management.

Overall, Kubernetes gave us the flexibility and control we needed to maximize resource efficiency, optimize hardware utilization, and achieve scalability on demand. This in turn minimized idle capacity and helped us reduce infrastructure costs.

Cluster Autoscaler (CA)

The CA takes autoscaling a step further by managing the number of nodes in your Kubernetes cluster. If your cluster is running out of resources due to increased demand, the CA can automatically add new nodes to the cluster. Similarly, if the demand drops and there are unused nodes, the CA can remove them, reducing infrastructure costs.

The key benefits of the CA are:

Improved application availability – By automatically adding nodes when resource constrained, the CA prevents application downtime.

Optimized costs – Only running the number of nodes required to meet demand reduces infrastructure costs.

Automated management – No need for manual intervention to scale the node pool up and down.

The CA allows Kubernetes clusters to automatically scale based on actual resource usage metrics. This ensures high application availability while optimizing infrastructure costs.

Horizontal Pod Autoscaler (HPA)

The HPA is responsible for automatically adjusting the number of pods in a deployment or replica set based on the observed CPU usage or custom metrics. This means that if your application is experiencing a sudden spike in demand, the HPA can scale up the number of pods to handle the increased load. Conversely, if the demand drops, the HPA can scale down the number of pods, reducing resource consumption and cost.

‍The HPA operates by periodically checking the current resource usage against the target resource utilisation. If the observed utilisation deviates from the target, the HPA adjusts the number of replicas accordingly. You can also configure the HPA to scale based on custom metrics, giving you even more control over your application’s scalability.

Vertical Pod Autoscaler (VPA)

While the HPA focuses on scaling the number of pods, the VPA is all about adjusting the resource limits for individual containers within a pod. This means that if a container is running out of memory or CPU, the VPA can automatically increase the resource limits, allowing the container to continue functioning without disruption.

‍The VPA operates by monitoring the resource usage of containers and comparing it to the current resource limits. If the observed usage is consistently higher or lower than the limits, the VPA recommends new resource limits for the containers. In some cases, the VPA can also automatically apply these recommendations, ensuring your application always has the right amount of resources

Spot Instances: For non-critical workloads and batch processing tasks, we utilized Spot Instances to take advantage of unused capacity at a fraction of the cost. This flexible approach helped us optimize costs while maximizing resource utilization.

KEDA Implementation

The Kubernetes pods were enabled to perform Horizontal Pod Autoscaling (HPA) based on CPU and memory utilization. The customer wanted to scale the Kubernetes pods to meet the requests coming in for deployment. This is similar in requirement to the native AWS auto-scaling behavior dependent on “requests per target group”

  • Event-Driven Scaling: It enables automatic scaling of Kubernetes pods based on the number of events in event sources such as message queues (e.g., AWS SQS, Kafka)
  • Scaling to Zero: It allows your Kubernetes pods to scale down to zero when there are no incoming events. This capability is crucial for serverless and event-driven architectures, where resources should only be allocated when there’s actual work to be done. Scaling to zero helps save costs and resources during idle periods.

Kubernetes Kustomize

Kubernetes Kustomize allows you to define and manage variations of Kubernetes configurations for different environments, such as development, staging, and production. This flexibility ensures that resources are provisioned appropriately for each environment, avoiding over-provisioning and unnecessary costs.

For example, you can use Kustomize to create customized Kubernetes manifests for your dev, test, and prod environments. The dev manifests may specify less compute resources, while the prod ones provision more resources to handle production workloads.

Kustomize lets you reuse common configuration components across environments while varying environment-specific settings like replica counts, memory/CPU limits, etc. You don’t have to maintain separate YAML files for each environment.

Instead, you can create a common base and overlay customizations for each environment. Kustomize will then generate the final manifests for you by merging the base and overlays.

This approach streamlines configuration management and ensures consistency across environments. By tailoring configurations to the specific needs of each environment, Kustomize helps optimize resource utilization and ultimately contributes to cost management in Kubernetes deployments.

ArgoCD:

ArgoCD indeed plays a significant role in cost optimization within Kubernetes environments. By automating the deployment and management of applications, ArgoCD reduces the reliance on manual intervention, thereby minimizing human errors and the associated costs of troubleshooting and rectifying them. Additionally, ArgoCD facilitates continuous delivery, ensuring that deployments are efficient, reliable, and consistent across different environments. This automation not only saves time but also optimizes resource utilization by enabling faster rollouts and updates. Overall, ArgoCD contributes to cost optimization in Kubernetes deployments by streamlining the deployment process, reducing operational overhead, and improving overall resource efficiency.

Overall, Terraform has been a huge win in terms of flexibility, productivity, and cost management. The key takeaway for readers is to invest time in learning Infrastructure as code practices and tools like Terraform. The long-term benefits are well worth it, especially as complexity and scale increase.

Food tech platform integrates with dozens of POS and OFO systems via LINK

Food tech platform integrates with dozens of POS and OFO systems via LINK

Overview 

A well funded market leader in the food tech segment wanted to rapidly sign up restaurants as customers to streamline restaurant order management, off-premise food prep, and delivery. The rate of customer acquisition was critical for this Company to establish a first-mover advantage over the competition. Target restaurants included multiple brands and concepts.

The Challenge

To attract restaurants and go to market, the Company faced an almost insurmountable challenge of integrating with a large, technically diverse, international as well as niche portfolio of Online Food Ordering (OFO) and Point of Sale (POS) systems – 100 plus and growing exponentially. The Company’s in-house integration effort was in the nascent stage and they needed a rapid and cost-effective way of integrating with POS, OFO, and delivery systems.

The Solution

LINK delivered 56 (and counting) POS and OFO integrations for the Company, which included not only the international systems with bulk of the restaurant volume, but also local players that are well-established in their markets. Within the first 11 months, LINK’s team rolled out 18+ integrations with a rapid velocity, letting the Company take its tech platform to over 5000 restaurants globally.

Admin view to manage all integrations

LINK’s white-labeled integration platform enabled the Company’s customer onboarding team to sign up new restaurants and activate the necessary integrations within minutes. Leading POS systems that LINK integrated included Toast, Square, Clover, Lightspeed, Oracle Simphony, Shopify, and many others. One key value proposition was LINK’s public API, which allowed any small or local app that didn’t have their own API to be able to sync with the Company’s platform.

Interface to activate a new restaurant

All active restaurants filtered by integration connector 

Additionally, restaurants acquired by the Company were able to use a broader range of LINK’s integration connectors, including but not limited to, accounting, marketing, inventory management, and loyalty systems. Thus further enabling automation and saving tens of thousands of hours otherwise spent by restaurants in manual data entry and reconciliation.

The Result

With thousands of new restaurants being on-boarded monthly onto its tech platform, the Company has established itself as the market leader in North America, and has gained a strong presence in LATAM, Middle East, and Europe. It has also capitalized on the cost-efficiency and integration velocity brought about by its partnership with LINK to identify the most critical integrations that are vital to the Company’s long-term success.

LINK’s platform can also be used by geographically diverse multi-restaurant and multi-brand companies to integrate their operations for analytics, supply chain optimization, and many other use cases.

Multi-outlet Retail Chain: POS & Inventory Management Integration

Multi-outlet Retail Chain: POS & Inventory Management Integration

Overview

A 16 chain specialty retail store (now expanding to 80 locations) needed to integrate their operations with their Cloud Point of Sale devices and enable the automation of their replenishment and supply chain model. They approached ShoppinPal for solution architecture and building out the necessary integrations.

The Challenge

They had a complex supply chain process with two central warehouses and a large number of SKUs being ordered by the stores. The manual process of ordering was time consuming and the fulfillment process was subject to human errors as there was no systematic tracking process in place.

From the store managers’ perspective, the time spent on the manual ordering/receiving process, trying to track discrepancies, and account for missing stock was taking away from their primary responsibility of providing their customers a great in-store experience.

The Solution

We built an automated fulfillment system that automatically created orders for the store managers based on the in-store sales and current inventory. The app also tracks the orders from the stores to the warehouses where the person can use the app to record their shipments.

The app makes the entire process easier and trackable and seamlessly syncs with the Point of Sale system so all inventory changes are up to date.

The Result

We enabled the client to plan, document, implement, and optimize the operational process and customized it to provide the client with a flow that mirrors their physical process. The alternate options that the clients had considered ranged between $80,000 and $120,000 per year. The homegrown solution built via integrations was accomplished for $45,000 in Year 1 with running costs of $6000 from Year 2 on. ShoppinPal also provides ongoing technical support and hosting to clients.

A top-rated e-commerce platform based in Canada specializing in the wines and spirits vertical

A top-rated e-commerce platform based in Canada specializing in the wines and spirits vertical

Overview

The Client is one of the world’s top-rated e-commerce platforms specializing in the wines and spirits vertical. They power some of the most popular wineries and have an impressive global customer base that is growing at 50% YoY. 

The Challenge

Many of their existing and potential customers were using Vend as their Point of Sale solution at the cash registers in their stores and expressed a need for an integration between the two systems in order to better manage inventory. While product subscription, shipping, and other information were being maintained by the client, the inventory, customer information, and sales data were being collected at the POS. Having an easy way to synchronise the data between the two systems would ensure that the POS has the most up-to-date product and inventory data and the e-com backend gets all the relevant inventory, sales, and customer data required for many of its functions. The lack of such integration was resulting in mismatched information, inventory stockouts, unfulfilled orders, and many hours of manual effort to reconcile the two systems. 

The Solution

The client engaged with link to scope, architect, and build a working, scalable, two-way integration between its own systems and Vend. We delivered the first version of the solution in 30 days with a budget of $2000 and helped on-board the first two clients. A few features for error detection were later added based on the customer feedback in order to help them catch mismatches.

The Result

The client has on-boarded 7 large Wineries since introducing the integration. We also provide full support and hosting services so that Blackboxx can focus on its core product while still providing its customers with the data sync service they really need. This has helped in increasing customer loyalty and preventing churn as the end customers are able to use their POS with their Blackboxx platform without having to make wholesale changes to their operations or migrate to a new system.

Retail Conglomerate: POS & ERP System Integration

Retail Conglomerate: POS & ERP System Integration

Overview

The client is a group of companies specializing in the distribution of internationally renowned premium brands in apparel, footwear, accessories, jewelry, and cosmetics across different markets in Europe. With a network of over 80 self owned & operated stores and 12 brand partnerships, the client is a leader in retail and distribution.

The Challenge

The group wanted to upgrade their ERP Software and install Netsuite Oneworld to streamline and manage their Wholesale and Retail businesses. They have 12 stores across the UK and Ireland that currently utilize Vend, a cloud-based point-of-sale(POS) and retail management software. They were looking for a way to integrate their POS & its related Accounting systems with Netsuite. All the sales & accounting data such as transactions, refunds, returns and store transfers from the point-of-sale needed to flow into Netsuite while the ERP would act as the master repository for product and inventory information. The integration also needed to support multiple subsidiaries and currencies(such as GBP, EURO) used by the stores in different geographies

The Solution

We implemented an integration between Netsuite and Vend which allows data to move seamlessly between the two systems. Our team worked in collaboration with the customer and the Netsuite implementation specialists to customise mappings and ensure that product, customer, sales, payments data from Vend were reflected real-time & with 100 % accuracy in Netsuite. On the Netsuite accounting front, we worked on ensuring that all data went into the correct accounts & that the General Ledger was correctly maintained, COGS were correctly reflected and P&L data was accurate

The Result

The integration is successfully functioning across the 12 stores in UK & Ireland  and has ensured smooth and seamless functioning of their Wholesale and Retail businesses resulting in significant improvements in process efficiencies, cost & time savings