0

I am reading about Google Cloud CDN, and in that article it says it needs 4 services (I am new to Google Cloud architecture):

  1. Cloud DNS: Safely look past the obnoxious inclusion of the word "Cloud" here (Google marketing be damned). This "service" involves DNS configuration for a given domain, such as adding A/AAAA records. This allows us to serve assets from a custom domain (such as cdn.hackersandslackers.com, in my case).
  2. Load Balancer: It feels a bit excessive, but GCP forces us to handle the routing of a frontend (our DNS) to a backend (storage bucket) via a load balancer.
  3. Cloud Storage: Google's equivalent to an S3 bucket. This is where we'll be storing assets to serve our users.
  4. Cloud CDN: When we configure our load balancer to point to a Cloud Storage bucket, we receive the option to enable "Cloud CDN." This is what tells Google to serve assets from edges in its global network and allows us to set caching policies.

My actual problem is described in more detail in How could creating symlinks/aliases to files on S3 work, while still taking advantage of CDN optimizations?, but the main thing I'm wondering is, how can I create a many-to-one mapping from custom app-level IDs, to the Google Cloud bucket file? I want to have each user get a unique URL to a file, so we can measure the traffic that comes from each user's unique shared URL (so if one user shares ImageA and it only gets 1000 views per month, vs. another user sharing ImageA getting 1M views per month, they get charged differently for traffic).

So I am trying to imagine, we have a "frontend DNS" routed using a "Load Balancer" to the "Cloud Storage bucket", which is geographically distributed in the CDN somehow (not too sure how this works exactly in Google's case). Can I insert a layer, or create a simple Node.js app at the "frontend DNS" or "load balancer" layer which takes the URL, and grabs the ID from the URL, looks it up in some database (like Firebase), and then calls to the actual CDN/Cloud Storage bucket path? All-the-while keeping the benefit of the geographically distributed content on the CDN? I don't know if this is possible, and not sure where to really look if it is possible. Looking for an answer on if it's possible, and if yes, where I can look to learn more on how to add my custom little 1-filer Node.js app mapping the input ID to the bucket path.

It sounds like you can do very basic mapping with URL maps, but I am looking for inserting basically a script or app in between, to do the mapping by looking up stuff from a database. Not sure if that is possible.

Lance
  • 75,200
  • 93
  • 289
  • 503

0 Answers0