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

Update to alpine and dockerize #107

Merged
merged 11 commits into from
Oct 15, 2018
Merged

Conversation

Xaseron
Copy link
Contributor

@Xaseron Xaseron commented Oct 11, 2018

Benefits:

  • Smaller images 200MiB vs 700MiB
  • Faster build times (mvn clean install -PbuildDocker -DskipTests ) 90s vs 120s
  • dockerize will fail if the timeout is exceeded

The problem with the wait-for-it.sh script is that it will not fail if the timeout is exceeded and contiune with the execution even if the requested service is not available.

Exposing ports in the docker-compose file is only necessary if the port is accessed outside the docker network and that is only the case for the gateway service.

Copy link
Member

@arey arey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Xaseron for your contribution.
I'm aware to update to alpine and use dockerize (I didn't know this project) instead of the wait-for-it.sh script.

For ports removal, it could be helpful for debugging to reach the REST API. And we have to access to server UI (ie. Zipkin, SPring Boot Admin, Server Config, Eureka)

I also have a question : why do you inscrease memory limit from 256M to 1024 ?

@@ -3,14 +3,14 @@ services:
config-server:
image: mszarlinski/spring-petclinic-config-server
container_name: config-server
mem_limit: 256M
mem_limit: 1024M
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to increase the memory limit from 256M to 1024M ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The services gets killed during startup with this little amount of ram. On master branch too.
ctop

I will undo the exposed port removal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for the port. According to your screenshot, 512M should be ok. Does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it works and i have changed the pull request accordingly.

@arey
Copy link
Member

arey commented Oct 12, 2018

@mszarlinski could you also review this PR please?

@mszarlinski
Copy link
Collaborator

dockerize looks nice, but I don't get increased memory limit too

@Xaseron
Copy link
Contributor Author

Xaseron commented Oct 12, 2018

The config container simply crashes during startup with 256M memory limit

@arey
Copy link
Member

arey commented Oct 12, 2018

@Xaseron and @mszarlinski, what is your OS?
I'm working on MacOS.

@Xaseron
Copy link
Contributor Author

Xaseron commented Oct 12, 2018

% uname -a

Linux arch 4.18.12-arch1-1-ARCH #1 SMP PREEMPT Thu Oct 4 01:01:27 UTC 2018 x86_64 GNU/Linux

% docker version

Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.11
 Git commit:        e68fc7a215
 Built:             Fri Sep  7 11:26:59 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.11
  Git commit:       e68fc7a215
  Built:            Fri Sep  7 11:26:11 2018
  OS/Arch:          linux/amd64
  Experimental:     false

@mszarlinski
Copy link
Collaborator

System Version: macOS 10.13.6 (17G65)
Kernel Version: Darwin 17.7.0

@Xaseron
Copy link
Contributor Author

Xaseron commented Oct 12, 2018

Could you post a docker stats of the running microservices

@arey
Copy link
Member

arey commented Oct 12, 2018

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G65

I've reached the memory limit:

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
77a06a5a5e89        api-gateway         0.31%               255.7MiB / 256MiB   99.89%              5.86kB / 4.65kB     88.4MB / 62MB       43
a72d71c7b5c3        tracing-server      0.12%               255.8MiB / 256MiB   99.94%              6.05kB / 4.82kB     60.5MB / 30.4MB     30
a40dbe6e8f8d        admin-server        0.30%               255.5MiB / 256MiB   99.81%              6.09kB / 4.81kB     46.7MB / 14.5MB     36
7618aca928ea        discovery-server    0.20%               255.8MiB / 256MiB   99.92%              22.3kB / 12.2kB     89.3MB / 38.8MB     42
aaab21f29faa        config-server       0.19%               236.5MiB / 256MiB   92.39%              53.1kB / 34.3kB     86.2MB / 38MB       36

And 3 containers have crashed

@mszarlinski
Copy link
Collaborator

mszarlinski commented Oct 13, 2018

