Minimum resource to run a Spring Boot app

Viewed 285

I'm just starting to test out deploying my spring boot webapp onto AWS. I've currently got a t2.micro (1vcpu/1gb) running Ubuntu server and I've packaged my app into a fat jar using mvn clean install.

The tomcat server initially deploys fine and I can access my APIs remotely, however, after a few hours (haven't managed to time it accurately), the server seems to stop on its own. I login to the instance and the java process seems to have stopped on its own.

The command I use to run the jar is the typical java -jar xxxxx.jar.

The app has 2 entities, 2 controllers, 3 services. Nothing complex.

Currently still using h2 as the db as I'm just testing some stuff out, but the db initializes empty with no data.

From what I've read on other threads, this sounds like a OOM issue. Contributing factor being the h2 db which is an in-mem db.

However, it's a really small app and as mentioned the db starts out empty. So doubting if it's consuming that much RAM beyond a few 100mbs. The idle server consumes ~23% of RAM, with ~500mb in cache and ~300mb free.

Also I'm not able to find logs on the server which say it's killed the java process due to OOM. (I searched in var/logs/dmesg)

I haven't tried deploying it on something bigger yet, but wanted to get some insights before going in the wrong direction.

Will post my java code if it adds context. Thanks in advance.

1 Answers

To make sure you Spring BOOT app works, you can build the FAT JAR and then try using Elastic Beanstlak - which puts the app onto an EC2 instance. See this AWS tutorial for information. It uses various AWS Services, including DynamoDB. But you can skip the code part and read the deployment section:

Creating the DynamoDB web application item tracker

See the environment variables that also need to be set.

Related