[HN Gopher] Handling 350k Requests for $3 using Lambda ___________________________________________________________________ Handling 350k Requests for $3 using Lambda Author : karakanb Score : 64 points Date : 2020-02-28 16:35 UTC (6 hours ago) (HTM) web link (levelup.gitconnected.com) (TXT) w3m dump (levelup.gitconnected.com) | [deleted] | [deleted] | fabioyy wrote: | 3$ for 350k request is VERY expensive | kenhwang wrote: | Seriously. Something like an AWS nano instance only costs | $4/month and can easily handle that many requests an hour with | a slow dynamic language. | highfrequency wrote: | Is there no variable charge for network bandwidth? | kenhwang wrote: | Lambda and EC2 have the same network bandwidth charge. | jerf wrote: | The scary thing I saw is that while it's cool that Lambda is | $2/month right now, which is negligible, it's $2/month for | 900 users. If it scales linearly (and I don't know that it | does, because I don't know exactly how the system works), | then that means you're one good blog post somewhere about | your extension away from being $200-$2000/month. | | That said, my gut says there's a good chance that since the | author is surprised at the rate of requests, there's almost | certainly an optimization opportunity that wouldn't even take | much effort. | tasogare wrote: | Especially the author has experience with docker so | deploying a container for his app on Digital Ocean would be | super quick and easy. In addition, the list of | disadvantages seems longer than the advantages, with scary | points like the difficulty to debug things (that could | easily takes hours to figure out if something don't run | properly). | habosa wrote: | However in the case when they both get 0 requests, the Lambda | solution costs $0 and the Micro instance still costs $4. | | That's a really nice advantage for starting a new project | where you're confident in unit economics but have unknown | scale. | cnst wrote: | Is it two different arguments you're posting? How's $0 on | zero requests is a better solution when the range would be | 0 to $2000 for what's a fixed $4 without Lambda? | | The $0 argument is also flowed because $4 is a fixed cost | for unlimited $0 to $2000 solutions through hedging. If you | have 10 solutions, what's the likelihood of all of them | still doing $0, or at the very least below $4? | | The unit economics argument is likewise hard to see in | practice, because we'd be talking quite different numbers | on a per-unit cost with Lambda vs. without, which may | easily make the difference between making a profit or | taking a loss, especially if it's a lifestyle business | we're talking about. | abc-xyz wrote: | Pretty sure you'd have to pay at least $3.5 if you wanted | to expose your Lambda function using AWS API Gateway (which | I assume most would want to do).. The author mention $1.11 | but that's for "HTTP APIs (Preview)" rather than "REST | APIs" - in either case it wouldn't be 0. At least that's | how I read it.. AWS pricing is such a mess with so many | hidden fees (https://aws.amazon.com/api-gateway/pricing/).. | nwsm wrote: | If you meant for your comment to be constructive you'll need to | expand on it. | tuananh wrote: | well authhor did list high cost as disadvantage. | aeyes wrote: | It would be a fraction of that without API gateway, not sure | what it is needed for. I deploy directly to Lambda@Edge and it | is an order of magnitude cheaper. | paxys wrote: | It may be very cheap or very expensive depending on what the | requests are doing. There's no point making an overly | generalized statement. | jerven wrote: | My experience with UniProt.org where some requests generate | responses dynamically generated gigabytes in size. This is | roughly 400x more expensive, assuming response equivalence. | rumanator wrote: | >>It may be very cheap or very expensive | | It is very expensive. Very. No need to ignore this fact. You | can get a VM with 2 vCPU and 2GB of RAM for that amount with | some cloud service providers like Hetzner. | SlowRobotAhead wrote: | And manage it yourself forever. | | I'm not saying this example isn't expensive. But you didn't | post an apples to apples. | lgsilver wrote: | Agree. We consider non-cached requests costly if they extend | beyond around $1.50 / million. That said, we do about 2-3% of | requests non-cached. As a content network, that means that a | million web requests can be as low as $.30 to .40. This does | have a lot of benefit to scale, but ~$10 / million seems high. | What stops you from putting a ttl on these and caching them for | a couple mins. Probably would lower that number substantially. | blantonl wrote: | Couple points here in this specific case | | 1) Lambda costs were shown as actually 50 cents for all this. | 2) API Gateway was the balance of the cost, and actually isn't | needed in this customer's use case. Lambdas can be placed | behind application load balancers which are significantly less | expensive. | | Author also mentions other downsides such as "vendor lock-in," | however his lambdas were written in NodeJs and it would be | trivial to move his code to some other NodeJs delivery | mechanism such as Fargate or ECS cluster. | | The benefit here is his deployment with the ServerLess | framework got him his MVP very quickly on a very scalable | environment with minimal management. | shaneprrlt wrote: | API Gateway is the definite gotcha with serverless | architectures. Whenever someone tells me how cheaper | serverless is, I figure they haven't actually dived in to see | how many AWS resources besides Lambda are required for a | production deployment. | | It is convenient in several use cases, but for an endpoint or | even an entire API that is going to receive a lot of load, | managing servers is the more economical approach. | | If you need to get a one-off endpoint built that won't | receive any significant amount of load, I think a serverless | solution is great. But I wouldn't use it as my primary API | architecture. Like most things in tech, there's no silver | bullet. Context matters, and the best approach depends on | many factors. | | I still recall this article by the creator of ipify on how | he's able to receive upwards of 30 billion requests per month | on Heroku for a fraction of the cost of API gateway: | https://blog.heroku.com/scaling-ipify-to-30-billion-and- | beyo... | blantonl wrote: | I run 8 different production API endpoints, all on Lambda, | directly through Application Load Balancer instead of API | Gateway, and they served 510 million requests last month | for about $200. | | Those API endpoints took me about a day to deploy using | serverless deployment tools. They economically scale | between extremely varied workload requirements. There are | no complaints on my end. | koolba wrote: | > Author also mentions other downsides such as "vendor lock- | in," however his lambdas were written in NodeJs and it would | be trivial to move his code to some other NodeJs delivery | mechanism such as Fargate or ECS cluster. | | I find it amusing that your examples to which one could move | the project and avoid "vendor lock-in" are both from the same | vendor as Lambda. | | I get the point that it's not Lambda specific outside the | entry point, it's just funny that the presented alternatives | are still cutting a check to the same vendor. | blantonl wrote: | Well, the variability in this case is how much system | administration you want to do. Right? | vander_elst wrote: | It's like 0.13qps on average. Assuming a constant load and no | spikes, a raspberry pi should also be able to handle this load, | it would be nice to compare the performance | draw_down wrote: | Well, there are a lot of other assumptions embedded in that | comparison too. What's the raspberry pi's availability like vs | Lambda? | rubyn00bie wrote: | My Raspiberry PI model 3 would do roughly[1] ~250 req/s with an | Elixir server I wrote. 350k @ $3 requests seems kind of | expensive to me to be honest. | Klinky wrote: | Is your pi at an AWS data center? How much to co-host it at | an AWS-grade data center? | | Sure a self-hosted pi is cheaper, but that's an apples vs | oranges comparison. | whalesalad wrote: | (This comment is unrelated to the use of lambda, and more of a | note to the author) | | The author comments that they prefer the light mode to their own | dark mode. I think that the dark mode would benefit greatly from | being designed (color wise) bottom-up as a dark mode, versus just | trying to toggle certain things to be darker. | | The big tell is that the lines separating each row of content | appear to be the same color in both areas. This tells me that the | color of the line is not determined based on the color behind it | (either via transparency, via color manipulation manually, or via | dynamic color manipulation from a tool like sass (ie, opacity(), | darken(), etc...) | | I do agree w/ the author that light mode looks better. I also | tend to prefer dark mode UIs. I think that by mindfully | revisiting color a lot of the visual noise will go away and | result in a more pleasant experience. | | tl;dr dark mode is not just inverting certain light colors to | dark, it should be done with more care. | SahAssar wrote: | Seems like a better argument for not using FaaS after reading it | all. | | It's also filled with "once you've done X Y is simple!" like: | | > Once you have the template ready, you can simply deploy your | code by running: serverless deploy | | which is true for all automatable tasks. The same can be said for | any VM or shared hosting. | unethical_ban wrote: | That completely misses the point of FaaS. | | Devs don't want to manage VMs. Patching, gold loads, SSH | configs, k8s, so on. You write code, you deploy, and you pay | only when the function executes. It scales as much as you want | it to, as much as it needs to, and quicker even than EC2. | | There are very clear benefits to FaaS. It is certainly not for | everyone, esp. if you already have a well functioning | deployment pipeline. | brintnc wrote: | > Devs don't want to manage VMs. Patching, gold loads, SSH | configs, k8s, so on | | Which devs? | | I'm a developer and I enjoy most of these things. Working | with k8s is a pleasure, managing VMs can be quite simple (and | more often than not, is). I don't do much patching, but I | "SSH" into our k8s pods quite frequently. I've never thought, | gee I wish I had a lambda to simplify this. I know I _also_ | don't represent all devs, but I'm never seen this comment | made outside of it being an argument supporting FAAS. | jayd16 wrote: | If the author is already making an extension, could they have the | extension set the security policy for these sites and simply | display them in iframes? No cost at all. | wackget wrote: | They're not actually displaying the websites; they're pulling | the top stories via each site's API and rendering them locally. | treyhuffine wrote: | Friend link (no paywall): | https://levelup.gitconnected.com/handling-350k-requests-for-... | ignoramous wrote: | archive: | https://web.archive.org/web/20200228185628/https://levelup.g... | merty wrote: | This isn't actually one of those solutions where Lambda shines, | pricing wise. | | I would simply trigger a Lambda function once a minute (or every | X minutes) using CloudWatch to fetch the latest articles and save | them to an S3 bucket which I would expose and cache using | CloudFront or any other CDN service. | | This would lead to: | | - No Lambda costs as it would be covered by the monthly free tier | of 1M requests. | | - No storage costs as the size of the stored data would be | extremely small. | | - Really fast responses as the "response" would actually be a | static file cached at the CDN. | | - The only parameter defining your cost would be your CDN of | choice, which would cost somewhere between free and as low as | $10/TB. For a project like the one in the article, that's | hundreds of millions of requests for just $10. | chasers wrote: | Cloudflare is $0.50 per million. | jessmay wrote: | Can the extension not make the http requests to get this info? Am | I missing the need for a backend for this type of work? | treyhuffine wrote: | API keys I believe | jccooper wrote: | As mentioned in the article, some of the data sources use API | keys which the author didn't want to make available to end | users. | danols wrote: | Is there anyone but me who uses the premium article on medium.com | as a filter for what is NOT worth my time? | | I believe in the tech space the majority of readers who write in | depth worth to read articles are not incentivised by a few | dollars kickback from their hard work from medium.com. They often | write it for personal profile enhancement or company blog | marketing reasons and want to reach maximum audience and will | keep it free for all. | | The problem nowadays though is that medium.com is often able to | trick them by making the article premium through deceptive ui | even when that is not their intention. Just look at the | googlecloud medium blog and you constantly see premium articles | there which seems bizarre. | wj wrote: | I haven't subscribed to Medium but there are certainly some | articles/guides I have read there over the years that have been | helpful. | jeremyjh wrote: | I use medium.com as a filter in general. | danols wrote: | readers-> authors ___________________________________________________________________ (page generated 2020-02-28 23:00 UTC)