3 ms·
I've got bad experiences with go startup (i.e., cold runs). They're much more expensive than I would have expected. If node can indeed run in 40ms (as https://n
by tgv 6y ago
I've got bad experiences with go startup (i.e., cold runs). They're much more expensive than I would have expected. If node can indeed run in 40ms (as https://news.ycombinator.com/item?id=25267211 https://news.ycombinator.com/item?id=25267211 says), then I'm surely going back to JS.
- philosopher1234 6y agoWhat is your experience? Go is an AOT compiled language so the only thing I could imagine you running into on startup is loading the binary into memory? Theres not a cold-start issue with Go, as its not an optimizing JIT. Edit: Bizarre. Seems like Go on lambda does actually have slower cold start than JS or Python. I wonder if its just that the binary is likely larger than the equivalent JS source code? https://levelup.gitconnected.com/aws-lambda-cold-start-language-comparisons-2019-edition-%EF%B8%8F-1946d32a0244 https://levelup.gitconnected.com/aws-lambda-cold-start-langu...
- nicoburns 6y agoI'm not sure about lambda, but cloudflare workers use v8 isolates to avoid starting a new process at all.
- tgv 6y agoMy experience is that Go cold start takes around 900ms. Processing (parsing a JSON message, verifying it with one DynamoDB look-up, and storing it in DynamoDB) then takes between 11ms and 105ms. Go does use less memory than node, though, and that also counts in Lambda. I hadn't expected it either, but it loads node faster. Perhaps via some VM trick?
- gen220 6y ago> The function did nothing except emit ‘hello world’. A more realistic benchmark would be parsing a 1kb protobuf blob and printing some random key from it. (this would require importing a non-stdlib parser) Without knowing how it's implemented, my guess is that they're conserving python/v8 processes, so that they're not cold-starting the interpreter on each lambda execution. You can't [1] do the same thing for a Go binary, so they have to invoke a binary, which might involve running some scans against it first. This leads to some pretty counterintuitive conclusions! If you want minimal latency (in Lambda!!), you really should be using JS/Python, I guess. [1]: OK. Maybe you could. Go has a runtime after all, although it's compiled into the binary! I have never heard of anybody doing this, but I'd love to read something about it. :)
- indymike 6y agoGo binaries are pretty large compared to say, C.
- Thaxll 6y agoGo is not AOT compiled.
- philosopher1234 6y ago... yes it is?
- gabipurcaru 6y agosame. I went through the trouble of implementing my function in Rust (Rocket), and it's actually quite slow because (a) startup is slow and (b) async/await is still pretty painful to use so I'm blocking on IO
- Tehnix 6y agoI wrote this in another comment here, but just so you don't miss it: Don't. Dependencies for the dynamic languages matter A LOT! Take a look at what it'll cost you for requiring the AWS SDK in Node.js, for your cold starts https://theburningmonk.com/2019/03/just-how-expensive-is-the-full-aws-sdk/ https://theburningmonk.com/2019/03/just-how-expensive-is-the... Personal benchmarks puts Rust as the most optimal language that I've tried to run on AWS Lambda so far.