Here is docker stats output for different OS images and memory limits:

  • openjdk:8 / mem_limit: 256M (as-is)
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
de5e5e96108d        api-gateway         0.31%               255.2MiB / 256MiB   99.69%              36.3kB / 370kB      74.2MB / 78.6MB     45
24b32e76ef0c        visits-service      1.12%               148MiB / 256MiB     57.81%              65.7kB / 64.5kB     477MB / 277MB       46
9584d2076b76        customers-service   0.28%               206.1MiB / 256MiB   80.52%              66.3kB / 65.3kB     472MB / 303MB       46
bf9ab7c15741        vets-service        0.81%               172.4MiB / 256MiB   67.33%              67.2kB / 65.1kB     493MB / 266MB       46
23f8848a9195        tracing-server      1.01%               200.6MiB / 256MiB   78.36%              66.6kB / 67.5kB     38.4MB / 13MB       65
933f98f02051        admin-server        5.33%               221.4MiB / 256MiB   86.48%              136kB / 154kB       157MB / 57MB        50
ea26fdc66470        discovery-server    0.32%               202.8MiB / 256MiB   79.24%              203kB / 144kB       85.6MB / 85.2MB     42
4c92de729b7a        config-server       0.31%               161.3MiB / 256MiB   63.00%              149kB / 106kB       328MB / 28.3MB      36
  • openjdk:8-jre-alpine / mem_limit: 512M (changed with this PR)
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
03c85a6963a0        api-gateway         1.06%               260.9MiB / 512MiB   50.95%              91.4kB / 401kB      69.7MB / 0B         66
57de68fbbfd8        visits-service      0.44%               289.6MiB / 512MiB   56.55%              14.8kB / 13.1kB     112MB / 0B          56
9e8d49f76ecb        customers-service   0.64%               302.2MiB / 512MiB   59.02%              16kB / 16kB         114MB / 0B          55
b55c5b57659d        vets-service        0.41%               295.9MiB / 512MiB   57.79%              15.5kB / 13.2kB     111MB / 0B          57
3698dd89a836        tracing-server      0.29%               131.8MiB / 512MiB   25.74%              16.8kB / 15.3kB     22.3MB / 0B         52
65f3bcab1080        admin-server        0.59%               197MiB / 512MiB     38.47%              48.6kB / 1.51MB     94.4MB / 73.7kB     63
4def7a01d61a        discovery-server    0.55%               161.3MiB / 512MiB   31.51%              55.7kB / 377kB      196MB / 0B          54
9619c8f2e1a0        config-server       0.30%               140.9MiB / 512MiB   27.53%
  • openjdk:8-jre-alpine / mem_limit: 256M (limit decreased to current value)
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
b480eacc6569        api-gateway         1.34%               250.9MiB / 256MiB   98.02%              41.7kB / 375kB      113MB / 51MB        67
f0adb1b1c277        visits-service      7.17%               246.3MiB / 256MiB   96.22%              10.8kB / 10.4kB     341MB / 184MB       56
06b08d515c9a        customers-service   0.39%               252.6MiB / 256MiB   98.66%              11.9kB / 13.3kB     263MB / 137MB       56
23bba8c9edf3        vets-service        6.39%               240.3MiB / 256MiB   93.87%              11kB / 10.2kB       358MB / 188MB       57
8c50ea6b1454        tracing-server      0.39%               211.2MiB / 256MiB   82.52%              13.8kB / 13.1kB     32.7MB / 16.5MB     49
1f0c07ebfd96        admin-server        0.49%               227.6MiB / 256MiB   88.89%              37.3kB / 63.7kB     44.2MB / 73.7kB     62
b4e21f6c9c4d        discovery-server    9.20%               185MiB / 256MiB     72.26%              38.8kB / 30.9kB     68.6MB / 0B         53
cca8db042c81        config-server       0.38%               155.6MiB / 256MiB   60.79%              66.1kB / 43.9kB     133MB / 156kB       36

@arey
Copy link
Member

arey commented Oct 14, 2018

Memory limits looks like to depend of OS and configuration. I suggest to increase the memory limit to 512m. It's a good compromise.
@Xaseron you have to resolved a conflict because we have migrated to OpenZipkin.

@Xaseron
Copy link
Contributor Author

Xaseron commented Oct 15, 2018

Ok, i've rebased onto master.
In the compose-file i removed the links, because all container are by default in the same network. Links are only needed for settings aliases like:

    links:
      - "config-server:conf"

Addionally i set the environment variables for the zipkin server.

@arey
Copy link
Member

arey commented Oct 15, 2018

Ok thank you @Xaseron. Are you OK for the merge @mszarlinski ?

@mszarlinski mszarlinski merged commit 318c08a into spring-petclinic:master Oct 15, 2018
talha-01 pushed a commit to talha-01/microservices-ci-cd-pipeline-with-petclinic-app that referenced this pull request Nov 13, 2020
* Add alpine jre and dockerize script

* Add docker build argument DOCKERIZE_VERSION

* Increase memory limit

* Use dockerize instead of wait-for-it script

* Update documentation dockerize script

* Remove unnecessary ports

* Revert "Remove unnecessary ports"

This reverts commit a605aaf

* Set memory limit to 512M

* Merge openzipkin

* Remove obsolete links

* Fix honoring memory limits for openzipkin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants