No good deed goes unpunished. I certainly don’t believe that — but when I built an API and put it out there for other people to use for free, the huge AWS bill hit me like a ton of bricks.
 
I built the API as a response to a question on Stack Overflow. It took me less than a day to build and post it. A few months later I learned that the API was getting millions of requests per day. This was great — but I quickly realized that it wasn’t financially sustainable.
 
I was really happy that so many people found it useful, but I got an unexpected surprise when I received an email alert that my server usage was off the charts. At the time, I had a full-time job and never intended to charge for the API, but I found myself in a predicament.

Should I start charging for the API to help cover the high usage costs?
 
Beyond AWS, I really didn’t have any other hard operating costs. I found the best balance by taking steps to reduce AWS costs, while also monetizing the API so that really heavy users would help share the cost of operations. This was how I could make my API accessible to a large user base — and make it sustainable over time.

Monetize Your Product to Cover Costs

Free products are a great way to spread the word about your product and grow usage, but when you start getting a lot of users you run into trouble. When hard costs increase as more people use your free product, you hit a point where you either shut it down for lack of funds or you monetize to keep the service alive.
 
Monetizing something that you originally gave away for free might feel disingenuous, but to make sure that everyone can keep using it in the way they want, it’s actually the fairest way to make your operating costs sustainable in the long term. And if those really high-volume users are getting a lot of value from the tool, they will be happy to help support the product in exchange for the service. 
 
The challenge is to monetize with an eye towards supporting the community, rather than exploiting it. For that reason, I stayed away from indirect monetization like selling advertising or user data to cover costs. I set out to monetize the product in a way that supported the community. 
 
Developing the right monetization strategy that won’t alienate your users takes time and testing. By experimenting with different pricing structures and keeping my users informed of my intentions, I was able to find an acceptable pricing structure that aligned with the perceived value. It took nearly two years to finalize.

After running a half dozen pricing experiments and receiving feedback from users, I saw three big themes from what I’d learned:

  1. Most of your users will pay nothing, but that doesn’t mean you lose out. Your core users are part of a bigger community that shares good ideas and supports each other. It’s important for your product to be part of their everyday interactions, even if they’re not paying anything.
  2. Your users come in all shapes and sizes, so try to include all of them in your pricing. You might have hobbyists, freelancers, and big businesses all enjoying your product. Don’t be afraid to create multiple pricing tiers that make sense for each group and reflect what each group is willing to pay for the tool.
  3. Keep your plans simple, using one value metric. When users clearly understand what you are charging for, it makes it easy to choose the right plan. For ipinfo, our value metric is the number of requests. This metric not only separates hobbyists from heavy users, but it is directly related to our hard costs.

To deliver the most value and keep users' fees as low as possible, you need to keep your operational costs down. Here are some ways you can optimize your AWS resources to reduce costs and keep pricing low.

Read On: How I Monetized My Invisible Product.

Optimize AWS to Reduce Hard Costs

Even though AWS has a pay-as-you-go pricing model with elastic scalability to run usages up or down, the costs can still get really expensive if you are not paying attention to what you are using.
 
AWS offers a lot of different services to accommodate varying use cases, which can help bootstrap your new business if you are smart about choosing the right features and optimizing them accordingly. Keeping costs down with AWS is an iterative process, where continual check-ins are the key to understanding usage and removing waste.

Whether you are monetizing your product or not, it is always smart to stay on top of your costs. As a business you want your margins to improve but more importantly, you want to keep your costs down for all your loyal users. These are some of the best ways to keep an eye on your AWS costs, especially if there is a chance that your usage skyrockets.

Plan Ahead to Size Your Resources

I never imagined that my API would receive millions of requests after I posted it. If I did, I would have saved a lot of money with AWS by planning ahead and anticipating the spike.
 
In reality, it is difficult to predict the number of resources you will need to ensure uptime, which leads most people to over-provision capacity. Instance prices are proportional to the size of each instance. The more resources an instance requires, the more it will cost.
 
