My Clojure Compojure application exceeds the boot time limit for binding to a port on Heroku 50% of the time. Then it takes one or two calls to heroku restart to get it going. It is possible I am requiring too many dependencies, but I don't know if I can do this dynamically.
Is there a way to bind faster in Clojure by loading dependencies later? The generally accepted solution in Ruby land is heroku-forward, but this does not work for Clojure.
This issue is related to Heroku Boot Timeout (Error R10).
CircleCI handles my deployment and the uberjar is built up-front.
TL;DR: There's no easy way to decrease Clojure boot time on Heroku. Deploy uberjar instead.
I had the same problem with Clojure + Heroku. I think the problem is mostly not about time to download dependencies because Heroku has them cached so a solution like heroku-forward won't work.
Clojure apps require a full Clojure runtime to be loaded first, then the runtime will compile your app's code. That amount of bootstrapping and compiling time results a timeout error.
There are two ways to work around this problem:
lein uberjar and deploy the jar instead.I produce an ubjerjar as well, and downtime during upgrades due to the startup time was an issue for me (even if I was not on Heroku).
I noticed that if I aot my code beforehand, it takes longer to produce the uberjar, but it boots faster afterwards. That was enough in my case.
With lein, add :aot :all. There is a built-in (aot) task in boot.
You could also try to control the JVM options (heroku seems to support them according to this link). Some options to try would be :
-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With