Try running an app made with Quarkus on Heroku

Introduction

You use Heroku to run web applications for free and easily, right? However, if you use it for free, if you leave the application for more than 30 minutes (no request), the server will go to sleep.

If you access the application after sleep, it will take some time for the response to come back. So, in order to shorten the startup time, I tried using GraalVM, which has been attracting attention recently, and Quarkus, which can run Java web applications on GraalVM.

This time I would like to compare how to run Quarkus on Heroku and the startup time with Spring Boot.

Prerequisites

--Has a Heroku account

Preparing the Quarkus application

Creating an application

Please refer to the following article to create the application.

I tried the Java framework "Quarkus"

Docker file creation

This time we'll use Heroku's container registry for the Docker registry.

Create the following file.

src/main/docker/Dockerfile.web


FROM registry.fedoraproject.org/fedora-minimal
WORKDIR /work/
COPY *-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=${PORT}"]

-Dquarkus.http.port=${PORT}Is required to boot on the port specified on Heroku. It cannot be started without this.


 By the way, you can change the launch port of the Quarkus app by changing the $ {PORT} part.

## Log in to the Heroku container

```console
heroku container:login

Create an application on Heroku

heroku create <Application name>

After that, please go with the project root.

Push to Docker registry

heroku container:push -R -a <Application name>

Start Docker

heroku container:release web -a <Application name>

Operation check

curl https://<Application name>.herokuapp.com/hello

Confirm that hello is output.

Preparing the Spring Boot application

Creating an application

RestController


@SpringBootApplication
@RestController
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@RequestMapping("hello")
	public String home() {
		return "hello";
	}
}

Creating a Docker file

Dockerfile


FROM openjdk:8-jdk-alpine
VOLUME /tmp
COPY target/app.jar app.jar
CMD ["java","-jar","app.jar","--server.port=${PORT}"]

** The following steps are the same as Quarkus, so they are omitted. ** **

Measure the wakeup time after sleep

Wait for the heroku server to look like this: スクリーンショット_2019-04-10_12_35_14.png

Execute the following command to measure.

Quarkus application measurement

curl https://<Quarkus application name>.herokuapp.com/hello -o /dev/null -w  "%{time_starttransfer}\n" -s
7.038011

Spring Boot application measurement

curl https://<Spring Boot application name>.herokuapp.com/hello -o /dev/null -w  "%{time_starttransfer}\n" -s
15.208555

** Quarkus now boots in half the time of Spring Boot **

Recommended Posts

Try running an app made with Quarkus on Heroku
Run an application made with Go on Heroku
Try running SlackBot made with Ruby x Sinatra on AWS Lambda
I made an app to scribble with PencilKit on a PDF file
Try running MPLS-VPN with FR Routing on Docker
Publish the app made with ruby on rails
Try running OSPF with FR Routing on Docker
I want to push an app made with Rails 6 to GitHub
Can I try all combinations with an app that has 20 checkboxes?
Create an app with Spring Boot 2
Try running cloudera manager with docker
Try Quarkus on IBM Cloud Shell
Create an app with Spring Boot
Try running Spring Boot on Kubernetes
DB error on deploying with Heroku
Run an application made with Java8 with Java6
Deploy your Rails app on Heroku
Creating an app and deploying it for the first time on heroku
Try running Word2vec model on AWS Lambda
Try running MySql and Blazor with docker-compose
Try deploying a Rails app on EC2-Part 1-
How to publish an application on Heroku
Try running Slack's (Classic) Bot with docker
I made an eco server with scala
Try Health Check on Azure App Service.
Shiritori map app made with Swift UI
I made a rock-paper-scissors app with kotlin
Deploy a Java web app on Heroku
I made a calculator app on Android
Build an environment with Docker on AWS
Try with resources statement in web app
I made a rock-paper-scissors app with android
Try creating an iOS library with CocoaPods
Hello World, a cross-platform GUI app with Groovy running on the Java platform
Try running ScalarDB on WSL Ubuntu (Environment Construction)
Downgrade an existing app created with rails 5.2.4 to 5.1.6
I made an app for myself! (Reading management app)
I made an Android app for MiRm service
Ssh login to the app server on heroku
I made a LINE bot with Rails + heroku
I made a portfolio with Ruby On Rails
I tried Getting Started with Gradle on Heroku