Quick revision
The short answer
Elastic Beanstalk is an older platform as a service: we upload a Spring Boot jar to its Java SE platform on Corretto and it creates the EC2 instances, load balancer and scaling for us, which is simple but inflexible. ECS on Fargate runs our container without servers to manage; we describe it in a task definition with CPU, memory, image and IAM task role, and run it as a service behind a load balancer. EKS runs Kubernetes, the most flexible and portable option, but we operate cluster upgrades, add-ons and much more configuration; in all three, the JVM must respect container or instance limits and health checks should use Spring Boot Actuator.
What to remember
In this answer, we compared three ways to run Spring Boot on AWS. Elastic Beanstalk builds EC2, load balancing and scaling around an uploaded jar but offers little flexibility, ECS on Fargate runs containers described by task definitions without servers, and EKS gives Kubernetes's power and portability at the cost of operating the cluster. In all of them, the JVM must be sized for its limit and health checks should use Actuator's liveness and readiness probes.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Elastic Beanstalk is an older platform as a service: we upload a Spring Boot jar to its Java SE platform on Corretto and it creates the EC2 instances, load balancer and scaling for us, which is simple but inflexible. ECS on Fargate runs our container without servers to manage; we describe it in a task definition with CPU, memory, image and IAM task role, and run it as a service behind a load balancer. EKS runs Kubernetes, the most flexible and portable option, but we operate cluster upgrades, add-ons and much more configuration; in all three, the JVM must respect container or instance limits and health checks should use Spring Boot Actuator.
Why this question is asked
Where to run a Spring Boot service on AWS is one of the first decisions a team makes, and the three main options differ mostly in how much we manage ourselves. Interviewers ask this to check that we can explain the trade-off clearly and pick sensibly for a given team, rather than reaching for Kubernetes by default. In this answer, we will recap what each service is, look at what we manage in each, see a task definition for ECS, cover the JVM and health check settings that apply to all of them, and finish with when to choose which.
1A Quick Recap of the Three Options
Elastic Beanstalk takes an application and builds the environment around it: EC2 instances with a Java runtime, an Application Load Balancer, an Auto Scaling group, logs and health monitoring. For Java it has a Java SE platform based on Amazon Corretto, where we upload an executable jar, and it also supports Docker. It was popular before containers became standard, and it is still a quick way to run a small service, though it gets fewer new features than ECS and EKS.
Amazon ECS is AWS's own container orchestrator. We describe a container in a task definition and run it as a service that keeps a number of copies running behind a load balancer. With the Fargate launch type, AWS runs each task on capacity it manages, so we never see a server.
Amazon EKS is managed Kubernetes. AWS runs the control plane; we choose how nodes run, managed node groups, Karpenter or Fargate, and we use Kubernetes objects such as Deployments, Services and Ingresses. It brings the whole Kubernetes ecosystem, and its operational load.
2What We Manage in Each
The useful way to compare them is the line between what AWS manages and what we manage.
| Concern | Beanstalk | ECS on Fargate | EKS |
|---|---|---|---|
| Servers and OS patching | AWS (platform updates) | AWS | us, unless Fargate or auto mode |
| Orchestrator | Beanstalk | ECS (AWS) | Kubernetes control plane (AWS) |
| Cluster upgrades and add-ons | none | none | us: versions, CNI, ingress, DNS |
| App packaging | jar or container | container image | container image |
| Config surface | small | medium | large |
| Portability | low | low (AWS only) | high (Kubernetes anywhere) |
3A Task Definition for a Spring Boot Service
On ECS, the task definition is the heart of the setup. It says which image to run, how much CPU and memory the task gets, which IAM role the application uses, which ports it exposes, where logs go, and how to check health.
Notice the two roles. The task role is the identity of our Java code, used by the AWS SDK; the execution role is used by ECS itself to pull the image and send logs. The container health check uses curl, so the image must contain it, or we rely on the load balancer's health check instead. Then an ECS service runs, say, three copies of this task across availability zones and registers them with a target group.
4Settings That Apply Everywhere: the JVM and Health Checks
Whichever option we choose, the JVM runs inside a limit. Modern JDKs detect container memory and CPU limits, but by default they use only 25 percent of memory for the heap, which wastes most of a 2 GB task. Setting -XX:MaxRAMPercentage to about 70 to 75 gives the heap a sensible share while leaving room for metaspace, thread stacks and native memory. Setting a fixed -Xmx close to the limit is the classic cause of the container being killed.
Health checks should use Spring Boot Actuator's probes: /actuator/health/liveness says the JVM is alive and should not be restarted, and /actuator/health/readiness says the service can take traffic. The load balancer checks readiness, the orchestrator restarts on liveness failures, and graceful shutdown lets in-flight requests finish when a task is stopped during deployments.
5When to Choose Each
Choose Elastic Beanstalk for a small or legacy application that just needs to run, with a team that does not want to learn containers yet, accepting that it is less flexible and less actively developed. Choose ECS on Fargate for most container workloads run by a small or medium team on AWS: it has few moving parts, integrates tightly with IAM, load balancers and CloudWatch, and needs no cluster operations. Choose EKS when the company already runs Kubernetes, needs its ecosystem, such as operators, service meshes, Helm-based tooling or a common platform across clouds and on-premises, and has a platform team to run it.
- Already on Kubernetes or need its ecosystem?YesEKS with a platform teamNoContinue
- Ready to run containers?YesECS on FargateNoContinue
- Small or legacy app, simple needs?YesElastic Beanstalk (Java SE)NoContainerize, then ECS on Fargate
3 steps in order. Play them, or step through them one at a time.
6Follow-up questions
What does a task definition contain?
It is a versioned JSON description of how to run one task: the launch type compatibility, network mode, the total CPU and memory, the task role for the application and the execution role for ECS itself, and one or more container definitions. Each container definition has the image, port mappings, environment variables and secrets from Secrets Manager or Parameter Store, a health check, log configuration and optional resource limits. Every change creates a new revision, and a service is updated to run a new revision during a deployment.
Can Fargate be used with EKS too?
Yes, EKS can run pods on Fargate through Fargate profiles, which removes node management for those pods. Some Kubernetes features, such as DaemonSets, do not work there, so many teams combine it with managed nodes or use EKS Auto Mode; check the current limitations.
Why not run the jar directly on EC2 instances?
We can, but then we build what the other options give us: deployments, scaling, health replacement, patching and log shipping. That hand-built setup is exactly what companies later spend effort migrating away from.
7Conclusion
In this answer, we compared three ways to run Spring Boot on AWS. Elastic Beanstalk builds EC2, load balancing and scaling around an uploaded jar but offers little flexibility, ECS on Fargate runs containers described by task definitions without servers, and EKS gives Kubernetes's power and portability at the cost of operating the cluster. In all of them, the JVM must be sized for its limit and health checks should use Actuator's liveness and readiness probes.
Open with
The difference is mostly how much I manage. Elastic Beanstalk is the oldest, a platform as a service: I upload the Spring Boot jar to its Java SE platform, which runs on Corretto, and it creates EC2 instances, a load balancer and auto scaling.
Then, if they want more
It is simple, but I have limited control and it is less actively developed, so I would use it for small or legacy apps. ECS on Fargate runs my container without any servers.
I write a task definition with the image, CPU and memory, the task role that my code uses for AWS calls, the execution role for pulling images and logs, port mappings, health check and log settings, and then an ECS service keeps a number of tasks running behind a load balancer.
For most container workloads with a small team on AWS, that is my default, because there is no cluster to operate. EKS is managed Kubernetes.
It is the most flexible and portable, with the whole ecosystem of Helm, operators and service meshes, but I have to handle cluster version upgrades, add-ons like networking and ingress, and much more configuration, so it makes sense when the company already uses Kubernetes or needs that ecosystem and has a platform team.
In all three, I make the JVM respect the limit, with MaxRAMPercentage around 75 instead of a fixed Xmx near the limit, and I point health checks at Actuator's liveness and readiness endpoints with graceful shutdown on.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- AWS documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Compare Amazon ECS with Fargate, Amazon EKS and AWS Elastic Beanstalk for running a...": https://scrivio-interview-library.netlify.app/spring-boot/aws/db093d6ba3/