We survived 10k requests/second: Switching to signed asset URLs in an emergency
1–10 of 176 posts
Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#2This post goes over what happened, how we put an a solution in place in hours and how we landed on the route we took.
I'm curious to hear how others have solved this same problem – generating authenticated URLs when you have a public API.
Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#3For example, the value of session ID cookies should actually be signed with an HMAC, and checked at the edge by the CDN. Session cookies that represent a authenticated session should also look different than unauthenticated ones. The checks should all happen at the edge, at your reverse proxy, without doing any I/O or calling your "fastcgi" process manager.
But let's get to the juicy part... hosting files. Ideally, you shouldn't have "secret URLs" for files, because then they can be shared and even (gasp) hotlinked from websites. Instead, you should use features like X-Accel-Redirect in NGINX to let your app server determine access to these gated resources. Apache has similar things.
Anyway, here is a write-up which goes into much more detail: https://community.qbix.com/t/files-and-storage/286
Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#4Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#5Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#6Reading your blogpost I don't fully get how the current signing implementation can halt massive downloads, or the "attacker"(?) would just adapt their methods to get the signed URLs first and then proceed to download what they are after anyway?
Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#7Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#8I had a look at the site - why does this need to run on a major cloud provider at all? Why use VERY expensive cloud storage at 9 cents per gigabyte? Why use very expensive image conversion at $50/month when you can run sharp on a Linux server?
I shouldn't be surprised - the world is all in on very expensive cloud computing.
There's another way though assuming you are running something fairly "normal" (whatever that means) - run your own Linux servers. Serve data from those Linux computers. I use CloudFlare R2 to serve your files - its free. You probably don't need most of your fancy architecture - run a fast server on Ionos or Hetzner or something and stop angsting about budget alerts from Google for things that should be free and runnong on your own computers - simple,. straightforward and without IAM spaghetti and all that garbage.
EDIT: I just had a look at the architecture diagram - this is overarchitected. This is a single server application that almost has no architecture - Caddy as a web server - a local queue - serve images from R2 - should be running on a single machine on a host that charges nothing or trivial amount for data.
Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#9Re: We survived 10k requests/second: Switching to signed asset URLs in an emergency
#10Do any cloud providers have a sensible default or easy-to-enable mode for “you literally cannot spend one penny until you set specific quotas/limits for each resource you’re allocating”?