Infrastructure as Code Best Practices with Terraform for DevOps
João Victor Alhadas | Dec 17, 2024
When developing a mobile or web application, it is often necessary to build a web server that will integrate with your product. This part is often called the backend and, in simple words, it is the running piece of software that stays remote to all users – Cloud services, the center where the database is located and the place where the clients (iOS apps, for example) retrieve data from.
Although invisible from the user perspective, the backend is fundamental for any data-driven application – it is the component that users usually don’t directly interact with but, if it ever goes down, it might cause all of your client apps to stop working. The backend has a couple of other more famous nicknames: “the server” or – when it’s remotely located – “the cloud“.
After realizing the importance of a stable, scalable and reliable server – while developing a mobile or web application, for instance – the next step is to decide between the several cloud services available for hosting it, all of them having different aspects that should be taken into account.
Here’s a comparison of the most common cloud services for backend hosting, as well as their prices, usage difficulty levels and implications on the development workflow as a whole [no particular order was used].
Difficulty level: Easy.
Cost: $$$
Languages/Frameworks supported: Ruby, Node.js, Python, Java, Go and PHP.
Overview: Heroku is one of the big names of the new generation of PaaS (Platform as a Service). It takes care of scaling your application and load-balancing it — meaning it automatically creates/removes new virtual machines to your website cluster depending on the number of clients accessing it. They also have almost plug-and-play integration with a wide variety of services, ranging from pay-as-you-use databases to monitoring, logging, searching and a whole set of other useful tools.
Development Workflow Implications: Heroku provides a CLI (command-line interface) that integrates with Git, so, after an initial and fairly simple setup, developers just need to run a single command to send updates to the backend. It also has its own protection against various attack types, so that the backend developers can focus on the application development itself.
Difficulty level: Easy.
Cost: $$
Languages/Frameworks supported: Java, Ruby, PHP, Node.js, Python and Perl.
Overview: Red Hat OpenShift Online is a very powerful alternative to Heroku. Having the same capabilities of easy deployment, autoscaling and load balancing, OpenShift only lacks the user-friendliness and awesome CLI that its main competitor offers. On the other hand, the developers have more control over how things run in the host machine — even though it’s not necessary (nor recommended) to deal with any low-level configuration.
Development Workflow Implications: OpenShift offers a Git hook that is triggered whenever new code is pushed to the repository, and it handles distribution over all machines in the cluster. Similarly to Heroku, this enables really straightforward continuous integration, letting the development team focus on the business logic rather than on setup overhead.
Difficulty level: Intermediate.
Cost: $$
Languages/Frameworks supported: Go, Java, .NET, Node.js, PHP, Python, Ruby and Docker.
Overview: Elastic Beanstalk is the complicated cousin of Heroku. Amazon has put together a lot of their individual solutions together to make something that would, at least in theory, make the lives of backend developers easier. However, as robust and reliable as Amazon Web Services are, user- (or developer-) friendliness is definitely not one of their sweet spots, and EB is considerably less configurable than its competitors.
Development Workflow Implications: Once you manage to make EB work for the first time, the benefits of using it are the same as Heroku and OpenShift — letting your team focus on the application, not on deployment and manual scaling overhead.
Difficulty level: Advanced.
Cost: $$
Languages/Frameworks supported: Any.
Overview: AWS EC2 is basically a virtual machine running an OS of your choice. It’s up to your team to install/build anything on top of it. Although this gives a lot more flexibility than any of the tools above, it also requires a considerably more experienced team to ensure your web server is stable and reliable.
Development Workflow Implications: There are no automated deploy tools connected beforehand, although Amazon provides some solutions that you can plug in for that, like AWS CodeDeploy. This cloud service is ideal when the engineering team already has a consolidated development workflow, associated with tools like Ansible, Chef or Puppet, and can also handle the configuration of services like Elastic Load Balancer and the setup of Auto-Scaling Groups.
Difficulty level: Advanced.
Cost: $
Languages/Frameworks supported: Any.
Overview: DigitalOcean Droplets are the equivalents of AWS EC2 instances. They are also virtual machines with SSH access, providing a lot of flexibility to the engineering team. Although DigitalOcean is considerably cheaper than AWS EC2, it also does not offer the huge variety of plug-and-play services that its competitor does.
Development Workflow Implications: Developing with DigitalOcean is as hardcore as it gets when dealing with cloud services. They offer virtual machines with good bandwidth that are able to communicate between each other. Period. The development team will be the responsible for building (or using open-source solutions) for load balancing, scaling and deployment, which can generate a big development overhead for an inexperienced team.
Difficulty level: Advanced.
Cost: $$
Languages/Frameworks supported: Any.
Overview: Rackspace Cloud Servers are somewhat in the middle of the way between AWS EC2 instances and DigitalOcean Droplets. They have a wider variety of hardware specs than the latter does, but don’t have the incredible number of plug-and-play services that Amazon offers.
Development Workflow Implications: The development workflow is really similar to DigitalOcean, which means it’s entirely up to the dev team to use and/or develop load balancing, scaling and deployment tools for the servers.
Each situation requires specific tools. Although all of the cloud services solutions can support a wide variety of applications, it is key to understand the implications on the development effort once one of them is chosen. At Cheesecake Labs, our favorites are AWS EC2 for projects that have are more focused on long-term goals and Heroku for bootstrapping backends and validating concepts. What are your picks?
Progressive rock lover, programming languages aficionado, full-stack web/mobile developer and pentesting enthusiast. Legend says he's never lost a Pokémon battle.