12 programming tricks to cut your cloud bill

4 min read
Curated from infoworld.com →

Nothing lifts a development team’s spirits like watching an application go viral. It’s a wonderful feeling–at least, until the monthly cloud bill comes in. Some developers believe that managing the cost of computing is a responsibility for the devops squad. Coders write the software, toss it over the wall, and let someone else worry about paying for it. Nothing could be further from the truth.

Smart developers know that their coding decisions make a big difference for the company bottom line. Bulky code is slower and requires more cloud resources to run. Choosing better algorithms and writing tighter code is about more than just speed. Well written code costs less to run.

Developers don’t always see the connection. It’s easy to write code on your own machine, where RAM and extra disk space were paid for when the machine was purchased. If you’ve got two terabytes of disk space, you might not notice how much of it your code consumes. If a new algorithm takes twice as long to run, your desktop might not even blink–and besides, who notices a few extra milliseconds? But it’s almost certain that doubling the computation will result in a larger cloud bill.

Modern cloud computing excels at converting resource utilization into a line-item charge. Good cloud developers understand that they have the power to make smarter decisions when writing their code. It can be as simple as running a profiler to identify slow spots, or avoiding unnecessary data storage for a lower memory footprint.

Here are 12 ways to streamline your code so that it is leaner, faster, and cheaper to run.

Most developers don’t spend much time optimizing their code. If it runs in a split second on their laptop, they don’t notice if it’s running 20%, 30%, or even 300% slower over time. The program is still responding in split seconds. But these differences add up when they occur millions of times on the server. Careful profiling can flag the slow parts. Rewriting them could reduce the number of instances your application needs.

The amount of RAM being used is an important parameter for pricing cloud instances. In many cases, doubling your RAM also doubles the cost. Programmers can lower their RAM footprint by avoiding keeping data in memory. Some streaming algorithms, like Java’s Stream classes, are designed to work with large files of data without loading them all into memory.  The Apache DataSketches project generates approximate answers for complex big data statistics without occupying all the memory.

As a side benefit, careful RAM consumption can also speed up your algorithms. Sometimes, the operating system will start offloading data onto the disk using virtual memory. This prevents crashing, but it can slow down your programs dramatically.

Using lower resolution images and video can pay off in multiple ways. First, storing them will be cheaper. Second, any data exfiltration charges will be lower. Third, the application will seem snappier to users.

All static images should be minimized from the beginning. The amount of minimization, alas, is not simple because at some point the visual quality degrades enough to be apparent to users. Finding the right tradeoff is a design decision that some programmers aren’t prepared to make.

Some applications that use uploaded images can also create smaller thumbnails and reduced-resolution versions after receiving the image. Toolkits like ImageMagik and formats like WebP were developed for this purpose.

Many developers are digital pack rats who store information just in case they might need it someday. They fill out tables with endless columns and then never delete the rows. The extra data doesn’t cost anything if you own the hardware and the disk drive has plenty of space. But the cloud charges for everything. Will you really need all those values in the future? Does the user even want so many details? Dumping some of that old data will save you money on data storage and exfiltration.

Continue Reading

Enjoyed this summary? Read the complete article at the source:

Continue at infoworld.com →

Yves Mulkers

Yves Mulkers is the founder of 7wData and a widely followed voice in the data and AI community. He curates the 7wData and AI Beat newsletters, reaching hundreds of thousands of data and AI professionals, and writes on data strategy, analytics, AI, and the evolving data ecosystem.