Running Spring Boot application on Elastic Beanstalk

January 24, 2018

In 2012 I was working for a startup building browser and mobile games. Actually the mobile era was just getting started there and after few simple client-side-only games we started working on a multiplayer game - potentially a big hit.

While our older titles - pretty stabilized in the market with predictable load and number daily active users - were running on-premises - in the case of new game we knew exactly nothing how big success it’s going to be. We decided we go with AWS - at that time next to Google App Engine the only reasonable cloud provider.

We did not know much about AWS, except that it scales well and if we don’t mess it up completely we should be able to handle large number of users without issues. As it’s in the game industry, the deatline was “yesterday” so our goal was to find the quickest way to ship. That’s how we chose Elastic Beanstalk - a service from AWS released one year earlier that configures everything we wanted for us. Back in a days it was the easiest way into the AWS world and actually even nowadays its the only service that lets you deploy and run Java based applications with just a few clicks or command line commands.

If you are like me in 2012, knowing Spring but just getting started with AWS and you want to release your Spring application to the world let me guide you through the series of steps.

Creating Spring Boot application

To avoid any confusion with configuration, lets start with simple Spring Boot application with single endpoint returning some JSON content.

In IDE of your choice, or through select Web starter, Lombok and Maven as a build tool.

Let’s add dummy endpoint implementation:

class HelloController {
    Message hello() {
        return new Message("hello world");

class Message {
    String content;

Install AWS CLI

Just in case you have not done it yet, install AWS Command line Interface. Sooner you learn to use it the better. Clicking through AWS Console can be a tedious job in some scenarios.

Just to check if it’ installed properly you can execute:

$ aws --version
aws-cli/1.8.9 Python/2.7.10 Darwin/16.7.0

Elastic Beanstalk 101

Creating Elastic Beanstalk environment

Deploying Spring Boot application with AWS CLI

Deploying Spring Boot application with Maven plugin

Changing Xms and Xmx settings

Health Check

Setting up MySQL with RDS