Being elastic in nature, many of us think migrating to cloud will be a cost-effective solution to host infrastructure. But this is partly true, however, when your hosted infrastructure becomes fat the cost of the cloud increases rapidly. Moreover, managing cloud infra costs becomes difficult because of the growing infrastructure/teams. To curb the increasing costs, here are a few best practices which can be adhered to manage infrastructure efficiently. In addition, this blog mainly talks around AWS although these inputs are more or less similar for all cloud providers.
- Right-sizing: Select the lowest cost resources which can fulfill your technical needs. Do not go with over-provisioning assets as they are a classic recipe for disasters. In cloud, you will get elasticity to increase the size on the fly, however, though this thought this looks simple you might have to play with assets to find the right sized resources. For example, you have a task to a process for which its necessary to provision a specific instance and terminate it after the task gets finished. In this scenario, a t2.small instance type took 120 minutes to finish the work and on the other hand an m5.large finishes the same task in 5 minutes. In this case, m5.large is an efficient option to consider.
- Purchase Options:
- Spot Instances – Spot instances are far cheaper than on-demand instances of the same capacity and they can even be bided for a minimum required duration as well. You can also design your application which adds new tasks in the queue and waits for spot instances for a number of hours. In that time frame, spot instances will start processing the tasks or otherwise, the application will start on-demand instances and finish the task after the given time frame. This also opens the option of changing the time-frame to a number of tasks as well.
- Reserved Instances – Save resources by knowing how much capacity is required in the coming years. To get reserved instances, you need to sign the cloud services agreement with AWS for a tenure of 1-3 years. Longer the agreement period, lower the cost will be. Cloud providers also give concessions on full payment for the agreement.
- Geographical Locations: Cloud providers offer services at different rates for different locations. For example, AWS N.Virginia region generally has low rates than other regions. If you are ready to deal with a slight network latency you can check different regions and host assets in cheaper regions. In another situation, you can even host your development and testing environments in low-costing regions and keep production systems in regions which are close to your customers. Keeping in mind, that some assets/services are available only in some specific regions.
- Pay as You Go: You can save a huge amount of cost on developing and testing environment by running it only when you need it. To elaborate it further, a dev environment is running 24*7 = 168 hours. If you spin off the assets each night and spin it on again in the morning in working days and working hours, it will reduce to 5*10 = 50 hours, almost saving ? of your costs. This solution comes handy in dev and testing environments (with queue like SQS we can use this strategy in prod cases as well).
In addition, you might want to try CloudHedge for saving additional costs. The CloudLease feature enables you to custom schedule Start and Stop instances hosted on Amazon Web Service (AWS), Microsoft Azure and, Google Cloud Platform cloud vendors.
- Managed Services: Managed services help in curtailing infra costs on a regular basis. For example, running a database on RDS is cost-effective than deploying it on instances and further managing it on a day-to-day basis. You might feel that the cost of Managed Services is high, however, consider this offering to eliminate the pain of managing instances, including OS level patching, antivirus, version upgrade and many more.
- Optimize on Data Transfer: Network cost increases with more hits on your application. Make use of CloudFront for cashing some content on edge locations as it will reduce the strain from the server as each request does not come to servers for processing. You can put static content like CSS/JS/images files on sS3 rather than on server itself. In some scenario, assets in network talk to each other by public endpoints and can grow costs rapidly.
Cost optimization is an endless process, you need to be updated in tools/cloud managed services frequently and implement new things. In addition, email us at firstname.lastname@example.org if you want to migrate or manage your cloud infrastructure efficiently.