From zero to hero — Deploy a scalable Java app on AWS App Runner ..

Mani
4 min readMar 21, 2022

--

Imagine you are a developer in a startup or for that matter in an enterprise or a student, and you have an web application written in either Node.JS or Python or my favorite language [;-)] Java. You just want to deploy it on the cloud and don't have to worry about server configurations, learning Docker or Kubernetes, setting up a load balancer, setup auto scaling and all the other stuff, which is needed to get a scalable, fault tolerant app, before being exposed to the masses !! At the same time, your inner voice tells you to follow a standards based approach and do not want to make any changes to your source code to make it run on a specific platform.

Well, with AWS App Runner you can meet all these requirements in just a matter of minutes !!

So, lets get rolling ..

Step 1: Build and test my Java app locally

I have a simple “Hello World” Java app based on Spring boot framework, and I use Maven for my builds and testing. You can check out the source code at my github repo

#build the spring app 
$ mvn clean install
#run the app
$ java -jar target/demo-0.0.1-SNAPSHOT.jar

In a different window, access the “Hello world” app

$ curl http://localhost:8080
Hello World from AWS App Runner. The JDK version is 1.8.0_322

Step 2: Deploy the app on AWS App Runner

AWS App Runner now supports Java language platform for building and running Java based web application on two Amazon Corretto runtimes — Corretto 11 and Corretto 8, and supports Maven and Gradle build tools. The App Runner architecture diagram at https://docs.aws.amazon.com/apprunner/latest/dg/architecture.html gives a complete picture of how App Runner works.

One more new feature, which I absolutely love is that an AWS App Runner service can now communicate with other applications hosted in a private VPC from Amazon VPC). You can find the release notes for App Runner at https://docs.aws.amazon.com/apprunner/latest/relnotes/relnotes.html

AWS App Runner takes your source code from GitHub or source image from a Amazon ECR, and creates and maintains a running web service. In this blog, we will use the source code from my github repo.

A few screen shots from my deployed App runner service, I have linked my GitHub source code repo.

App Runner linked to the Java source code in GitHub
build and start commands, and have specified the vcpu and memory. The supported vcpu and memory configurations are at https://aws.amazon.com/apprunner/pricing/
I have given a deliberately low concurrency setting to showcase the autoscaling during my load test ;-)

So, that’s it, in a few minutes, we have deployed the Java Spring boot app on AWS runner and we get an endpoint which can be accessed !!

accessing the Java spring boot app

Step 3: Load test the deployed app ..

Obviously, I wanted to load the app and see, how the scaling happens . I installed an open source testing tool, siege

sudo yum -y install siege
siege --version

Run a test with some, 200 concurrent users hitting the service endpoint

$ siege -c 200 -i https://vnfdbpd9fp.us-east-1.awsapprunner.com/

From the App Runner console, you can see the point, where it scales to add an additional instance to handle the load. Once the load testing stops, the instances come down ..

scales from one to two active instances and then back to zero ..

About pricing, the App Runner pricing page has some good scenarios on how it is priced. Works great for both test /development as well as for production scenarios.

Also, the App Runner roadmap is available at https://github.com/aws/apprunner-roadmap/projects/1 , including issues related to support for your favorite programming languages .. Do a +1 or add a new feature request, if you find that feature missing from the roadmap.

That’s it, its a wrap and I feel that I was able to accomplish all the things that I had wanted to do. I love AWS services like AWS App Runner which abstract the complexities needed to run a scalable, secure application on the Cloud and lets you concentrate on stuff that you know best !!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Mani
Mani

Written by Mani

Principal Solutions Architect at AWS India, and I blog/post about interesting stuff that I am curious about and which is relevant to developers & customers.

No responses yet

Write a response