For startups & SMBs

Docs


Careers

Blog

Pricing

Terms of Use

Privacy policy

Contact us

Sign up

Serverless? Containers? Why not both?

Simon Obetko, Dev @ Stacktape

March 14, 2024

In the developer community, the discussion around whether serverless or containerized approaches reign supreme has been lively. Which one's better? Stacktape's philosophy is straightforward: developers shouldn't have to limit themselves to one paradigm. By supporting both serverless and containers, Stacktape enables teams to pick the right tool for the job.

Containers vs Serverless Lambdas? It's not about preferring one over the other; it's about choosing the right one for your needs.

Fight

Going Serverless with AWS Lambda

Stacktape Lambda functions (running on AWS Lambda) are great for event-driven architectures, microservices, and apps with changing traffic. You only pay for what you use, without the hassle of managing servers.

Easy Lambda Setups with Stacktape

Setting up Lambdas with Stacktape is straightforward. Just point to your handler file, and Stacktape handles the rest, packaging and deploying your code. This simplicity removes the complex steps usually involved with Lambda, like creating deployment packages and sorting out dependencies.

Lambda's Flexibility

Lambda can handle a lot of different tasks:

  • Incoming HTTP events: For APIs or webhooks.
  • Queue events: Processing messages from AWS SQS, AWS SNS, or Kafka.
  • Scheduled tasks: Running jobs at set times.
resources:
generateReport:
type: function
properties:
packaging:
type: stacktape-lambda-buildpack
properties:
entryfilePath: src/generate-report.ts

Streamlined Access Control

With Stacktape, setting up access to other AWS resources for your Lambda functions is easier. Instead of diving into IAM roles and policies, you tell Stacktape what your Lambda needs access to, and it sorts out the permissions and injects required environment variables into your function. This means less time on setup and fewer chances for security slip-ups.

resources:
generateReport:
type: function
properties:
packaging:
type: stacktape-lambda-buildpack
properties:
entryfilePath: src/generate-report.ts
connectTo:
- reportDataTable
reportDataTable:
type: dynamo-db-table
properties:
primaryKey:
partitionKey:
name: id
type: string

Read on in our documentation for more information on Lambda functions

Using Containers for Full Control

Containers are ideal for traditional applications, complex environments, or when you need full control over the runtime and dependencies. They offer an isolated environment for your application, ensuring consistency across development, testing, and production.

Easy and Flexible Container Packaging Options with Stacktape

Stacktape offers flexible options for packaging your container:

  • Auto Packaging: Let Stacktape package your code automatically.
  • Buildpacks: Use buildpacks for an easy and automated way to create container images, similar to how Heroku operates.
  • Dockerfile: Specify a Dockerfile to customize the build process of your container image.
  • Prebuilt Images: Use a prebuilt container image from a registry.
Container packaging options

Stacktape’s Container Solutions: Tailored for Every Task

Stacktape supports various flavors of container workloads, each designed for specific use cases:

  • Web Service: A continuously running container with a public endpoint and URL. Ideal for public APIs and websites.
  • Private Service: Similar to a web service but with a private endpoint. It's used for private APIs and services within your infrastructure.
  • Worker Service: A continuously running container not accessible from the outside, perfect for ongoing processing tasks.
  • Multi-Container Workload: Allows custom setups with multiple containers, where you can define accessibility for each container. This is great for more complex scenarios that require customization.
  • Batch Job: A simple container job that terminates once the job is complete. Suitable for one-off or scheduled processing tasks.

You do not need to learn about all the underlying AWS services such as Fargate, EC2 or Elastic Load Balancing. Stacktape abstracts these complexities away from you, so you can only focus on what you need.

resources:
web:
type: web-service
properties:
packaging:
type: stacktape-image-buildpack
properties:
entryfilePath: src/index.ts
resources:
cpu: 1
memory: 1024

Combining Containers and Lambda

Often, you might want your server's main tasks in a container but offload resource-intensive jobs (e.g., report generation) to a Lambda function. Stacktape makes this mix easy. You get containers for heavy lifting and Lambda for specific, scalable tasks. This way, your core application runs in containers, with Lambda stepping in when needed. Stacktape streamlines this setup, ensuring containers and Lambda work well together in your AWS setup.

resources:
# serves as entry gateway to our app
entryGateway:
type: http-api-gateway
# serves bulk load of what our app does
web:
type: multi-container-workload
properties:
containers:
- name: nuxt-app
packaging:
type: stacktape-image-buildpack
properties:
entryfilePath: src/index.ts
events:
- type: http-api-gateway
properties:
httpApiGatewayName: entryGateway
containerPort: 3000
method: '*'
path: '*'
resources:
cpu: 1
memory: 1024
# offloading generating report to a lambda
generateReport:
type: function
properties:
packaging:
type: stacktape-lambda-buildpack
properties:
entryfilePath: src/generate-report.ts
connectTo:
- reportDataTable
events:
- type: http-api-gateway
properties:
httpApiGatewayName: entryGateway
method: GET
path: /generate-report

Enhancing Cloud Development Workflows with Stacktape

Ever developed your app locally, only to have it crumble after deploying to the cloud due to missing permissions or environment variables? We've been there. That's why we created `stacktape dev`.

`stacktape dev` was crafted to let you develop your workload interactively, ensuring it mirrors the production environment as closely as possible. Here's how it works with Lambda functions and containers:

  • Lambda: The command updates the Lambda code in the cloud in real-time. This means you're actually testing it directly in the cloud environment, ensuring that what you see in development matches what you'll get in production.
  • Containers: For container workloads, `stacktape dev` starts the container locally but injects all the required permissions and environment variables. This approach aims to replicate the cloud environment as accurately as possible, right on your local machine.
Stacktape dev in action

Conclusion

We've covered our Serverless functions and Container solutions, showing how Stacktape makes AWS development and deployment easier. But there's much more to explore.

To really see what Stacktape can do, try our starter projects. They're made to help you start fast, using popular frameworks to give you practical experience with serverless and containers in real situations.




We are looking forward to seeing what you build with Stacktape, and your feedback to make it even better.

More on Launch Week #1 & how to support us:

Want to deploy production-grade apps to AWS in less than 20 minutes?

Let Stacktape transform your AWS into a developer-friendly platform.

Learn more

Stay in touch

Join our monthly product updates.

input icon

Copyright © Stacktape 2024