Need advice about which tool to choose?Ask the StackShare community!
Serverless vs Terraform: What are the differences?
Serverless and Terraform are two popular technologies used in web development and infrastructure management. While both have their own unique features and functionalities, they also have some key differences that set them apart from each other. This markdown code aims to highlight and provide a concise description of these differences.
Scalability: Serverless architecture allows applications to automatically scale up or down based on demand. It abstracts the infrastructure layer and manages the scaling on behalf of the developers. On the other hand, Terraform is an infrastructure-as-code tool that provides scalability through defining resources and their configurations in the code. It allows developers to specify the desired state of their infrastructure and make changes accordingly.
Vendor Lock-In: Serverless platforms are often tied to a specific cloud provider, such as AWS Lambda or Azure Functions. This can result in vendor lock-in, making it difficult to switch to another provider. Terraform, on the other hand, is cloud-agnostic and supports multiple cloud providers. It allows developers to define resources using a consistent language across different platforms, reducing vendor dependency.
Cost Management: Serverless architectures have a pay-per-use pricing model, where developers are charged based on the actual usage of their applications. This can be advantageous for applications with unpredictable or varying workloads. Terraform, on the other hand, does not directly handle cost management. It focuses on infrastructure provisioning and management, and developers need to manage the cost of resources manually.
Flexibility: Serverless architectures provide a high level of flexibility, allowing developers to focus on writing code without worrying about infrastructure management. It abstracts away infrastructure details, making it easier to deploy and maintain applications. Terraform, on the other hand, offers more control and flexibility in defining infrastructure configurations. Developers can specify resource parameters and dependencies, giving them granular control over their infrastructure.
Execution Environment: Serverless platforms provide isolated execution environments for applications, ensuring that one application does not impact the performance or security of other applications. Terraform, on the other hand, does not provide execution environments as it focuses on provisioning and managing infrastructure. It is mainly used in conjunction with other tools and platforms to run applications.
Deployment Time: Serverless architectures offer faster deployment times as the infrastructure is managed by the platform. Developers can quickly deploy their applications without worrying about configuring servers or managing infrastructure. Terraform, on the other hand, may have longer deployment times, especially for larger infrastructures. It requires the creation and configuration of resources, which can take more time depending on the complexity of the infrastructure.
In summary, Serverless architecture provides automatic scaling, vendor lock-in, cost management, flexibility, isolated execution environments, and faster deployment times, while Terraform focuses on cloud-agnostic infrastructure provisioning, offers more control and flexibility, does not handle cost management directly, does not provide execution environments, and may have longer deployment times.
Because Pulumi uses real programming languages, you can actually write abstractions for your infrastructure code, which is incredibly empowering. You still 'describe' your desired state, but by having a programming language at your fingers, you can factor out patterns, and package it up for easier consumption.
We use Terraform to manage AWS cloud environment for the project. It is pretty complex, largely static, security-focused, and constantly evolving.
Terraform provides descriptive (declarative) way of defining the target configuration, where it can work out the dependencies between configuration elements and apply differences without re-provisioning the entire cloud stack.
AdvantagesTerraform is vendor-neutral in a way that it is using a common configuration language (HCL) with plugins (providers) for multiple cloud and service providers.
Terraform keeps track of the previous state of the deployment and applies incremental changes, resulting in faster deployment times.
Terraform allows us to share reusable modules between projects. We have built an impressive library of modules internally, which makes it very easy to assemble a new project from pre-fabricated building blocks.
DisadvantagesSoftware is imperfect, and Terraform is no exception. Occasionally we hit annoying bugs that we have to work around. The interaction with any underlying APIs is encapsulated inside 3rd party Terraform providers, and any bug fixes or new features require a provider release. Some providers have very poor coverage of the underlying APIs.
Terraform is not great for managing highly dynamic parts of cloud environments. That part is better delegated to other tools or scripts.
Terraform state may go out of sync with the target environment or with the source configuration, which often results in painful reconciliation.
I personally am not a huge fan of vendor lock in for multiple reasons:
- I've seen cost saving moves to the cloud end up costing a fortune and trapping companies due to over utilization of cloud specific features.
- I've seen S3 failures nearly take down half the internet.
- I've seen companies get stuck in the cloud because they aren't built cloud agnostic.
I choose to use terraform for my cloud provisioning for these reasons:
- It's cloud agnostic so I can use it no matter where I am.
- It isn't difficult to use and uses a relatively easy to read language.
- It tests infrastructure before running it, and enables me to see and keep changes up to date.
- It runs from the same CLI I do most of my CM work from.
Context: I wanted to create an end to end IoT data pipeline simulation in Google Cloud IoT Core and other GCP services. I never touched Terraform meaningfully until working on this project, and it's one of the best explorations in my development career. The documentation and syntax is incredibly human-readable and friendly. I'm used to building infrastructure through the google apis via Python , but I'm so glad past Sung did not make that decision. I was tempted to use Google Cloud Deployment Manager, but the templates were a bit convoluted by first impression. I'm glad past Sung did not make this decision either.
Solution: Leveraging Google Cloud Build Google Cloud Run Google Cloud Bigtable Google BigQuery Google Cloud Storage Google Compute Engine along with some other fun tools, I can deploy over 40 GCP resources using Terraform!
Check Out My Architecture: CLICK ME
Check out the GitHub repo attached
When adding a new feature to Checkly rearchitecting some older piece, I tend to pick Heroku for rolling it out. But not always, because sometimes I pick AWS Lambda . The short story:
- Developer Experience trumps everything.
- AWS Lambda is cheap. Up to a limit though. This impact not only your wallet.
- If you need geographic spread, AWS is lonely at the top.
Recently, I was doing a brainstorm at a startup here in Berlin on the future of their infrastructure. They were ready to move on from their initial, almost 100% Ec2 + Chef based setup. Everything was on the table. But we crossed out a lot quite quickly:
- Pure, uncut, self hosted Kubernetes — way too much complexity
- Managed Kubernetes in various flavors — still too much complexity
- Zeit — Maybe, but no Docker support
- Elastic Beanstalk — Maybe, bit old but does the job
- Heroku
- Lambda
It became clear a mix of PaaS and FaaS was the way to go. What a surprise! That is exactly what I use for Checkly! But when do you pick which model?
I chopped that question up into the following categories:
- Developer Experience / DX 🤓
- Ops Experience / OX 🐂 (?)
- Cost 💵
- Lock in 🔐
Read the full post linked below for all details
We are in the process of building a modern content platform to deliver our content through various channels. We decided to go with Microservices architecture as we wanted scale. Microservice architecture style is an approach to developing an application as a suite of small independently deployable services built around specific business capabilities. You can gain modularity, extensive parallelism and cost-effective scaling by deploying services across many distributed servers. Microservices modularity facilitates independent updates/deployments, and helps to avoid single point of failure, which can help prevent large-scale outages. We also decided to use Event Driven Architecture pattern which is a popular distributed asynchronous architecture pattern used to produce highly scalable applications. The event-driven architecture is made up of highly decoupled, single-purpose event processing components that asynchronously receive and process events.
To build our #Backend capabilities we decided to use the following: 1. #Microservices - Java with Spring Boot , Node.js with ExpressJS and Python with Flask 2. #Eventsourcingframework - Amazon Kinesis , Amazon Kinesis Firehose , Amazon SNS , Amazon SQS, AWS Lambda 3. #Data - Amazon RDS , Amazon DynamoDB , Amazon S3 , MongoDB Atlas
To build #Webapps we decided to use Angular 2 with RxJS
#Devops - GitHub , Travis CI , Terraform , Docker , Serverless
Pros of Serverless
- API integration14
- Supports cloud functions for Google, Azure, and IBM7
- Lower cost3
- Auto scale1
- Openwhisk1
Pros of Terraform
- Infrastructure as code121
- Declarative syntax73
- Planning45
- Simple28
- Parallelism24
- Well-documented8
- Cloud agnostic8
- It's like coding your infrastructure in simple English6
- Immutable infrastructure6
- Platform agnostic5
- Extendable4
- Automation4
- Automates infrastructure deployments4
- Portability4
- Lightweight2
- Scales to hundreds of hosts2
Sign up to add or upvote prosMake informed product decisions
Cons of Serverless
Cons of Terraform
- Doesn't have full support to GKE1