13 ms·
Announcing Go Support for AWS Lambda
- jrs235 9y agoDupe: https://news.ycombinator.com/item?id=16153780 https://news.ycombinator.com/item?id=16153780
- jitl 9y agoThe link there pointed to a Github repo with an almost entirely empty README, so I posted the official blog post with examples and a full walkthrough.
- dhbradshaw 9y agoGo seems like a great fit for this application. Would love to see stats comparing cold start times etc. for go vs. java/python/js. One would guess that it would be faster, but measurement trumps guessing.
- Cthulhu_ 9y agoI think it mostly depends on whether it's always executed from source, or whether it's compiled and stored in fast access storage. If the latter, binary size becomes the main limiting factor (for pretty much all of those applications). Java is generally kinda slow to start up, but that may be due to all the frameworks. Python / JS IIRC are interpreted as scripts, not compiled. Mind you the go compiler is also pretty damn fast, almost script language speed.
- mattherman 9y agoI created one yesterday when this announcement was made. I had to upload my compiled binary, not source.
- mathw 9y agoAbsolutely. I've done some work with Lambda, and the cold start times for Java and C# were horrendous. Node and Python were pretty fast. I would expect Go to be more the latter than the former, with the added advantage of running really fast as well (and not being JavaScript), so my advice to my former colleagues on implementation language for a Lambda-based solution would be different if that pans out...
- chronid 9y agoIn my case when I gave Java a bigger allocation of RAM I got far better result (and it usually got even faster than the equivalent Python/NodeJS code). At the time at least (I don't know right now, it's been a long while since I touched a lambda function) it seemed that the bigger RAM share == the more CPU you get, which was not written anywhere in the documetation. And JVM startup times with crappy CPUs are indeed horrible. :)
- pixie_ 9y agoFor Go and/or C# lambda support would it be worth even running the garbage collector, or just allocating a block of memory and cleaning it up when the function ends? Side note I think that should be an option for web servers as well for languages with managed memory. Light isolated non-threaded api endpoints shouldn't be interrupted by garbage collection.
- jitl 9y agoWe do this during request execution in our Ruby services. We tell the GC to pre-allocate a few GBs of memory, and then explicitly suspend GC until the end of the request. Then we do a single GC run.
- wickawic 9y agoVery interesting! Have you experienced improvements from this approach?
- jitl 9y agoAbsolutely. It's a critical part of our runtime configuration, but we're hardly the first people to think of this approach. I remember reading some discussion in an HN thread about FinTech developers who run Java with 100GB+ heaps and no garbage collector, and then reboot the application after the markets close. I can't find that specific thread, but I did find this which has a few nuggets on the same subject: https://news.ycombinator.com/item?id=6131786 https://news.ycombinator.com/item?id=6131786
- jnordwick 9y agoWhile that does happen sometimes, from where I've worked at it is more common to write in a garbage-less style (basically not allocating or pooling everything) since JIT time matters at startup, especially for certain classes of strategies. Ive seen applications run and never GC after initial startup until they get bounced to update. Another problem with the big heap is that you still have tlab issues if you keep allocating. There is a new-ish poc collector called the null collector that literally does nothing, not even instrumentation, i believe, of write barriers. We always see idiomatic programs benched against each other but I'd really like to see high performance pure java against high performance pure go and others. Some of the low latency Java tricks we use I'm not sure if they can even be copied in other hll (not including c/c++).
- leifg 9y agoI'm still wondering why Lambda simply doesn't support Docker containers? Would put an end to all this requests like "Please support $my_favorite_language on Lambda"
- owaislone 9y agoYou are looking for a different product. What you are looking for is ECS+Fargate. That does exactly this. The difference is that with ECS+Fargate you are in charge of building the entire application from scratch. With lambda you just implement 1 function, the "service" part of your app and all the plumbing to support different things like X-Ray, logging, handling errors, hot and cold boots, etc etc are handler by AWS.
- otterley 9y agoBecause it’s a function execution system, not an application execution system. If you need the latter, you can use ECS or K8S.
- benatkin 9y agoIt seems that they benefit from lock-in, whether it's deliberate or not.
- philliphaydon 9y agoThere is no lock-in... you can write an agnostic function for both AWS lambda and azure function.
- 9y ago
- schappim 9y agoI wish they'd do the same for Ruby... hopefully Ruby is next!
- drej 9y agoFirst Python 3, now Go, fantastic. Plus that X-Ray support looks great. The only thing that surprised me is that the Body struct element is a String, not an io.Reader. Can we not stream large bodies through API Gateway into a Lambda? Does it always read the whole thing before passing it onto my Lambda? Or what's the reason behind the String? I haven't tried this yet, so I'm curious.
- alexcasalboni 9y agoThe maximum payload is 6MB for synchronous invocations and 128KB for asynchronous invocations. More info here: https://docs.aws.amazon.com/lambda/latest/dg/limits.html https://docs.aws.amazon.com/lambda/latest/dg/limits.html
- Corrado 9y agoI guess I'm confused as to how the support of one compiled language differs from any other compiled language; couldn't you just replace "Go" with "Rust" at this point? I understand how Lambda would have to support scripting languages (NodeJS, Python, etc.) with built-in runtimes and such, but if you are going to compile down to a binary object anyway, why does it matter what language the binary object was written in? Does it have to do with supporting libraries being pre-installed on the Lambda image or something? Couldn't they build a Lambda image that handles any language that can interface to common "C" headers?
- Guthur 9y agoYour code is wrapped so you do not have to deal with networking and serialization. Your code must only satisfy the interface and feels native to the language of choice.
- colde 9y agoYou can actually sort of do what you are asking. It was common before official support for languages to use node, and simply call out to a binary compiled for Amazon Linux. That does work. However, the support means that the Lambda system can call the specific binary directly, and that libraries are available to expose the data structures easily. There is nothing preventing you from calling a rust program from the node runtime for instance, if you wanted to.
- owaislone 9y agoThe answer lies in understanding how lambda truly works. Lambda does not start a new version of your program every time the function is called. The real entry point to the program is somewhere else hidden to customers. That program starts up and then waits for requests like a web server. On every request, it invokes our lambda function. It literally invokes the function, it does not spin up a new instance of the program. The program lambda spawns keeps running until no new requests come in for a certain amount of time which is not known. This is also why first invocation of a lambda function after a long time is slower. Also, there still are other things to take care of. Online code editor support, making sure everything works and there are no bugs, support for compiling the programs edited directly from the browser, etc etc. Also, Lambda support means that the language has access to it's execution context through an API and there is no better way than to implement it in the same language and just pass an object to your handler. Lambda functions in reality are not one-off CLI commands that boot and terminate fast. They actually spin up a long running service and then the same instance handles multiple requests until the instance is killed off because of being inactive for too long. Having lambda support means AWS implementing a long running server that integrates with your code, handles things like errors, exceptions, logging and provides you with an API to execution context.
- HNSucksAss 9y agoHas Amazon cleaned up their documentation yet? Oh yeah, and how about not being able to search for a file by name using the S3 Web UI? WTF?
- ramses0 9y agoWhat's the current state of the art for "I know I use AWS for my 9999-server production instance, but how can I test the majority of my services offline on an airplane w/o spending $199.99/mo to keep a fleet of test AWS servers/services at the ready"? Last I looked the "fake-aws", specifically "lambda" supported python, not JS/Node, which was not matching my use-case. Go is now on the radar as a usable programming language for this purpose, but what are the chances of being able to also use it with local test deployments?
- dschep 9y agoYeah, that's probably the worst part of 'serverless computing.' If using the serverless framework, the serverless-offline plugin[0] supports JS/Node but not Python. [0] https://github.com/dherault/serverless-offline https://github.com/dherault/serverless-offline
- jsty 9y agoDo you need to keep them running constantly? The beauty of platforms like AWS, GCP, ... is that provisioning capacity is just an API call away - so could you not have some way of provisioning those resources on demand to run the necessary tests? (If you can't get internet on your plane then you might not be able to run tests, but that's the case with the full test suite on a fair few systems anyway)
- ramses0 9y agoThe services are incredibly useful, incredibly powerful, but from a code + dev hygiene perspective it's safer to be able to completely test your code in isolation prior to deployment. Many people are saying: "Just mock the AWS parts..." or "Provision from amazon on demand...", but there should be "common" mocks, or ideally "toy mocks" which can be used locally in order to verify the production system works how you expect it to, prior to deployment to that production system. Basically, I'm uncomfortable making AWS a hard-dependency if I can't get something like it running locally for a "100 record use case"
- cachesking 9y ago
- srebalaji 9y agoWhat about Ruby.. ?
- baybal2 9y agoAn interesting service this lambda is. Amazon wants to bill people money for basically hosting xinetd scripts. I wonder how much money do they make from it.