Firebase Hosting just got a bit faster all around the world. Today we're announcing the launch of origin servers in Europe and Asia, plus two more across the US!
Firebase Hosting now stores and serves content not just in the United States, but in Europe and Asia. This means that all this content can be delivered more quickly to people close to these regions. The results so far have shown a 20% reduction in global Time To First Byte (or TTFB), which is the time that the browser has to wait before receiving the first byte of data from the server.
How Firebase Hosting delivers content
Firebase Hosting uses a global CDN (Content Delivery Network) to deliver cached content. But sometimes the content requested isn’t available in a CDN and needs to be requested from the origin server.
For example, this could be the first time the content is being requested by a user, or it could be that the site is frequently deployed, which means that previous versions that were cached have been purged from the CDN. We call this situation a Cache-Miss.
How Firebase Hosting deals with Cache-Miss
When the content is not available on the CDN, we need to request it from the origin server which is located in the United States. The problem is that there is a longer wait time for requests made from places far away from this server. Well, at least there was a long waiting time until now!
Here at Firebase, we wanted to reduce latency for everyone, not just those located near the origin server in the US.
Origin servers and content in Europe and Asia!
What does it mean?
When you deploy your site, Firebase Hosting replicates your content in the United States and on origin servers located in Europe and Asia. Before this launch, if content was not in the CDN cache, the request would be routed all the way back to the single origin server in the US.
From now on, requests made in regions close to these will be redirected to one of these servers, making a much faster response time.
We can already see the results!
As soon as we spun up the servers in Asia, we could see a 50% reduction on the waiting time for uncached content to start loading in the region. This is a huge improvement for all users around the world. These are the origin servers we have so far:
A glimpse into the future of Cloud Functions
The next big step for the Firebase Hosting team is to allow Cloud Functions to be deployed to these servers in Europe and Asia as well. Currently, Cloud Functions can only be deployed to the origin server in the United States, meaning a higher latency for users across the world. These new global origins will allow for Cloud Function deployments outside of the US to work with Firebase Hosting.
If you're looking to take advantage of this functionality today, then check out Cloud Run. Firebase Hosting currently supports Cloud Run rewrites outside of the US.
Update August 2022: Cloud Functions for Firebase now supports Hosting's new global origins! As of version
11.4.0 of the Firebase CLI, you can set a region in your function code, and Hosting will automatically talk to that function from a global region. Learn more in the docs
What does this mean for dynamic content?
Enabling our users to deploy Cloud Functions and Cloud Run to the same regions as these new origin servers will result in dynamic content being delivered significantly faster to everyone making requests in regions close to Europe and Asia, so stay tuned!
Now that you know about the Firebase Hosting improvements, and what this allows us to do going forward, why not try it yourself? Refer to the documentation to learn how to quickly set up and get started with Firebase Hosting. Reach out to us on Twitter if you have any questions or comments! Happy deploying!