Handle Heavy Traffic with Google CDN and File Caching

Started by proofread, Oct 16, 2022, 08:17 AM

Previous topic - Next topic

proofreadTopic starter

If you need to host a static website like a Leaflet map with pre-calculated data or a static 3D model, you can use static file hosting on Google Cloud Storage. This method allows easy access restriction through the Google Cloud web interface by specifying user email addresses.

Heavy loads are handled through Google CDN and file caching, and adding or deleting files can be done through the gsutil console utility or the Google Cloud web interface. You don't need to worry about acquiring or updating SSL certificates or creating domain names since a scalable and easily supported solution that guarantees data protection is available through a few console commands.

The necessary steps for creating a site with limited access include creating a new bucket, allowing fine-granted access control, preparing an OAuth wrapper, copying it, making it publicly available, setting up a web site entry point, copying data, and setting the CORS configuration for the website. Access control for new users can be added using the Google Cloud web interface or the console command gsutil acl ch -u USER_EMAIL:objectViewer gs://BUCKET_NAME.

To make the website accessible to all users, execute the command gsutil acl ch -u allUsers:legacyObjectReader gs://BUCKET_NAME. After executing the command, any user can access the website from the link https://storage.googleapis.com/bucketname/index.html, which can be shortened using the command gsutil web set -m index.html gs://bucketname/.


Using cloud storage means that you pay for a service that provides both architecture and hardware. Numerous options exist for cloud interaction, such as an integrated approach or VSAAS (Video Surveillance As A Service), where the cost of video processing, analytics, and storage is not borne by you but instead purchased from a provider in addition to buying video cameras.

 Alternatively, you can back up your video archive from a local system to the cloud. One of the main advantages of cloud systems is the ability to access your system from anywhere in the world at any time. Urban infrastructure may be the most obvious user of cloud systems, such as having video cameras installed across a wide area that are controlled from one place and accessible online.


To configure Google Cloud, some preparation is necessary, as it requires additional credentials compared to similar services. You will need a working Google Cloud account with a payment option added and a domain that you have confirmed ownership of in the Search Console. A custom domain is necessary for website functionality in Google Cloud storage. Once these requirements are met, follow the steps below to set up Google Cloud:

First, open your Google Cloud console at https://console.cloud.google.com/ and ensure your website project is selected or create a new one if needed.

Select the Storage option from the hamburger menu on the left of the toolbar, and click on Enable billing on the Browser tab to allow your account to be charged for usage over the complimentary amount.

Next, click Create bucket and enter details for your bucket. For the bucket name, use your previously-verified domain name. Choose either Regional or Multi-regional for the Default storage class option depending on your visitors' location, and then click Create to finish.

After the bucket is created, we need to create a JSON key file that Publii can use to access the bucket to upload or update website files. In the Google Cloud console, click on the IAM & Admin → Service accounts option and create a new service account by setting the Role option to Storage Admin and checking the Furnish a new private key checkbox.

Next, enable the Cloud Storage JSON API service by clicking on the API Manager option and searching for the Cloud Storage JSON API. Once found, enable the API and configuration is complete.

Finally, open Publii, and configure the server settings to establish the connection with the bucket for file transfer.


Cloud storage is an appealing option for employees across different enterprises and users who require fast access to various databases and files. The platform is especially useful for accessing live audio and video content.
Users may prioritize maintaining consistent speed in different geographic regions. However, the owner of such hosting should still test the service in target locations ahead of time to ensure optimal functionality.


Cloud CDN functions primarily as a cache and necessitates a premium Google network layer, unlike AWS CloudFront. As a result, a load balancer is requisite for connecting to and serving the content, and it accounts for most of the configuration. Improving the platform's performance necessitates enabling this feature.

However, it also means that you will always have to pay at least $15 per month for a load balancer, plus applicable data transfer fees, making it impossible to create a "free S3 website" on GCP. Nevertheless, GCP offers Firebase Hosting, which can perform the same functions as AWS CloudFront and trigger relevant cost structures.


Google CDN (Content Delivery Network) and file caching are powerful tools that can help you handle heavy traffic on your website hosted on Google Cloud Storage.

When you use Google CDN, your web content is cached and distributed to multiple edge locations around the world. This means that when a user requests your website, they will be served the content from the edge location nearest to them, reducing latency and improving performance. This is particularly beneficial for static content that doesn't change frequently.

Additionally, Google CDN automatically caches your static files, such as HTML, CSS, JavaScript, and images, at the edge locations. This reduces the load on your origin server and improves response times. Caching can be customized further by setting cache control headers on your files.

To make use of Google CDN for your static website hosted on Google Cloud Storage, you simply need to configure the appropriate settings. You can enable CDN by going to the Cloud Storage browser, selecting your bucket, and navigating to the "Settings" tab. From there, you can toggle the option to use a CDN.

Google CDN operates by replicating your static website content across several edge locations worldwide. These edge locations are strategically placed in different geographical regions, allowing users to access your content from a location that is closer to them. This reduces the latency experienced by users, resulting in faster load times and improved performance.

When a user requests your website, the CDN serves the content from the edge location that is nearest to them. This reduces the distance data needs to travel, resulting in lower network latency. Additionally, since the content is cached at these edge locations, subsequent requests from other users in the same location can be served directly from the cache without needing to fetch the content from your origin server. This greatly reduces the load on your server and improves overall scalability.

Furthermore, Google CDN automatically applies caching rules to your static files. This means that once a file is requested, it is stored in the cache of the edge locations for a specified period of time. Subsequent requests for the same file within the caching period can be served directly from the cache, eliminating the need for repeated requests to your origin server. You can customize the caching behavior for your files by setting cache-control headers or using cache invalidation techniques.

By leveraging Google CDN and file caching, you can effectively handle heavy traffic by offloading the workload from your origin server and taking advantage of the distributed nature of the CDN. This combination helps improve the performance, scalability, and availability of your static website, ensuring a seamless experience for your users even during periods of high demand.