All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Cheap CDN with long origin timeout (180-200 seconds)
For a product that I'm working on, customers expect to make a single HTTP request and wait for as long as it would take for the result to be produced (typically ~160-180 seconds).
Since this product is hosted on one of the "big three" clouds, I'm hoping to reduce outbound data costs by caching repeated requests on a CDN. Of course, this CDN would need to support a timeout of 180 seconds or more.
My search only turned up CloudFront, which is hell of a expensive service ($0.0085/GB at the cheapest tier), and Cloudflare, which requires that I spend a four figure sum with them for this feature.
If this were a VPS I'd look into nginx caching, but I'm trying to save money and thus, caching it on the server instances of the "big three" would end up costing me the same data transfer pricing for every request.
Are there any alternatives to what I'm looking for?
Comments
Bunny CDN (Bunny.net)
What kind of request need 180-200 secs?
I doubt most CDN provider would allow. Max timeout for most will be within 30-60 secs.
That's an insane request. 170 sec time out count?
cloudflare is free.
Thanks, do they allow for 180-200 seconds timeout? I couldn't find anything on their public documentation.
I'd love to ask the customers to use a polling or event driven architecture, but I can't. They expect to keep a HTTP request open to the service and wait until the data is ready to be served.
Cloudflare is free and allows upto 100 seconds, anything beyond that and you need to pay up for the four figure amount, which I don't have.
I think hosting it on a VPS besides the big three are the only option.. Much more flexibility & customization.. Have you considered this?
@BunnySpeed
Bunny CDN or cloudflare
What about using a push CDN rather than a pull CDN? Your origin can take as long as it wants then, as it pushes the data to the CDN rather than the CDN pulling it. Doesn't work in all scenarios, but it's worth considering.
Cloudflare's maximum timeout on free accounts is 100 seconds for the entire request, and 15 seconds for the HTTP handshake. Paid accounts can increase it to 600 seconds, so a paid Cloudflare account might be an option here.
These requests are dynamic (imagine something like being asked to fetch a large data source and process it immediately), so push can't help. I'd really love if the customers were accommodating, but you know how customers are
Is it any paid account? $20 for their business plan doesn't seem so bad, and Google cloud has some discounted rates if I transfer data to Cloudflare POPs, so that would be nice.
Not sure, as I've only dealt with complimentary enterprise accounts (for popular open-source projects) where we have access to some (but not all) enterprise features for free.
The docs at https://support.cloudflare.com/hc/en-us/articles/115003011431#524error say "Enterprise customers can increase the 524 timeout up to 600 seconds" so unfortunately you might be out of luck on their non-enterprise plans.
IMO give their sales team a call (or use their live chat) and see if they can do a custom paid plan that's essentially just the free or plus plan with an increased timeout.
I use Bunny, and it times out at 60 sec. I guess you'll have to use the site without CDN.
how about put a reverse proxy server in front of client it and reply 307 redirect when proxy found it has cached responses in cdn?
do they chunk? can you send bytes slowly at a time?
I've used that trick in another project of mine. In this case, I can't, since the data is highly interdependent.
Yeah, since I'm looking for an unicorn, that's probably the route I'm going to go down.
was thinking continually send newlines or null bytes until your data finished processing
I guess 100 seconds is the maximum time until the response headers are sent out - or at least, Cloudflare doesn't seem to have a set timeout for the response body transferred in chunked encoding. I have a hobby project on a free Cloudflare account that utilizes server-sent events, and the longest request last week survived 24.5 hours.
However, their manual says in https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors:
So I guess it's not something you can rely on.
For a REST service, you can't send headers before the API call completes, because you can't know whether the call would succeed or fail, and thus can't predict the HTTP status code that is part of the headers.
This is an interesting idea, but the reverse proxy server isn't really necessary.
Whenever an API call completes successfully, the API server writes the result to a file (could be ramdisk), and then redirects to a CDN domain.
This includes the first time that response is sent.
The CDN domain points to a file server that sends those files.