Do the best you can to predict usage before your product launches, but once the product is live, you will have access to metrics that can help predict sizing. Instance right-sizing is the first step to cost savings as it will inform your purchasing decision.

Understand Your Purchasing Options

AWS offers service options for every type of business, which is great — unless you choose the wrong option that ends up costing more than you ought to be paying.
 
There are three ways to purchase instance resources on AWS. Understanding them and selecting the best option will help you control your costs:

  • On-Demand Instances is the fixed rate plan where you can cancel anytime. This is great for smaller projects where you pay smaller variable costs per use, but when usage surges it can be expensive.
  • Reserved Instances provide a considerable discount over on-demand prices, but the caveat is that you have to commit to a longer-term purchase.
  • Spot Instances is not recommended if your product can’t afford random service interruptions. The idea is to bid your own price on instance capacity, but when your price is not available, you go dark.

Both On-Demand and Spot Instances require some careful planning or your costs will go through the roof. Once you nail down your estimated usage, reserved instances are the most cost-effective option, but you will be locked-in for at least a year. That said, most companies save 30%-75% over the on-demand approach by paying in advance.

Monitor & Analyze to Optimize Costs

Once your service is live, AWS provides two valuable tools you can use to monitor, analyze and optimize your resources.

  • CloudWatch is the AWS monitoring tool that tracks important metrics like CPU usage and latency, storage space and memory, and custom performance counters. You can also create notifications when certain metrics appear in the logs or specific events take place
  • Cost Explorer helps you better understand your costs so you can figure out new ways to optimize. You can create custom reports to find the trends that are driving costs and dig deeper to inform what your usage will look like in the future.

These analyses provide insights into how you can improve your costs, but you need to go through the process of consistently reviewing the usage trends. Most products change over time, and cost inefficiencies are usually a result of not updating your AWS plan to align with changes in your activity.

Consider the AWS Serverless Architecture

Amazon’s serverless option can be extremely cost-effective depending on the amount of compute time you need to run your product.
 
The serverless approach only uses server resources in response to specific requests, which alleviates the need to predict how many resources you will need in advance. When your product is not using any resources, you pay nothing.
 
Let’s say you build an API that aggregates NFL scores. The majority of your requests will come on game days, but for the rest of the week, your API will be idle. Instead of paying AWS during the week for unused resources, the serverless option allows you to only pay for the actual events that happen on active days.
 
Lambda, Amazon’s serverless product, enables you to run code for almost any type of backend service without the need to provision or manage servers. For start-ups or individuals like me, this option helps reduce the complexity and costs of developing, scaling, and operating your product.

Source: Github.io

The example above shows how a REST API can be deployed with an AWS serverless architecture. API Gateway and Lambda work together to provide a cost-effective way to manage backend services without the traditional overhead.
 
The way that Amazon CTO Werner Vogels explains serverless puts a little bit of this into perspective:

“Before, your servers were like pets. If they became ill, you had to nurture them back to health. Then with cloud, they were cattle. You put them out to pasture and got yourself a new one. In serverless, there is no cattle, only your product, and all the execution is taken care of.”

It’s important to note that serverless is not always a cheaper approach. There are certain use cases and workloads that require a high volume of compute resources, which will drive up the costs. Use this serverless cost calculator to get a quick estimate before you jump in.

Good Deeds Open New Doors

Today, IPinfo gets 250 million daily requests, and my side project has now become a full-time job. It turns out that good deeds aren’t punished — they open doors to new opportunities.
 
When I received that first expensive AWS bill, I thought my free API was going to be a financial burden. But in the long run, it forced me to create a fair pricing model with an eye on cutting operational costs. 
 
By being a decent community citizen when taking these steps, your deeds will allow you to help a wider audience and can help the process be sustainable for you in the long run.

IPinfo is a comprehensive IP data and API provider with flexible pricing plans to meet your business needs. We handle billions of API requests per month, serving data like IP geolocation, ASN, mobile carrier, and hosted domains. Sign up for a free account or contact our sales team to learn more.