DEV Community

Dave Parizek
Dave Parizek

Posted on • Updated on

Problems with Firebase Hosting and Large Site - anyone know of large sites that do work on Firebase hosting??

In this article I share my experience with Firebase hosting, and their support, for a large static web site.

I have a quotes web site that includes tons of picture quote jpg files. That is relevant because I was using Firebase hosting for all the files, including the picture files, and that site has grown and now has over 2.5 million files.

When the site got over 2 million files large, I noticed deployment failures (time outs) more and more often. The deploy would fail and the error would be that it had tried six times on a file to reach the firebase hosting server to no avail. Then it reached the point where it would always time out and I could not deploy at all.

I contacted Firebase support about it. They responded after two days (it was during the holidays) and asked for more information:

  • Your firebase.json file
  • What framework are you using for your web site?
  • Why do you have such a huge amount of files?
  • Try to deploy your Hosting files using the following command firebase deploy --only hosting --debug and share firebase-debug.log

I sent the info immediately, and after two more days of waiting (was free support, I was not paying for a support plan, but ug), got this:

Hello David,
Unfortunately I have to admit that Firebase Hosting is not the best solution to store such an amount of images. And I can’t provide you any workaround that can speedup the deployment in this case.
Usually I would recommend you to use Cloud Storage for images, but in this case you will need to do major updates to your web site architecture, so the decision is totally up to you.

Feel free to contact me if you have any questions.

I was not looking for a speedup - I was looking for it to work period.

Anyway, their recommendation is to put user files, and excess image files in my case, in a storage bucket - and then the html, css, etc. can stay in Firebase hosting.

I went to do that but there is a deal breaking complication:

If I continued with Firebase hosting, but put the image files in cloud storage, then I have the tradeoff that the images will be at a different domain. My domain name discoverquotes.com would point to Firebase hosting, and then the image files -the quote pictures - would be src'd as some subfolder of https://storage.googleapis.com/ --
e.g. https://storage.googleapis.com/discoverquotes.com/404.html.

This is not good for branding or SEO and is a deal breaker.

So... clearly I made a "doh!" choice in choosing Firebase hosting for a site that I now hope may grow to 10 million files. When I started I originally had just a small site in mind. And I see that Firebase recommends putting "user" files in Cloud Storage - there is even a section in the Firebase console for Storage. But then what to do about the much longer url for the images - and more importantly - that those images are now not under your domain so you don't get SEO credit (or branding credit with users) for them? and wouldn't users prefer to see their files under the same domain they submitted them to?

My solution was to get a Google Cloud Storage bucket, point my domain at it, serve the entire site there, and forgo Firebase hosting entirely. I needed https, so this meant also paying for a load balancer, as that is required to make Google's cloud storage buckets work with https.

And then I put Google Cloud CDN in front of that to keep things fast. It has meant more complexity... my wish is that I could have just stuck with Firebase, which was a joy until my site got large.

To be clear: I could still use Firebase's other features - you do not have to use their hosting to use their other features like Firestore - a misconception I had when I first started with Firebase. But... no longer sure if I really need it if I am not going to use their hosting and could just use Cloud functions and other solutions now.

I even looked at changing my approach with the site. I cut the number of files from 2.5 million to 200,000. And still had Firebase error out every time I tried to deploy. Arrgh! I don't think it did such though back when I was growing and reached 200-300K files. Surely Firebase hosting should be able to handle 200K files - its the cloud, right? Right, or am I just clueless?

Was my experience an outlier? Has anyone else been able to deploy large sites successfully over time to Firebase hosting? Is there a size limit recommended? - I could not find one anywhere in Google's documentation, nor any warning that it - the hosting part - is only good for small sites. Your experiences?

Top comments (0)