Saving Money In The Cloud
If you've ever started a side project or a startup where the costs depend solely on you, you'll probably agree with me that saving money is very important.
I started using Amazon AWS for servers and GitHub. The main reason was that I wanted to learn more about cutting-edge technology, but once I gained the knowledge I wanted, costs started to arise. Now I want to share my tips with you on how to maintain quality and save money:
1) Embrace Static Websites
If you're creating a landing page, a blog, or any other website that can be turned into static pages, convert them into static websites. Forget Wordpress and use Jekyll. Static websites are faster, cheaper, and more secure. You can upload your entire website to Amazon S3, pay a few dollars per month, and serve your website from there! When combined with the s3_website gem, it becomes the state-of-the-art solution for static websites in my opinion.
2) Activate Swap on your Instances
If you run out of memory, your server will crash, and you'll probably need a more expensive server to handle the traffic. However, if the workload isn't significantly exceeding your memory limit, you can use Swap to store what goes beyond the memory limit on the hard drive. It will slow things down a bit, but it will save you a lot of trouble. If your instance is SSD-backed like Digital Ocean instances, reading from the hard drive will be less of a burden.
In some Digital Ocean images, SWAP is not activated by default. You need to enable it by using the following commands:
#!/bin/bash
# 3GB Swap, but you can change it, of course
# It's usually good to set it between 3GB and 5GB
# As root, execute the following commands:
fallocate -l 3G /swapfile;
chmod 600 /swapfile;
mkswap /swapfile;
swapon /swapfile;
echo "/swapfile none swap sw 0 0" >> /etc/fstab;
3) Move from GitHub to Bitbucket
I was hesitant to switch because of the absence of two-factor authentication, but they have implemented it, and I don't see a reason not to move from GitHub to Bitbucket, especially since you can have unlimited private repositories. The costs start to appear when you need more people to interact with your repositories, but until then, for small teams, it's great. The logic is as follows:
- GitHub: unlimited collaborators X pay per private repository
- Bitbucket: pay per collaborator X unlimited private repositories
One more thing
As I mentioned Digital Ocean, I moved from AWS EC2 to them because of the instance pricing (in comparison to AWS EC2 On Demand) and their high-quality support. Although it lacks the AWS Ecosystem, I'm very happy with the change. If you want to try them and get $10 USD credit right off the bat, use this link.
Stay tuned! More posts are coming :)