480 points · by abd12 · 8y ago · 211 comments
We are making these open source runtimes available soon:
C++[1]
Rust[2]
We are also working with our partners to provide more open source runtimes:
Erlang (Alert Logic)
Elixir (Alert Logic)
Cobol (Blu Age)
N|Solid (NodeSource)
PHP (Stackery)
There is also native Ruby support as well[3]1. https://aws.amazon.com/blogs/compute/introducing-the-c-lambd...
2. https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws...
3. https://aws.amazon.com/blogs/compute/announcing-ruby-support...
Seeing this takes away one of my biggest comparative advantages, but I'm happy to see that at least I was not wrong in thinking this feature would be important for developers.
CGI still has the advantage of being an open standard, locally testable, and not vendor specific.
[1] https://en.wikipedia.org/wiki/Service_Component_Architecture
With the native ruby support[3], I wonder how hard it would be to implement a Lambda ActiveJob handler..
Honest question: I don’t Ruby, I just looked up what it is.
Boom, no need for Active Job.
Welcome to Serverless.
There’s going to be a lot of people trying to do things the “rails way” on serverless and it’s going to be a little confusing for a while. Many will write it off, some will creat innovative new gems. And of course the Ruby community will come up with the best abstraction for SAM templates and deployment, because we like nice tools.
1. Lambda Layers - Reusable components that can be shared across lambda functions (covered in the linked article)
2. AWS (Serverless) Toolkits for PyCharm, IntelliJ & VS Code - https://aws.amazon.com/blogs/aws/new-aws-toolkits-for-pychar...
3. Nested Applications Using the AWS Serverless Application Repository - https://aws.amazon.com/about-aws/whats-new/2018/11/sam-suppo...
It relaxes constraints that have historically restricted the shape of viable languages. With massively-parallel deterministic compilation (like Stanford's gg - which just got simpler to implement). Parallel distributed incremental shared type checking, like Facebook's Hack. Language-community-wide sharing of compilation artifacts (sort-of like build images, or typescript's type definition repos, or Coq's proof repo).
"That would be a nice language feature, but we don't know how to compile it efficiently, so you can't have it" has been a crippling refrain for decades. "[D]on't know how to either parallelize or centrally cache it" is a much lower bar. At least for open source.
This involves not just compiler tech in isolation, but also community organization for fine-grain code sharing. Any suggestions on things to look at?
https://www.serverless-ruby.org/
We've been waiting! I thought this would never happen. Eating major crow today, as I've assumed for a long time that AWS's lack of Ruby support in Lambda was an intentional omission and sign that they are not our friends.
I will change my tone starting today!
(edit: Or Google Cloud Functions, or probably some other major ones I've missed...)
It's pretty comprehensive. And it was able to cache the execution context (and keep the cache warm) to approach native execution times. All of this obviously before native Ruby support was announced.
Not the first time I heard of it. But actively trying to kill it is a whole different level.
10 minutes before the announcement that OP is about here, one of our architects copied this line from an AWS slide deck:
> AWS Lambda supports code written in Node.js (JavaScript), Python, Java (Java 8 compatible), and C# (.NET Core) and Go.
... and intimated that, if your language is not on this list, you're not part of the dominant side of the industry.
As if to say, to the large cohort of Ruby developers we have on staff, "You guys are basically irrelevant because Amazon doesn't care if you can work on the pride and joy of their platform or not."
Every other week I've got a different person telling me that Ruby is a quirky niche language and I should get with the times and become a full-stack JavaScript developer instead.
I get it, there's growth in other languages, but if I have years of experience that means I should throw it away?
Sometimes these conversations get really personal, too. Almost like we're choosing a football team, you'd think it was politics or religion that we're debating...
serverless-haskell also takes care of packaging shared objects depended upon alongside the binary. You will have to package any binary dependencies of your Haskell code yourself.
The way it works is by generating a Node script which invokes the compiled binary with the payload as an environment variable, although this is encapsulated by an interface which you implement in the Haskell code.
One thing to make sure is that your libraries and Haskell code are compiled on a system compatible with the Lambda execution environment. Documentation going further into ELF compatibility is available, but I can’t remember where. I remember using stack to have my Haskell code compile on an Ubuntu docker image which was compatible.
We use both Lambda for data processing on incoming IoT events, and also for API interactions with our user, along with services to send mails and SMS, etc.
---
I would just want to use the robustness and correctness that I'm able to ensure with Haskell, compare to TypeScript, and especially bundling quirks with Webpack and NPM.
An example of an easy thing to let through is missing an _await_ on a call (might be for logging or something else), which means it'll go out-of-band, and can then easily not be run during the execution, if you have disabled waiting for the event loop to be done (which is necessary in many cases for global setup optimizations).
The call might then finish when the lambda function is thawed, but it might also never run, because the function gets collected.
Now, admittedly, this is not a big issue in any way, but it's the death by a thousand papercuts that I'd like to avoid.
We have so many Lambdas that share common Java JAR libs.
Lambda Layers appears to solve our reuse and deployment headaches.
* We had to hack around Lambda zip size limits. Now we can deploy fat dependencies to Layers and ditch the hacks.
* We can drastically speed up build and packaging time locally by keeping fat dependencies in Layers.
* We use a shared in-house library to wrap all code that lives in a Lambda. Updating the version of this required us to deploy every single Lambda that used it. Now it can live in one place.
* We can eliminate repeated deployment pain for Python code with C dependencies by deploying the manylinux wheel to Layers. Now devs can go back to just packaging up pure Python and not worry about cross-platform problems.
And probably loads more I'm not thinking of.
In the end, we came to the conclusion that Amazon is smart and won’t let you hack together the equivalent of a cheaper EC2.
On the other hand, their incentive to solve the problem is relatively weak vs an on-premise alternative.
Life on a lambda is too short to pay 6-8 second startup penalty over and over millions of time.
[1]: https://github.com/libmir/mir-algorithm [2]: https://mratsim.github.io/Arraymancer/
Often it is a sign that the problem is not "big" enough (eg: not crunching truly large data sets) OR data science team gets disproportionate amount of goodwill (thus money) to spend on its foibles. :)
I came to this thread specifically to find out about numpy and pandas on lambda.
A similar method is described here: https://serverlesscode.com/post/deploy-scikitlearn-on-lamba/
Layers should make this entire process easier.
package: exclude: - venv/
would reduce the size considerably (to 50 MB in my case)
Of course an official method is nice here.
TBH, I'm very happy to see native support, but it was already super, super easy to use Rust on lambdas without a shim layer.
That said I I hope they increase the limit to at least 500 Mb sooner than next reInvent.
"Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again. This also means that a single prepared statement cannot be used by multiple simultaneous database clients..."[1]
I have used C++ in Lambda before, it is quite cumbersome and it still has the performance hit of using Node.JS.
Check out some of the examples in the GitHub repository.
There are only example CMake calls to find_library, that will or will not find this library based on things that are not documented.
AWS Lambda still uses Amazon Linux AMI as the base for running all code. MySQL C++ connector library is not available to be easily installed by yum for this particular OS.
In particular, the library is distributed as an RPM, from Oracle website, which requires you to be logged in to download it, and then manually installed.
Also, an appropriate CMake find script has to be available to CMake.
Therefore, this is still a valid question, and AWS support needs to clarify.
For the previous Lambda version, I had to add the mysqlcppconn.so file to the uploaded zip and use something like this to ensure the executable runs:
"/lib64/ld-linux-x86-64.so.2 --library-path "+process.cwd() +"/node_modules/.bin/lib "+process.cwd() +"/node_modules/.bin/helloworld "
I have O365 scripts i need to run, but i only see support for PS6+
The lambda team is now letting you write that runtime, and presumably providing more documentation on the responsibilities of the runtime.
Check out the example C++ and Rust runtimes to understand why each language needed to have it's own custom runtime.
The way Lambda manages to achieve the performance it does is because it bootstraps the application and then runs each new request through the loaded application.
This means Lambda needs some way to communicate with an already running service.
Initially, Lambda had language specific runtimes that took care of this (i.e. with Node they have their own bootstrapper that loads your top-level JS file and then calls the defined method each time it receives a new event).
With the release of the Go runtime, they built a framework that gets compiled into your service that runs a simplified HTTP server that Lambda then submits events to.
This latest generalised version eschews an embedded HTTP server for letting your app do something like a long-poll to a local event RPC source in the Lambda container. Basically, your app boots and attempts to pull a job off the queue, if there's a job, your Lambda runs, if there isn't, your Lambda service gets paused until there's something to send it.
I hope this runtime API is a simplification of the go rpc api
So, 10+ seconds cold start, and 200 + 200-300ms (around 500-600ms avg) calls to the Lambda function. Complete garbage for our application at least (I imagine using it for background processing might not be an issue with latency).
Switched over to EC2, less than 200ms response total, no cold starts.
[1] https://twitter.com/jeremy_daly/status/1068272580556087296
Thankfully, in my case, I have a very steady flow of data so I don't expect too many cold starts.
AWS is making continual improvements in this area.
We've tried this and it helps somewhat but when AWS attempts to scale your function based on load, cold starts re-appear. We've moved away from Lambdas where a dependable response time is required.
If you are experiencing cold starts it means that function is not used very often. If it's not used very often that likely means it's not user facing (or something less important like a Terms of Service page). If that's the case, why do you need instant response times?
You can basically replace all HTTP-API Lambdas with it, because it allows direct access to DynamoDB.
MySQL tends to have very low connection times, which helps a lot in this area also.
Guess you're stuck with Aurora Serverless or DynamoDB.
The VTL resolvers don't have the cold-start problem, AFAIK.
So I will go with AWS Lambda. But seems like having lot of dependency increases the lag, wonder if there's a way to put the source on a diet.
These issues that Azure has already solved, make me wonder how much longer i will stay with AWS.
Source: just implemented cross acct lambda -> RDS connection using VPC
(Disclaimer: I work for AWS, but this is strictly my personal opinion/observation.)
That’s the only major difference I can see, though. The rest is convention/standardization on what’s put into the image (an executable that speaks HTTP over its stdio; separately-namespaced projects under /opt rather than use of the global namespace; etc.)
1. https://aws.amazon.com/about-aws/whats-new/2018/08/aws-farga...
Per-event invocation of a docker container instead of a specific bundle of code seems much more flexible, especially with the Firecracker tech they announced.
If you're gonna use containers, use containers. If you want someone else to manage the container for you, use Lambda.
Create a simple ping/pong HTTP service in both and you'll quickly see difference in everything from billing to startup time.
If you're gonna use containers, use containers. If you want someone else to manage the container for you, use Lambda.