TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Using GraalVM to Run Native Java in AWS Lambda with Golang

152 点作者 CSDude将近 7 年前

10 条评论

kodablah将近 7 年前
You might be able to even compile Go as a static library and embed it in your binary instead of carrying a .so file around. Regardless, Go&#x27;s FFI story (especially in that direction) is hobbled and you can&#x27;t do things like share structs easily (for obvious reasons, but still annoying). But yes, as soon as you get to C-level, you can mix and match anything and write about it. Running Go in Rust, or Rust in Go, or Go in JS, or whatever.<p>What would really be neat is to leverage Graal&#x27;s polyglot iface a bit higher. I am not sure the status of llgo these days, but compile Go to LLVM bitcode and then leverage that from Java and compile to a single binary. Or even expose Go&#x27;s awesome stdlib to JVM developers that way. But the practicality of doing some of these things becomes a bit lost beyond toy use.
评论 #17284534 未加载
评论 #17286336 未加载
benmmurphy将近 7 年前
the other alternative is to just implement the go-aws-lambda protocol. it is basically a bunch of go RPC calls that AWS makes to a port that you listen on. if you do it correctly it should be safe to run because AWS can&#x27;t change the protocol in a way that is not backwards compatible with existing go projects. any language that can compile statically and be run on linux can run on AWS lambda because static-go binaries can be deployed to AWS lambda.<p>but this is probably a little less riskier because i&#x27;m sure if AWS made a change to the go protocol they would test it against their existing go libraries they have published but they can&#x27;t test it against your &lt;insert language&gt; implementation.
评论 #17284791 未加载
评论 #17286736 未加载
lvh将近 7 年前
So, clearly you can&#x27;t use the real Java runtime because it expects to load an endpoint from a jar, but I wonder what the equivalent Python runtime version would look like. Prior to explicit Go support, people used the Python runtime as a shim to start a Go binary.<p>Is there anything about the way the Go runtime works that makes it fundamentally better than the Python runtime&#x27;s semantics? Is the entirety of it that you really don&#x27;t need to do a lot of work but Go is going to be marginally faster at doing that tiny bit of work (dlopen and ferry bytes across)? I think the underlying serialization format in Python is JSON. I have no idea how fast Gob is.<p>Any idea how much you lose on the FFI bridge? (My understanding is you need to copy the Go struct you get out before you can pass it to FFI. I&#x27;m very familiar with FFI in general and especially on the JVM, but only superficially with Go&#x27;s in particular.)
评论 #17285613 未加载
ianamartin将近 7 年前
Christ, I&#x27;m officially old now. Current PhD candidates think cars needed to warm up in the 80s.
评论 #17285593 未加载
评论 #17285057 未加载
评论 #17284909 未加载
CSDude将近 7 年前
FYI There is a blog post for interested, a reverse engine of AWS Lambda for Python, which does not use RPC&#x2F;network at all, instead uses shared memory to communicate, which could be more of a challenge.<p><a href="https:&#x2F;&#x2F;www.denialof.services&#x2F;lambda&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.denialof.services&#x2F;lambda&#x2F;</a>
ericfrederich将近 7 年前
Sweet... I feel like someone should do this for a Jython program as a joke.<p>Then you&#x27;d have Python code executed by an interpreter written in Java compiled by Graal to produce a native binary which will be registered on AWS as a Go executable and will communicate via Go&#x27;s net&#x2F;rpc.<p>... as opposed to switching the runtime to Python ;-)
gw将近 7 年前
Is there any advantage to this over using Lambda&#x27;s python runtime to run a binary? That seems to be what this project is doing to run a natively-compiled Clojure project: <a href="https:&#x2F;&#x2F;github.com&#x2F;uwcpdx&#x2F;clombda" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;uwcpdx&#x2F;clombda</a>
评论 #17285961 未加载
bitwize将近 7 年前
&gt; This title might seem like generated by a Markov Chain on Hacker News submissions, but it is real.<p>I smiled. But a more plausible Markov-chain headline might be &quot;Using GraalVM to Run Native Java with Rust, Machine Learning, and the Gut Microbiome&quot;.
heyyyouu将近 7 年前
Side note: great dek on this story.
Twirrim将近 7 年前
Okay, I can see what you&#x27;re doing. I&#x27;m a little confused why. This seems like a potential rube goldberg machine that may exhibit some strange and unpredictable behaviour.<p>Maybe I&#x27;m crazy, but I much prefer to keep things as simple as possible. Pick a technology stack and use just it. Don&#x27;t play mix and match games.<p>If java is just not working for you in lambda, due to the startup cost, is it time to consider that Java might not be the right technology at all for you to be using there?<p>If you&#x27;re determined to stick with lambda, maybe it&#x27;s time to bite-the-bullet and use Go (or something else with fast startup times).<p>If you&#x27;re determined to stick with Java, maybe it&#x27;s time to consider that maybe Lambda isn&#x27;t the right solution for you? How much benefit are you really seeing vs the engineering cost and complications?
评论 #17287126 未加载
评论 #17287294 未加载