10 ms·
Chalice: Python Serverless Microframework for AWS
- collyw 10y agoOk, I have seen the phrase "serverless" a few times recently. Can someone explain to me what it is (as I am pretty sure it involves a server - it runs on AWS ffs) and why I should want to use it? And most importantly, is it web scale?
- Slippery_John 10y agoIt just means you don't have to worry at all about managing the servers, using thing like AWS Lambda which handle it for you. Generally these services will scale up and down for you as well.
- oneplane 10y agoThat just worries me all the more. You basically get software engineers that wall themselves into their garden. It's like nodejs all over again...
- nostrademons 10y agoThat's been the trend in the software industry since about 2000. When I started then, the job description was just "software engineer", and you were expected to know networking, databases, low-level code, UI code, scripting, etc. Now you have "frontend software engineer", "backend software engineer", "full-stack software engineer" (which seems to mean web framework + database, which is a very different meaning from what "full stack" meant when I started, or what it means at big companies like Google), "AWS specialist", "web developer", "Android developer", "iOS developer", "SRE", "devops", "data scientist", "machine-learning researcher", "infrastructure engineer", etc. It's actually a boon to entrepreneurial types who really do know the full stack inside and out. So many startups these days are "slap a web or mobile app in front of a manual process", so people who really do understand computation and all the things computers can do have less competition.
- scardine 10y agoIf you don't understand why GOOD startups do this, take a look at the "Doing things that don't scale[1]" lecture from "How to Start a Startup" series by Sam Altman at Stanford. [1] https://clip.mn/video/yt-oQOC-qy-GDY https://clip.mn/video/yt-oQOC-qy-GDY
- deleted 10y ago[deleted]
- losteric 10y agoWe're still figuring out how to separate responsibilities for building software... it's the same cycle of maturation that construction, manufacturing, and every other large domain goes through.
- audleman 10y agoI think this type of thing will end up being useful for special cases, but in general we'll still want to run our own servers. Their use case of creating a public API is a great one: it's a simple interface and having Lambda handle the auto-scaling is pretty awesome.
- coredog64 10y agoWe are using Lambda to export CloudWatch metrics to another system. Haven't exceeded the free tier of Lambda yet, and CW itself was only $5 last month. Having a t2 up the whole time would have been way more, plus it would have been subject to our Chaos Monkey.
- oneplane 10y agoWouldn't it be a lot cheaper if you have a dedicated box where you can run your own VMs and add and remove services as you please? So far, running one at base cost with leased hardware costs about 1/10th of any 'cloud' provider out there, with lots more resources to go around. Right now, if want to spin up a new instance, container or process, I can do it locally, in vagrant or on a VM on the dedicated box all with the same config and management ease of the configuration management stack (we use SaltStack). It also works just fine with stuff like GCE or AWS, but those simply are never ever the 'cheapest' option. At best, they are a in-between solution when we need more hardware. It's great for temporary scaling, but of nominal resource usage there is no point in using those services at all, at least for us. The cost of a dedicated box is static, no matter how much you use, and yet it is always lower than the mean cost or 95th percentile of any AWS/GCE kind of thing. For (converted currency from euro) about 100USD we get 16 E5 cores, 92GB RAM, 1TB SSD RAID10, 10TB HDD RAID10 and 8TB transfer on a dual 1Gbit link. For the life of me I can't find any combination on Amazon to match that.
- dkarapetyan 10y agoIt's just marketing hype. As you noted there is no such thing as serverless. It is another architecture that forces you to use AWS Lambda and API gateway and a few other services to glue everything together. The idea being that if you are just shuttling bytes back and forth then the overhead of the traditional deployment is too much and you're better served with what looks like an event bus with some transformers sitting in the middle.
- collyw 10y agoIt seems like its a serverless pricing model.
- meddlepal 10y agoIt means it runs using AWS Lambda and allows access via the API Gateway... it's literally in the second sentence with links to explain what those technologies are. Lambda's are just units of code that run only On-Demand and without having to manage one or more EC2 instances or a container platform.
- oneplane 10y agoAlso known as: an expensive and lazy way to make something work 'a little bit' until it gets too complex and times out.
- softawre 10y agohttp://martinfowler.com/articles/serverless.html http://martinfowler.com/articles/serverless.html
- dragonwriter 10y agoIn this case, its the FaaS version, which is really just a slight twist on traditional PaaS. Really, the "serverless" term does more to obscure than to illuminate.
- vhold 10y agoWith Lambda you pay per 100ms / per-1-million-requests. So, yes, it's very proprietary at the moment, but for any service that sits idle most of the time it can be very cheap. https://aws.amazon.com/lambda/pricing/ https://aws.amazon.com/lambda/pricing/ If you were hosting something like a little message board for your friends and family, or something you are demoing to to possible employers, etc, it'd be borderline free, but available all the time.
- jafingi 10y agoI have a SaaS running on EC2s/Beanstalk where I have a feature that a user only runs max. a few times per day (if any). It's a small Python algorithm that finds the most optimal combination in an array of items. For that, Lambda is great. We have lowered our price since migrating to Lambda for this relatively simple script.
- tie_ 10y agoIt means that you no longer have to deal with the server configuration - the servers are completely hidden from you. You just give your functions to AWS, and they run them in a black-magic-box of theirs. I've tested it at least to the extent of 100-200 rq/sec, and it holds up nice. Ultimately, there is a server somewhere, as you might expect. It's just not yours to manage/worry about.
- deleted 10y ago[deleted]
- wcummings 10y agoIt's an app server. It's like PHP.
- spriggan3 10y agoThat's exactly what it is, fancy CGI only one pays for each script execution instead of a monthly subscription. The "Oh, but it doesn't use HTTP but a pubsub architecture" is meaningless, that's still CGI for hipsters. And you still need to use (and pay) for API gateway on AWS in order to execute Lambda scripts from the outside.
- nashadelic 10y agoWell, if you look at how we've done things over the years: - We used to have our own machines in our own data centers - Then we started renting machines in data centers - We then moved to the cloud model where we would get compute capacity on demand. But the minimum unit was an hour - But what if you could deploy your code and you were only charged for the compute and memory you take for the fulfillment of that request? That is what the "serverless" model is. You don't constantly run a server like apache; instead, when you receive a user Request, the relevant function is called, executed and results returned to the user. You are billed for the ram ⨉ CPU. This has many benefits: - For low traffic sites, this has significant cost savings - For high traffic sites, this is auto-scaling without thinking about launching machine instances This isn't without problems, naturally. This lends itself well to certain type of problems better than others. For example, if you need lots of hot-cache data, the response times on a serverless stack would be slower. But as you can see from the above, this is the logical direction cloud computing will evolve. Infrastructure will truly be shared and you should be able to extract efficiencies down to the minute.
- Animats 10y agoIt's like running CGI on a shared server, except that it scales better.
- e12e 10y agoI wonder if that's really true (that it scales better than running more-or-less bog standard CGI across a fleet of thousands of servers, behind a load balancer). If I've understood lambda correctly, rather than spinning up a process (as with CGI), it spins up an entire vm/container. I suppose it might do the fast-cgi thing - spin up a container, and keep it running while there are requests coming in, and then kill it off. I'm sure there are other benefits of "container-on-demand" vs "process-on-demand" -- but I'm not sure "scales better" is one of them. Well, I'm sure it "scales better" in the sense of organization (human resources), but not necessarily in terms of machine resources. At any rate, I like the analogy.
- 10y ago
- pesfandiar 10y agoHas anyone successfully and painlessly used Lambda+API Gateway in production as their main backend? It appears Lambda has many limitations, but I see rather mature frameworks such as Serverless (formerly JAWS) being promoted here, and now Amazon is also working on their standard framework. It would be great to just use CDNs and this; get all benefits of using a PaaS with IaaS-level costs only!
- cddotdotslash 10y agoCloudSploit did - and just wrote an article [1] about it a few days ago. It isn't for everyone but it definitely save money in the right situations. [1] https://medium.com/@CloudSploit/we-made-the-whole-company-serverless-5a91c27cd8c4 https://medium.com/@CloudSploit/we-made-the-whole-company-se...
- adzicg 10y agowe use it now as the main backend for Mindmup 2, migrated from Heroku. I recently published the scripts evolved from our usage to simplify deployments as https://Github.com/claudiajs https://Github.com/claudiajs - the tool is mature, and allows teams to use API GW almost as easy as if it were a lightweight web server
- spriggan3 10y agoSo basically each end point is a function ? how do you test your whole app locally ? I mean integration tests and acceptance tests on your local machine if you depend entirely on AWS vendor lockin infrastructure
- SwellJoe 10y agoAWS Lambda is cool and all, but aren't people doing the math on this? Lambda seems like a really expensive way to deliver almost anything. Likewise, the AWS API Gateway is expensive, but at least provides some additional capabilities. Lambda seems like its profitable niche would be very small; limited computing environment, very high cost (relative to almost every other way to host an API), and having to learn a whole bunch of new APIs and processes to make it all spin. Am I missing something?
- scrollaway 10y agoWhat makes you say Lambda is more expensive than things like EC2? Obviously lambda is a hammer, not a swiss army knife - you shouldn't shoehorn it into your app just because it's the new tech on the block. But the use case isn't niche at all. We're using lambda for our service to ingest and process Hearthstone replays. An HTTP POST is sent to the API gateway, this triggers a lambda which parses a 0.5-2MB file, scrapes the data in it and stores data in the db + converts it to another format. The whole process takes 3-6 seconds. Lambda lets us easily scale to dozens of requests per second without having to worry about anything other than the DB server. Our frontend/app servers don't need to be touched. The alternative would be to provision and manage a lot of EC2 instances to handle the load. We'd have to worry about provisioning them dynamically so that it's economically viable. We'd have to manage the load balancing ourselves. Lambda's been a huge time saver. PS: Let it be known that Lambda only supports python 2.7, not python 3, and that really frickin sucks. Get your shit together, Amazon.
- emjr 10y ago"Let it be known that Lambda only supports python 2.7, not python 3, and that really frickin sucks. Get your shit together, Amazon." Node 4 support came, what, a month ago? It's pretty ridiculous.
- scrollaway 10y agoI specifically don't understand the Python 3 situation. They support Python 2, it can't be that complicated to have a separate Python 3 runtime.
- ak217 10y agoThis is awesome - it takes care of a lot of the pain of setting up Lambda, including the packaging, the tricky IAM policies and the crazy API Gateway incantations. It also follows the Flask decorator conventions! I could have really used this a few months ago. I ended up writing a library of my own, but I'd much rather have used this, as it's supported by the AWS Python team. This really lowers the barrier to entry to deploying Python-based API servers!
- gsmethells 10y agoI love the name. :) Fits right in with "flask" (http://flask.pocoo.org http://flask.pocoo.org) and "bottle" (http://bottlepy.org/docs/dev/index.html http://bottlepy.org/docs/dev/index.html).
- alaskamiller 10y agoShameless plug: come join over 6200+ of us at https://flask.reddit.com https://flask.reddit.com discussing Python and Flask!
- tdicola 10y agoVery cool, is it still Python 2.7.x only though like AWS Lambda service & Python code?
- Slippery_John 10y agoSeems that way, until Lambda adds support for Python 3
- cdnsteve 10y agoI think I would have preferred this to be some type of plugin/add-on to Flask rather than a full replacement that now locks me to AWS and is a brand new project without any docs :( If it was a cli with decorators or something that uses Flask I would feel more comfortable and give it a shot.
- ganduG 10y agohttps://github.com/Miserlou/Zappa https://github.com/Miserlou/Zappa might be more useful to you.
- deleted 10y ago[deleted]
- audleman 10y agoHopefully the Flask team will whip something like that up. I also want to see this for Django.
- ak217 10y agoI've looked into doing this. Flask is too integrated with the WSGI protocol to be easily adapted to this model. It presupposes a number of things about the request and response protocol that are not true in Lambda. You would end up having to write an unwieldy WSGI emulation layer (what Zappa did) and still wouldn't be able to achieve 100% WSGI compatibility, breaking a subset of the plugins. Most people love Flask because of its beautiful, minimalistic route decorators and hooks. That subset of the API can be easily replicated - Chalice is part of the way there - and I'm hoping it emerges as an API standard, separate from WSGI.
- eli 10y agoYou're not wrong, but there are plenty of examples of using Flash without WSGI. I use Flask-Frozen to generate static sites from the CLI, for example.
- bmelton 10y agoYou may be right overall, but that's a particularly bad example, as Frozen simply eliminates the "flask" portion that gets deployed to the server in lieu of static files, ergo obviating the need for WSGI altogether. Serving a Frozen app on lambda means serving static files on lambda, which is very doable, and a very different use case than developing something like an API to be deployed to lambda. Edit: Re-reading our comments, you may be confusing the difficulty -- it isn't in building the CLI for Flask, it's in getting Flask to be served over lambda. Presumably, the OP could easily re-write the deploy functionality to deploy a flask application, it's just that the flask application is unlikely to work because it defaults to WSGI, which lambda (apparently) does not provide.
- johnwheeler 10y agoQuestion: With these "Serverless" frameworks (Zappa, Chalice, Serverless, etc), do you have to redeploy to Lambda every time you want to test your changes during development? Is there a way to develop locally and get quick feedback?
- marcrosoft 10y agoI am not sure about the frameworks, but a lambda function is just that, a function. You can easily run your function and pass in an event object (a dict in Python) to test various scenarios. You don't need to deploy to test. Once you are ready you can deploy to lambda without publishing to fully test before publishing live.
- johnwheeler 10y agoThank you. Are these not meant to render user interfaces and just be for API-style computing?
- niftich 10y agoCorrect. That being said, there's nothing stopping you from emitting, say, HTML from such a function. But there's nothing really helping you either. It's basically function calls in the cloud; a remote procedure call where the remote procedure is executing on their infrastructure.
- deleted 10y ago[deleted]
- johnwheeler 10y agoI'm also guessing there's no session state or cookies?
- johnwheeler 10y agoWe'll I guess there wouldn't be without a server. You'd have to use JWT or the like.
- deleted 10y ago[deleted]
- jaydenmallen 10y agoConsider https://getsandbox.com https://getsandbox.com it provides great support for viewing state and route logs. Various hosting options.
- robmccoll 10y agoServerless computing seems to just be reinventing hosted CGI. Is this not just a trade of Perl and php for Python and JavaScript?
- e12e 10y agoI think one could engineer CGI to get many of the same benefits - I'm not entirely sure most people did. First, you'd want to run each process in a separate jail, as a separate user - and yet be able to (easily) use fifo's or pipes (possibly sockets) to pipe data through. At that point, you're already a bit from ephemeral data in /tmp and your typical php/perl/cgi setup. But I think you're right in that it borrows some of the good ideas from CGI (chief among them simplicity, assuming that you were doing stateless stuff).
- mxuribe 10y agoI think this is great! While I'm no python expert - as much as i love flask - i get annoyed at the parts needed to setup up the uWSGI stuff. It looks like using chalice, maybe i don't have to worry about setting up the annoying uWSGI stuff?
- e12e 10y agoWhat is the recommended way of keeping the URL of the service straight? To set up a DNS pointer to the DNS name amazon generates, with a "low enough" TTL?