Running serverless web service in AWS | Altostra
NEW: AI-Powered Cloud Deployments

Running serverless web service in AWS

Deploy serverless ECS Service to AWS Fargate Cluster in minutes
Bohdan Basov

September 8 2022 · 5 min read


Running serverless web service in AWS

When deploying a web server, you usually want an always-on service to handle all your incoming requests. For many developers, this automatically rules out Lambda functions, mainly due to cold starts and processing times. However, serverless is not just lambda: AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers.

Meet a Web Service resource

Web Service resource is an ECS service that constantly runs inside a Fargate cluster and listens for incoming HTTP traffic. Because of the nature of web service running constantly, it doesn't have execution warmup time as Lambda function and has configuration flexibility of Fargate Serverless Container resource, which makes it perfect for migrating your existing web services to AWS.

Web Service example
Web Service usage example

Creating a new web service

  • Add a web service resource
    Visual instruction
  • Select desired amount of CPUs and Memory and number of running instances
    Visual instruction
  • Provide Docker image, set exposed port and route for health checking
    Visual instruction
  • Provide VPC id, security group ids, and subnets ids
    Visual instruction
  • This is it. All you need is only to deploy your project

How Web Service works under the hood

When a user creates a web service resource, altostra uses Amazon Elastic Container Service and configures several resources to make everything work seamlessly.

First of all, Altostra creates Task definitions for every web service inside your project. Task Definition is a blueprint that describes how a docker container should launch. It contains settings like exposed port, docker image, CPU shares, memory requirement, a command to run, and environmental variables.

After that, we configured the needed permissions and roles for accessing connected resources such as SNS Topics, S3 buckets, etc.

The second step is to configure networking and service discovery. By default, your web services can't be reached through the internet, and all communications are inside AWS. The service discovery mechanism used during creation allows web services to communicate with each other and with lambda functions. We will add the env variable with the web service internal endpoint to make it easier for you.

The final step is to put every web service inside your project inside a Fargate Cluster. A cluster is a logical group of services that provides necessary computing resources.

How Web Service compares to Lambda Function

Lambda is an AWS service that runs code without the need to provision and manages infrastructure with a pay-per-use model and at no upfront cost. In addition, it enables you to run code in response to events and automatically conditions for and contains the compute resources required.

It’s a great starting point when you are building a project from the ground up or trying to react to events inside your applications. But it has drawbacks and limitations that make you look for other approaches to solving your needs. Lambda’s most significant flaws are considered to be limited configuration, cold starts, and a hard limit of 15 minutes execution timeouts.

Lambda function example
Lambda function usage example

How Web Service compares to Fargate Serverless Container

Fargate Serverless Container is a serverless compute engine that allows you to run containers without managing the infrastructure. It's an excellent solution for long-running heavy load processes with custom configuration due to the flexibility of running docker images and lacking lambda's limitations of 15 minutes execution timeout. Fargate Serverless Container can be configured to run manually or with a CRON scheduler.

A great example of use will be Database migration or storage maintenance. But it also has drawbacks, such as long invocation time (it can take up to several minutes to start work), which is why it is not very useful in reacting to events.

Fargate Serverless Container example
Fargate Serverless Container usage example

Fargate-based web service can solve your needs when lambda is not the right solution, without having to manage any servers.

Next steps

Want to give it a try? We provide a free-forever plan for developers. Create your free account today at

Want to stay up to date with the latest Altostra news? Join our community on Slack.

We want to hear from you! Share your Altostra experience with us on Twitter @AltostraHQ and LinkedIn and any suggestions that can make your work with Altostra even better.

Happy coding!

By submitting this form, you are accepting our Terms of Service and our Privacy Policy

Thanks for subscribing!

Ready to Get Started?

Get Started for Free