开发者

Why does a JRuby application on App Engine take so long to start (versus a Python app)?

开发者 https://www.devze.com 2022-12-25 17:23 出处:网络
I\'m considering using JRuby on App Engine but have heard that Juby app on App Engine have a long startup lag versus a Python app. Why is this?

I'm considering using JRuby on App Engine but have heard that Juby app on App Engine have a long startup lag versus a Python app. Why is this?

Is it because the JRuby jar开发者_运维百科 files are so large that a cold startup requires them to be loaded into memory before the app can start serving? That would be my guess but I'm not sure if that's a precise technical explanation. And, if so, why is Python different?


That's basically it. When your app hasn't been used in a while, App Engine swaps it out until another request comes in.

When that happens, it loads all the JARs your app requires, which may take a very long time, upwards of 10-15+ seconds in some cases.

I don't have any experience with JRuby in particular, but this page has some tips on how to reduce your app's cold start time. The tips should be useful even if you're not strictly writing vanilla Java.

Basically, just don't include any JARs that your app doesn't rely heavily upon.


Disclaimer: I haven't benchmarked this myself

The difference between the Python version and JRuby in particular probably have lots to do with the fact that JRuby is a language implemented on top of another language. The Python engine on the other hand is native, and much closer to CPython (some in-house variant of Unladen swallow, I would guess). This means that for Python, the interpreter is by definition already loaded, but for JRuby, your application must start with loading the Ruby interpreter before it can start with it's application's logic.

0

精彩评论

暂无评论...
验证码 换一张
取 消