New for AWS Lambda – Environment Variables and Serverless Application Model
aws.amazon.com
aws.amazon.com
I remember them telling us a way to make a lambda function distinguish whether it is in a DEV/TEST or PROD environment was to do some sort of regex on the function name, which was suboptimal, especially if you have Lambda's created via CloudFormation.
We "got around" this problem by creating tables in DynamoDB as our DEV/PROD environments are in separate AWS accounts, so the dynamo tables contained simple key/value pairs that you would read once when the lambda container started up. Another option would be to have a file in S3 or something, but you still have to write code to manage the retrieval of those resources.
Looking forward to dropping all that infrastructure and using this feature instead.
[1] http://docs.aws.amazon.com/lambda/latest/dg/versioning-alias...
Aliases are still a half solution to this problem though, you would still need logic in your code to say "if alias == PROD then ... else ..." for configuration, something I'd rather do without.
EDIT: by configuration I mean configuration that's specific to an environment. Imagine you had a Lambda that wrote data to an S3 bucket, you wouldn't want to accidentally mix TEST/LIVE data in the same location, so you would use a configuration property to inform the Lambda where to write.
Lambda is maturing so fast that I almost feel bad complaining about it, but of course we have run into our fair share of issues, too. One thing that's making our life more difficult right now is the fact that when you launch a Lambda function in a VPC via CloudFormation, the function's ENI doesn't get attached until the function runs the first time, so CloudFormation doesn't know anything about the ENI. Thus, when you tear down the CF stack, the ENI gets orphaned and hangs around in a detached state. Throw some automation into the mix and you can start eating up IP addresses in your subnet really fast. I have no doubt they will fix this soon.
I've been playing with AWS Lambda using travelling Ruby and Mruby, but have hit issues (with native gems etc).
I have used Iron Worker previously, but they seem to be going up market and don't even display pricing on their site.
Thanks in advance for your input!
I'm making an assumption that Functions is similar.
Taking another look now on some side projects, to get a sense of if all the of the issues have been addressed.
But the big ones were lack of env variables, and the tooling was atrocious.
I really like the concept, and the current serverless (serverless.com) framework has been simplified, runs based on cloud formation, and also allows the project to be run as an express server, and potentially with additional plugins on a competing serverless architecture.
I'm not using Apex or any of the other frameworks, just plain Go code wrapped by the JS function.
It's really awesome to work with, you just deploy a function and quit worrying about it.
Things like callbacks, message monitoring and stuff like that.
Example:
Monitor SNS messages for auto-scaling and send a message to slack when something fails. https://github.com/KensoDev/sns-lambda-notifier-golang
Recently, I've been using stdlib (https://stdlib.com) to do function-services since it's a lot easier to get started with it a bit more intuitive for newcomers to understand.
The main issue we've seen is, even at the "top" tier (1536mb) the CPU performance doesn't seem very good, it's difficult to tell as they abstract you away from what is actually going on under the hood.
Main advantages: easy to deploy, no infrastructure worries if your problem fits, event based triggers means you don't have to write any of that code, fits well in the AWS ecosystem.
I've seen people making serverless websites and things like that, but I'm not convinced Lambda is a good fit for such a thing (happy to be proven wrong)
[1] www.bustle.com and www.romper.com do a combined XX million unique visitors per month.
That said, we use node. I have heard cold starts are worse for Python (I have no data). I have heard they are near unbearable for Java (JVM startup and all that). We try and minimize external calls outside the main handler. Previous to this update we were packing configs with webpack at deploy time. Some people read them from S3 or dynamo. I don't consider that a good solution. I'll be working this week on Shep 3.0 which will use the new ENV var features.
I have talked to other people who do various hacks to force their functions to be warm. I've looked at doing this and haven't found it necessary yet for our use case.
Conceptually I think it's great for pipelines or use-cases like this, VMs are generally a terrible level of abstraction for a lot of problems, and the Lambda style promotes better architecture because of this.
The connectivity between Kinesis/SNS and friends is great. I'd agree that Lambda is not currently a good fit for "regular" apps, APIs should be fine now that the proxy stuff is in there, though there's slight latency.
No need to worry about gracefully stopping or restarting daemons, just push new code and the old stuff goes away, it really is a great abstraction that way. Basically replace anything you'd use a Go channel for, with more Lambda or SNS->Lambda if you need retries and backoff, it'll spare you a lot of code.
I find the workflow great as well, the slowest part for me is compiling the Go binaries, the rest is virtually instant. Especially now with all this needlessly complex Docker stuff it's refreshing to use something simple.
Cost is prohibitive for sustained use, so make sure you price things out properly, it sounds very cheap until you look at say a constant 100 requests/s behind API Gateway. It's easily 300-400% what you'd pay on EC2.
Cold-start is really a non-issue in most cases, it seems to take very little to keep a function warmed, so unless you get zero traffic (which would be dirt cheap on a t2.micro anyway) you'll be fine.
Edit: Feedback: Really like it. One feature that would be very nice would be the ability to trigger a ping on demand, e.g., for testing auth set up on a request. Runscope implements a similar feature. Otherwise great so far!
I had limited free plans originally but that went horribly wrong haha, free users only attract other free users, a few days later I had like 4000 free people. Maybe that works for startups, but not "real" companies.
https://hearthsim.info/blog/how-we-process-replays/
TLDR: AWS Lambda is awesome if you have indeterminate-but-high amounts of small CPU-bound tasks you want to be able to do in parallel, as soon as they are needed. Awesome for file processing (eg. image resizing) for example.
But being stuck on Python 2.7 sucks. PLEASE Amazon, announce Python 3 support already.
Last I calculated, it's nearly 5x the cost of comparable t2 on-demand EC2 instances. That can be mitigated if you have spiky traffic where you'd need to turn on several EC2 instances for less than an hour but are stuck paying for the full hour, or if you can scale to zero for extended periods of time.
Critical to us: you don't have the ability to serve concurrent requests from a single lambda worker, so if you're waiting for async IO (e.g. downloading from S3) then you're wasting money you wouldn't be wasting with EC2. You end up with one file per lambda worker, whereas we could handle about five files concurrently on a normal VM because of async IO. -- For us lambda was prohibitively expensive at scale. I suspect a fair number of people reporting significant savings vs EC2 had over-provisioned instances.
Hm...
My only gripe is that API Gateway (APIG) charges $3.5 per million requests and there is no other way to invoke lambda functions over HTTP. Had to scale back my micro-service ambitions because of this.
It seems like APIG has a boat load of features, which is great... but they are mostly unused.
My technical recommendation is as follows: "No".
[1] https://github.com/fugue/credstash
[2] https://topics.arlingtonva.us/2016/11/voter-registration-sea...
It's used in production for a few months now and we're really happy with it. It provides a negligible-cost replacement to Optimizely for us.
Wrote a blog post about it too: https://medium.com/@iotsky/how-we-built-the-iotsky-backend-u...
[0]: http://qmu.li
https://github.com/awslabs/chalice
Basically, I'm interested to know how the Swagger template file will look a like. It'd be nice if you could use Swagger to quickly create REST api on Lambda stack.
Being able to quickly generate scaffold CRUD REST api on Lambda behind Authentication + DynamoDB would be an absolute killer app.
I'd imagine that Azure is not far behind. But one thing that's killing it for Azure is the Visual Studio IDE. Edit my ASP web app, one click deploy to Azure from inside VS is a killer app as well.
I really wish AWS came up with their own IDE where it would be tightly integrated with AWS. Imagine if you could write code and deploy it instantly without setting things up yourself through the AWS console (not that it's bad or anything).
[1] https://www.google.com/amp/www.forbes.com/sites/janakirammsv...
If you want to see an example of how easy it is to use Zappa + Lambda + DyanamoDB, you can check out Zappa BitTorrent Tracker, which can use S3 or DynamoDB as a back-end.[1]
As a bonus, Zappa has had both local and remote environment variables as a feature for months - although it's pretty cool that this new announcement can use KMS, although that will of course mean more vendor-lock in if you choose to go that route.
[0] https://github.com/Miserlou/Zappa [1] https://github.com/Miserlou/zappa-bittorrent-tracker
I will say that chalice wasn't meant to copy zappa. Chalice and Zappa both started in Jan of 2016. Zappa has way more features and is a wonderful piece of software.
One thing Chalice does well that I'd love to see in Zappa is automatically figuring out what kind of IAM policy/permissions you need by analyzing the code.
[1] https://www.visualstudio.com/en-us/docs/build/define/variabl...
For example, instead of passing in a big JSON blob, one could split the JSON keys into separate environment variables.
That's our biggest restraint at the moment, so far I haven't seen any good options.
I've been involved with developing lambda functions that consume roughly 1.2gb of ram each time, but the memory usage is easy to predict as the function is triggered by files in S3 that are about the same size.
They say to break your problem down into smaller chunks to fit into the memory - is that possible in your case?