1

So I know that Cold Starts are a thing due to the whole architecture and that is fine, so I wanna host my SSR Website on the Hosting and make it SSR via the Cloud Functions which is possible as seen in endless examples when googling.

One thing I wanna prevent is having Cold Starts happen even if the page has a consistent traffic, in theory if the Page has a consistent traffic so that the Render Function is executed on a frequent basis there should be no cold Starts or do you I need to keep something else in mind?

I dont wann have long Page load times happen too often.

niclas_4
  • 3,514
  • 1
  • 18
  • 49

1 Answers1

0

Thats correct, as long as it has consistent traffic you shouldn't run into cold start issues. There is always a possiblity with serverless architecture that it could go away but as long as its consistently being hit it shouldnt suffer a cold start issue. If you are running on Firebase Hosting using a Cloud function to do the SSR you could also leverage the firebase cdn to store it and therefore not needing to do the SSR each time.

Link to Connect to functions and lower down the page explains the cache control. You can put it in the cache for as long as you need. I have used it in the past to preload the cache on specific pages and that way they are ready when needed and if needs be it can fall back to the SSR.

Jack Woodward
  • 991
  • 5
  • 9
  • Oh thanks for that Info I will try to implement that – niclas_4 Nov 13 '18 at 13:09
  • A other question idk if you got experience in such a case but since its a blog so a new post would only appear like 1-2 times a day would it be an option to let the post once in the firestore trigger a function which prerenders a related page, this way i could use a lot less function triggers while having the SEO optimization of SSR, or am i overlooking something? – niclas_4 Nov 13 '18 at 13:18
  • Thats what I would suggest. I have setup similar things where firestore triggers will for `onUpdate` purge a page from the cache and then issue to the web request which will put it into the CDN and `onCreate` just issue the web request and put it into the CDN. To purge instead of doing a get to the page the method is purge. Its not an official method in the API yet but was mentioned in a talk once. – Jack Woodward Nov 13 '18 at 14:10
  • Okay, I will write some code and I would appreciate it if you could look over the Functions File once im done with it i have no experience in the Functions yet and im scared that I do mistakes that lower efficiency and cost more – niclas_4 Nov 13 '18 at 15:22
  • 2
    You can't fully eliminate cold starts, as Cloud Functions may always spin up a new server instance to handle increasing load. That new instance will have a cold start. All you can do is make the problem less bad, but you can't eliminate it without having your own servers running 24/7. – Doug Stevenson Nov 13 '18 at 16:56