5

I need to run HTTP REST API (Spring Boot application with embedded Undertow server) in Docker container, but when I'm running container and loading it with benchmark I'm getting too long response time (<1000ms), but when I run my application just from IDE I'm getting responses in (<10ms), why do I have so big difference? My dockerfile:

FROM openjdk:8-jdk-alpine
ADD run.sh run.sh
RUN chmod +x run.sh
ADD tmp/data/data.zip tmp/data/data.zip
ADD travels-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 80
CMD ["sh", "run.sh"]

and run.sh from where I'm running my application:

#!/bin/sh
echo "Unzipping data..."
mkdir -p /opt/
unzip -o /tmp/data/data.zip -d /opt/
echo "Starting server..."
java -Xmx3G -Xms3G -XX:+AggressiveOpts -server -Djava.security.egd=file:/dev/./urandom -jar app.jar --data.path=/opt/

Thank you in advance for help!

Anar Sultanov
  • 3,016
  • 2
  • 17
  • 27
  • 1
    run the command `docker container stats ` to see the resourse usage by the container? Otherwise If it is a network issue run the container using `--network=host` option – yamenk Aug 17 '17 at 12:23
  • @yamenK when launching a container with `--network=host`, I can not connect to it: `The requested URL can't be reached` – Anar Sultanov Aug 17 '17 at 12:36
  • Stats under benchmark: `CPU: 107.10%, MEM:1.17GiB / 3.837GiB (30.50%), NET I/O:3.7MB / 4.7MB, BLOCK I/O:528kB / 0B` – Anar Sultanov Aug 17 '17 at 12:41
  • What happens with the data.zip? If that data is huge or your app heavily relies on disc reads/writes, you should consider using Volumes. Volumes don't use the COW file systems, which are inherently slower. – gesellix Aug 17 '17 at 12:46
  • @gesellix it Is the data the application is working with (~20mb). All data is placed in HashMap when the application loads. I do not read/write anything. – Anar Sultanov Aug 17 '17 at 12:50
  • Hey, did you find any answers about that ? I have the same problem in IntelliJ my api have 30-60ms in response time and in docker more than 1000ms – Spialdor May 21 '21 at 14:35
  • @Jessy unfortunately no – Anar Sultanov May 26 '21 at 08:32

0 Answers0