by Prem Balasubramanian

Laying the groundwork for cost-conscious coding

feature
Feb 13, 20245 mins
Cloud ComputingSoftware Development

To avoid unnecessary cloud costs, you need to optimize the code that runs on top of the infrastructure. Defining cost as an SLO paves the way.

shutterstock 1863109306 row of digital electric meters measuring power consumption
Credit: Shozab1 / Shutterstock

Every cloud-consuming company is concerned about runaway cloud costs. To address those concerns, the big three cloud service providers have introduced cloud pricing calculators. We’ve also seen the rise of finops.

That’s a good start.

But cloud calculators and finops are infrastructure-focused, not application-focused. To avoid unnecessary cloud costs, you need to optimize the code that runs on top of the infrastructure. Cloud providers don’t address that part of the equation—that’s up to you.

It is time for people to think about cloud as an extension of their code. That is critical because inefficient code in the cloud makes you pay from day one/minute one.

Lack of optimization leads to higher cloud bills

In the on-premises world, you would deploy code on a server. Later, you would add features and data to serve even more users. Somewhere along the line, your server would hit 70% to 80% usage. At that point, you would start thinking about how you could accommodate more users.

Buying more servers was typically how data centers grew. But because purchasing, provisioning, and connecting a server would take three to six months, you might try to performance tune to see if you could bring the server usage from 80% back to 60%. That way, you would have 20% more headroom until you could purchase and set up your new hardware.

It’s a different story when you deploy code in a cloud environment.

In a simplistic world, as the adoption grows, the utilization increases correspondingly. However, you never hit 70% or 80% capacity because the cloud is auto-scaling. So, you never get into the cycle of planning for your next expansion—and you never work to optimize by tuning your code to gain more headroom.

Because you don’t get into that process, the 20% to 30% optimization you got on premises to create some headroom never happens. That means you’re automatically spending on that 20% to 30% usage. As this vicious cycle continues, you pay bills that are far higher than what you think they should be.

Developers and SLOs don’t currently consider cost

Many people still believe cloud is infrastructure. It is not. It is code! Yet no developer thinks about how much their line of code will cost in production.

Developers write code for functionality or, in some cases, resilience. Organizations carve out parameters like CPU and memory consumption, latency, and response times as service level objectives (SLOs).

Imagine the requirements for a project were two-second response time and 60% consumption. If the developers met these two requirements, they would think they were good to proceed.

But the cloud calls for an evolved approach. Because on the cloud, consumption is cost.

Every execution second adds cost. An optimization of one second for a transaction that typically takes two reflects directly in customer happiness and tangible cost savings immediately. If you can bring a line of code that runs for two seconds down to 500 milliseconds, you can save 75%.

Cost-conscious coding delivers efficiencies and savings

Adopting cost-conscious coding makes such optimization and cost savings possible. And cost-conscious coding will become even more important going forward as developers work with AI copilots, enabling them to develop code a whole lot faster.

How do you get started with cost-conscious coding?

Cost-conscious coding calls for site reliability engineering (SRE) knowledge. You may have SRE know-how, or build it, or you can work with a partner that has SRE expertise. Don’t think of SRE as a production support construct. Think of it instead as a software engineering philosophy.

A good start is to treat cost as an SLO. The moment that you define cost as an SLO alongside availability, performance, scalability, and consumption, developers will start working to address it.

Manage your cost SLO by defining, measuring, calibrating, and recalibrating it. Cost-conscious coding is an iterative process. Different organizations will achieve different savings at the beginning of their efforts. As you progress, your returns will stabilize because cost-conscious coding follows the law of diminishing returns.

Understanding that returns will diminish is important. You will want to use cost-conscious coding only where the returns are worth the effort you put into it.

But do get into the practice of cost-conscious coding—and break the cycle of paying more for cloud services than you should. It will be good for your business. Even if you are within your cloud budget, make the effort to do cost-conscious coding. It will provide you with scalability and profitability as your user base, consumption, applications, and revenues grow.

Premkumar Balasubramanian is chief technology officer of Hitachi Digital Services. He is primarily responsible for strategizing and supporting all of the company’s go-to-market pursuits, architecting repeatable solutions and providing technology and thought leadership in the areas of cloud, data, IoT, and generative AI.

New Tech Forum provides a venue for technology leaders—including vendors and other outside contributors—to explore and discuss emerging enterprise technology in unprecedented depth and breadth. The selection is subjective, based on our pick of the technologies we believe to be important and of greatest interest to InfoWorld readers. InfoWorld does not accept marketing collateral for publication and reserves the right to edit all contributed content. Send all inquiries to doug_dineley@foundryco.com.