Reducing Clojure Load Time on Heroku (R10 error)

My Clojure The Compojure app exceeds the load time to bind to a port on Heroku 50% of the time. It then heroku restart

requires one or two calls heroku restart

. Maybe I need too many dependencies, but I don't know if I can do it dynamically.

Is there a way to communicate faster in Clojure by loading dependencies later? Common solution in Ruby land heroku-forward , but that doesn't work for Clojure.

This issue is related to Heroku Boot Timeout (R10 error) .

CircleCI handles my deployment and uberjar is built in.

+3


source to share


2 answers


TL; DR: There is no easy way to reduce your Clojure load times on Heroku. Deploy uberjar instead.

I had the same problem with Clojure + Heroku. I think the issue is mostly not about dependency load time, because Heroku caches them, so the solution heroku-forward

doesn't seem to work. Clojure applications require first loading the complete Clojure runtime and then compiling the application code. This amount of boot and compile time results in a timeout error. There are two ways to solve this problem:



  • Compile on another machine with lein uberjar

    and expand the jar instead.
  • Do not use Leiningen. Write a little Java to first require the port (ghost view), then manually bootstrap Clojure with Java, close the port by running the main application function to take over the port again. However, this method is a little weird, and since you are announcing your port so early, Heroku will bring your app (ghost) to the world eagerly, so the downtime is quite high.
+3


source


I am also building ubjerjar

, and downtime during updates due to startup times was a problem for me (even if I weren't on Heroku).

I noticed that if I have aot

my code ahead of time it takes longer to get the uberjar, but then it loads faster. In my case, that was enough. With lein add :aot :all

. There is a built-in task (aot)

in boot .



You can also try to manipulate JVM options (it looks like heroica supports them according to this link ). The following options are possible:

-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none

      

+1


source







All Articles