4 ms·
Interesting read, thanks for posting, but I think you can do better. I've been playing with Fastly and VCL recently and you could write your whole app in VCL an
by orf 9y ago
Interesting read, thanks for posting, but I think you can do better. I've been playing with Fastly and VCL recently and you could write your whole app in VCL and have it served right from the CDN. 25 million requests would cost about $20 for that. If you include the API keys in the log output and batch-process that each day/hour/whatever to keep usage stats, that would remove the need for Dynamo? You'd then keep a table of banned API keys and update that through the Fastly API dynamically.
Just a thought. Still, $150 p/m is not bad!
- jonathan-kosgei 9y agoAwesome! thanks for sharing! I'm always looking for optimizations. Any idea whether fastly would support running out of specific regions? Or how many endpoints they have?
- orf 9y agoNot sure if you can run them on specific regions. They have a lot of endpoints though, there is a list on their status page: https://status.fastly.com/ https://status.fastly.com/. I count 55.
- jonathan-kosgei 9y agoThanks! I'm excited to try this and benchmark it against my current setup!
- zzzcpan 9y agoConsidering it's like 20 simple requests per second, you can do it on a couple of tiny virtual servers (for geo and redundancy), totaling less than $10 per month.
- orf 9y agothe hard bit is the API key and usage monitoring. you could write the whole thing as Cloudflare workers for $5 per month else. $20 for 55 'servers' spread worldwide isn't bad, with no maintenance overhead.
- zackbloom 9y agoWriting Javascript is, in my experience, much more pleasant than writing VCL, and Cloudflare has over 150 points of presence.
- jonathan-kosgei 9y agoIt would also take some work to scale
- JrSchild 9y agoMy strategy is to use Cloudflare workers to invoke a Lambda function. This way I have a cheap AWS API Gateway replacement. $3.70 per 1M requests becomes only $0.50. Costing my only $12.5 for 25M requests + the Lambda invocations which are hella cheap.
- jonathan-kosgei 9y agoInteresting strategy mate! Any links on how to do that? I've googled a bit but haven't find anything on this!
- zackbloom 9y agoI don't know if there are any great blog posts on it yet (write one!) but you can read more about Workers here: https://developers.cloudflare.com/workers/about/ https://developers.cloudflare.com/workers/about/
- JrSchild 9y agohttps://blog.cloudflare.com/cloudflare-workers-unleashed/ https://blog.cloudflare.com/cloudflare-workers-unleashed/ Yes check this out. What you'll have to do is build the aws sdk into a single javascript file that runs as a Web Worker. These are distributed to over a 100 servers worldwide. Then you would want to invoke the Lambda function from the worker, link below. You could potentially distribute this further by invoking a Lambda function geographically close to that specific worker. But this setup will be very fast already. https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lamb...
- jonathan-kosgei 9y agoAwesome! Thanks!
- JrSchild 9y agoIt might be cool to create a tool that automatically turns a serverless.json file into Cloudflare workers that acts as little AWS API Gateway services. If anyone is up for swapping ideas, I made a GitHub repo: https://github.com/JrSchild/cloudflare-lambda https://github.com/JrSchild/cloudflare-lambda