Spending next to nothing on the cloud

Update: AWS is launching DocumentDB. Mongo on AWS may make more sense now. 

Hosting bills, even for small startups, can reach into the thousands of dollars per month.  That’s in spite of robust cloud providers like AWS, Azure, and Google Cloud. You no longer have to spend a lot- even with plenty of users. But most people often do.

The Evolution

Physical Servers

At one point, companies built and housed their own servers (some still do). Not only does this increase the barrier to launch any software, it also proves fragile and time consuming; you’re on the hook for a server going down.

In almost all cases, this approach is akin to reinventing the wheel. You want to avoid spending precious resources on server maintenance. Fortunately, there are plenty of very cheap ways to manage your infrastructure.

Hosting Providers (GoDaddy, HostGator etc.)

Launching websites and buying domains from a cheap hosting provider often makes sense. For one thing, making sure your website is online becomes someone else’s problem. If you’re a hobbyist who wants to launch a website on your own, this is the approach I’d recommend. There’s a learning curve to configuring everything properly, but it’s easily doable.

Additionally, most hosting providers come with an easy WordPress install right from your dashboard. You setup WordPress and then manage themes and content directly from WP.  This will run you somewhere around $10 a month.

Cons of this approach

Shared Hosting on Namecheap or GoDaddy limit the capabilities of your platform. I’d caution against overestimating how many users you will need to support (you can always invest in better hosting as you get more users). But you can’t really move beyond a pretty slow PHP / MySQL project.

Furthermore, if you plan to constantly upload new code, beware. Deploying is a tedious process and necessarily manual. At best, you can use an FTP application to upload your files every time they change.

Cloud Providers (AWS, Azure, Google Cloud)

The big cloud providers supply a diverse ecosystem of services for you to build upon.  Specialized infrastructure has allowed platforms to optimize their speed and minimize their spending. They also offer great deployment solutions.

I would recommend against trying to master the cloud on your own. There’s a steep learning curve and people make full careers on designing cloud solutions. Doing it poorly will have you worse off than going with the shared hosting plan.

All that said, K-Optional has used many different services for different types of platforms & problems. Here, we’ll delve into some of the low hanging fruit. These are strategies we’ve perfected over time, and hopefully they’ll be helpful to your launch.

Cloud Solutions: the Low Hanging Fruit

The S3 app / website

Amazon S3 is a super-optimized file server. I could list countless uses, from sharing files to managing database backups. You’ll usually pay nothing due to generous pricing policies.

In the simplest case, you can upload static HTML files to an S3 and very easily point your domain name at it. We use S3 for complex web apps. Here’s the strategy:

  • Create an app using a modern frontend framework (Vue, React, Angular etc.)
  • Upload the build files to an S3
  • Configure a CDN so that the files are accessible from multiple locations. This means people in different parts of the world can quickly access your website.
  • Point a domain name at the CDN
You may wonder how you can accomplish much with static HTML. The trick is to leverage the frontend framework for dynamic template rendering. Importantly, things become a lot simpler when you separate you client and API completely (as opposed to a server that also provides the markup). For the backend API, we opt to go Serverless.

The Serverless API

Serverless often confuses people as it still involves a server. However, the developer’s job shifts from programming and managing a server to merely supplying code for the server to execute. This falls in line with the general trend of developers wasting less time on administration.

The Serverless approach is incredibly cost-effective. You only pay for your application’s traffic; NOT to run a server continuously that simply waits for requests.  Additionally, the server that does run your code has top-notch specs.

Shallow Dive with Serverless

As expected, there are numerous ways to take advantage of the Serverless architecture. For our projects we’ve found some that we really like.

  • Zappa adapts your Django App to run in a Serverless Environment
    • Combining this with the Django REST project, you'll have a robust REST API running only when you make requests
  • This guide is a great starting point for running an Express app Serverless.
In both cases, you might consider integrating GraphQL on your server and frontend, to get a little bit more power with your requests

Database solutions: RDS, MongoDB

Finally, the database layer is the last thing virtually every project requires.  Somethings we always recommend:

  • Using an ORM
  • Going with a database as a service
    • Don't have your database sitting on the same server as your website. It's obviously not optimized for data storage and harder to maintain.
The type of database you should use depends a lot on the application. When you model out the objects of your project, determine how rigid the structure of the data has to be. Do you know exactly what relationships you'll need in your model? If so, a SQL solution might be a good idea. Specifically, K-Optional will reach for PostgreSQL, an open sourced variant that's highly performant.

Setting up a PostgreSQL server via AWS isn’t that challenging. That’s typically our strategy for these types of projects.

On the contrary, MongoDB is great for more flexible data structures (an advantage and disadvantage).  I’d recommend MongoDB Atlas as a great cloud provider. It has a free sandbox plan for development, which is awesome. Setting up a MongoDB on AWS is a bad way to go. It involves a lot of custom configuration and is extremely expensive. If you really want an AWS NoSQL database, look into their DynamoDB solution.

Conclusion

You can build most any web or mobile platform with an S3, Serverless API, and database solution. On the whole, these things can and should be free while you’re developing and obtaining your first users. They all scale up wonderfully with traffic and will offer you the best bang for your buck.

If you need help designing your infrastructure, don’t hesitate to reach out!