mjg123 / mjg123.github.io

MIT License
1 stars 2 forks source link

Would you care for a Dockerfile jlink java9 example? #2

Open StevenACoffman opened 6 years ago

StevenACoffman commented 6 years ago

Hello! I really enjoyed and benefitted from your recent blog posts (clojure + jlink? You rock!), so I wondered if you would be interested in a multistage Dockerfile I wrote that takes a real (simple) java9 web server and uses jlink and CDS on it?

Repository available here: java9-jlink-web

I was working on doing your earlier aot + CDS example on the same code, but ran out of time.

Regardless, Thanks again for your great articles!

mjg123 commented 6 years ago

Hi!

That's cool - you've actually used a lot of the options that the Java team recommended to me (and I didn't write about) such as -vm server and strip-debug. compress 2 might have an effect either way as the image will be smaller but it will take some time to uncompress the bytecode before it can be run.

Did you measure docker startup times with this image vs a non-jlink'd one? I'm not a docker expert but AIUI a smaller image should start faster, even if it's already cached locally, because of some work docker has to do at startup to prepare the filesystem. That would be interesting to see.

Thanks again, I'll write a post-script to my blog & link to your repo if you don't mind?

Matthew

StevenACoffman commented 6 years ago

That's a great idea! My purpose was a bit different, which was to explore cpu, disk, and memory usage for long-running services, but for what you are describing, a finite run-to-completion task would be easier to measure, as in your hello world. So I made a new repository and put that up in java9-bench. I'll add you as a collaborator if you don't mind.

For benchmarking what you describe, I should probably push a set of docker images with the various flags toggled in all the different permutations and see what their effect is. I haven't done that yet, or run the benchmark(s).