Closed lephyrius closed 8 years ago
Ok! I found the solution. The reason it was slow was because of entropy exhaustion: https://github.com/jruby/jruby/wiki/Improving-startup-time#ensure-your-system-has-adequate-entropy https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged
So I would just add: RUN apt-get install haveged Modify: /etc/default/haveged with DAEMON_ARGS -w 1024 update-rc.d haveged defaults
OR maybe install it from source.
To every single dockerfile. IF u don't think that's a good idea then just add that to the documentation. Here I was thinking that jRuby was super slow but it isn't. It's extremely high performant. Hopefully it will help more people than me.
Interesting! Thanks for the investigation!
Good research @lephyrius. However, for me, the answer over here was easier and better:
The idea is to simply mount /dev/urandom
(the nonblocking random source) from the host as /dev/random
in the container. Nice thing about this is, if you are running on OS X (as I am), it affects only the dev environment. I'm not modifying my Docker images, so I'm not changing the behavior in my production environment.
This brought initialization times for one of my jruby containers from around 3 minutes to around 30s.
Sounds like all that would be needed would be to seed /dev/random with something like haveged
Closing as this is not really a problem with the image itself and not something that's solvable at this layer in the stack.
From my experiences, running bundler
with JRUBY_OPTS="--dev"
reduced the total time to half of the original time...
I have tried running my application. The only thing that are slow is rubygems and bundler. Locally it's fast. But on the server it's slow. I have tried:
Is slow!
Is slow!
Is slow!
Is slow!
Is slow!
Is fast!
Is fast!
Is fast!
Is fast!
Is fast!
Is fast! I have also tried: FROM jruby:9.0-jre and FROM jruby:9.0-jdk
I see no difference....
Could this be a ruby problem?
I use docker version:
Here is my JRUBY opts: JRUBY_OPTS = --server -J-Xmn512m -J-Xms1024m -J-Xmx2g -J-XX:+UseCompressedOops -J-XX:+UseCodeCacheFlushing -J-XX:+CMSClassUnloadingEnabled -J-XX:+UseConcMarkSweepGC -J-XX:ReservedCodeCacheSize=128m
Is there some way to speed up the bundler/gem command? It's almost as if they have some handshake issue? Maybe SSL? The things is that the CPU is idle when gem/bundle starts. Is this a jRuby issue? Is there something I could do?