Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Tomcat App Container for Migrated Apps with Compatible Performance #1

Open
marcellodesales opened this issue Sep 23, 2019 · 1 comment
Assignees
Labels
hacktoberfest For hacktoberfest event

Comments

@marcellodesales
Copy link
Member

Description

  • Performance problems may occur in some SpringBoot apps when running from JARS
  • Tomcat App Containers can solve the problem
    • For some reason, the embedded version of Tomcat might not be that compatible

Steps to Reproduce

  • Run an application created using an executable JAR
  • Verify that the performance is relatively degraded when compared to the same app running in an App Container such as Apache Tomcat

Solution

  1. Package the app using WAR package insteas of the JAR
  2. Create a parent image using Tomcat App Container
  3. Re-run the same performance tests and compare

Expected behavior: [What you expect to happen]

The app should run at the same or better performance as the converted app

@marcellodesales marcellodesales added the hacktoberfest For hacktoberfest event label Sep 23, 2019
@marcellodesales marcellodesales self-assigned this Sep 23, 2019
@marcellodesales
Copy link
Member Author

A good start is as follows:

  • Make the build produce a WAR
  • Extend a Runtime image with Tomcat binary
  • Make sure the Runtime image uses the WAR

Make a build produce WAR

  • pom.xml or build.gradle must produce a WAR via a profile, etc
    • Notice the activation is by default to true <activeByDefault>true</activeByDefault>
        <profile>
            <id>war</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <packaging.type>war</packaging.type>
                <log.dir>${catalina.base}/logs</log.dir>    <!-- currently no effect on log4j2.xml -->
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
  • Declares a property
<maven-war-plugin.version>3.2.2</maven-war-plugin.version>
  • Declares the plugin maven-war-plugin
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${maven-assembly-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven-jar-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven-war-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
  • Possibly declare the following
ARG BUILDER_MAVEN_BUILD_CMD="mvn -s settings.xml package -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true"
ARG BUILDER_DIR="target"

### Runner Arguments
ARG RUNNER_EXTENSION="war"

Extend an existing Runtime image

FROM intuit/unmazedboot-runner:rhel6-oracle-jdk-8u181-0.5.0
# Switch to root for installation and some other operationsx
USER root

ENV TOMCAT_VERSION=8.0.24H

RUN curl -v -o apache-tomcat.tar.gz http://....apache-tomcat-${TOMCAT_VERSION}.tar.gz && \
    tar -zxvf apache-tomcat.tar.gz && \
    rm -f apache-tomcat.tar.gz && \
    mv apache-tomcat-${TOMCAT_VERSION} /usr/local/apache-tomcat && \
    rm -rf /usr/local/apache-tomcat/webapps/*

RUN mv /runtime/server.jar /usr/local/apache-tomcat/webapps/ROOT.war

COPY runner/server.xml /usr/local/apache-tomcat/conf
COPY runner/setenv.sh /usr/local/apache-tomcat/bin

#  create directories for persistent volume, also if just plain /tmp
RUN echo "mkdir -pv /tmp/git_basedir /tmp/tmpdir /app/git_basedir /app/tmpdir" > /runtime/init/mkdirs.sh

# How to set ulimit: https://access.redhat.com/solutions/61334
RUN echo "*     hard    nofile          100000" > /etc/security/limits.d/99-app-limits.conf
RUN echo "*     soft    nofile          100000" >> /etc/security/limits.d/99-app-limits.conf

# Add the build info to the Jar using zip to avoid breaking the layers
# TODO >>>>>>>> https://stackoverflow.com/questions/4799553/how-to-update-one-file-in-a-zip-archive

# Simulate unmazwedboot environment variables
ENV JAVA_HOME=/usr/java/jdk1.8.0_181-amd64
ENV PATH="$PATH:$JAVA_HOME/bin"
ENV UNMAZEDBOOT_RUNNER_CMD_EXEC="cd /usr/local/apache-tomcat; ./bin/catalina.sh run"
ENV CATALINA_TMPDIR="/app/tmpdir"

RUN mkdir -p /usr/local/apache-tomcat/conf/_health

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest For hacktoberfest event
Projects
None yet
Development

No branches or pull requests

1 participant