Varnish config for discourse

Is there an official config for discourse that I can use?

There is not an official Varnish config for Discourse.

2 Likes

Not official, but there have been some stabs at it before.

3 Likes

Thanks. A bit surprised there since Discourse has official support for Fastly and that means there should be a config the team uses.

Fastly does standard origin pull, you donā€™t need to fuss with Varnish. We have already 2 howtos that cover this depending on your level of adventure/pain.

https://community.fastly.com/ is configured using ā€œfull site CDN accelerationā€

4 Likes

Please correct me if I am wrong, but donā€™t you need to do invalidation when some one replies, update categories pages when new content is added etc. My understanding is that one needs to run the invalidation logic from the code to caching system. Therefore I thought Discourse should be having a varnish config file thatā€™s probably deployed on Fastly.

no not really, you only have to invalidate stuff you are caching.

Discourse can only use a CDN for static assets, not for content.

1 Like

Ohh ooh. Thatā€™s a revelation. Huge bummer.

I donā€™t think what @RGJ said is correct; you can visit our hosted Fastly community at https://community.fastly.com/ which goes entirely through Fastly, content and all.

Thanks Jeff. Huge relief. Am I right in assuming that https://community.fastly.com/ ā€˜s varnish config is by them and not by the discourse community.

We generally donā€™t recommend this config because it is quite complicated and does not get you much that a traditional (and far, far simpler) CDN of static assets does not already deliver.

CDN, in this case is not for performance but for high availability ā€“ I offload everything and my single server is hardly hit with more than 1 RPS (almost only the logged in people). In the eventuality that my server goes down(which often does), the read-only site is always up, even if the login and such functionality is limited.

1 Like

Hmmm ā€¦ no ā€¦ we never cache any dynamic content. Any caching we do is done in the app.

image

It is possible that a vary by x-discourse-username would allow us to cache for anon via headers. I never experimented with that implementation.

As it stands all dynamic requests like looking at this page hit the app.

2 Likes

Thank you for the clarification. Iā€™ll also post this question on https://community.fastly.com/ in case they have something interesting.

1 Like

@Quintin_Par I saw you also posted over at Fastlyā€¦

Did you ever get this worked out? Iā€™m surprised that even when configured as a ā€œFull Site CDNā€ that community.fastly.com would go offline if their one server with discourse went offline.

Iā€™ve got a setup right now with 2 descent sized web servers and 1 bigger data server. Iā€™m also planning to setup one autoscaling instance at AWS which normally would only see ~5% of traffic, but when spikes come in would scale up additional serversā€¦

My sites traffic comes in big spikes. Previously we had 500,000 users online at once, so thatā€™s a lot of load to plan forā€¦

Still having the site work via the CDN even if the server were down would just be fantastic, but my foremost concern is being able to handle big spikes.

QUESTIONS:

  • Did you end up going with Fastly? Full Site CDN?

  • If you did, how do you feel about your experience with it? If not, what made you decide otherwise?

Thanks so much for any additional feedback you can make the time to offer.

Saw this late. Nope. No real CDN for Varnish/Fastly.