dogvscat icon indicating copy to clipboard operation
dogvscat copied to clipboard

Add cache to Ghost blog service

Open BretFisher opened this issue 5 years ago • 6 comments

Since the Ghost service can only have a single replica (Ghost design limitation), it's expected to have a caching proxy in front of it, which itself could be multi-replica for better LB/HA. I'm thinking the best options here are varnish or nginx, which would be another service in the Ghost stack file.

BretFisher avatar Aug 31 '18 20:08 BretFisher

I'll be very curious to see the architecture you have in mind. There is an issue on Traefik's GitHub but it goes nowhere at this point.

pascalandy avatar Nov 15 '18 01:11 pascalandy

I was assuming a cache container in front of Ghost node container. So traffic would be:

client --> cloud LB-->swarm ingress-->traefik-->proxy overlay-->cache-->ghost overlay-->ghost

I'm normally a nginx guy, and have done reverse proxy caching with it before, but thought it would be fun to try varnish in this project, which I haven't used.

Hopefully, we can use one of these images:

  • This one requires a varnish config file added as a swarm config, but looks flexible and up to date.

  • This one is ENVVAR heavy, which I like (very 12factor.net!) No configs needed hopefully.

BretFisher avatar Nov 15 '18 03:11 BretFisher

If I understand well, in a case where I have 5 Ghost instances, I would need 5 varnish instances.

client—>cloud LB—>swarm ingress—>traefik—>proxy overlay—>Varnish_Caching_1—>Ghost overlay—>Ghost_1
                                                       —>Varnish_Caching_2—>Ghost overlay—>Ghost_2
                                                       —>Varnish_Caching_n—>Ghost overlay—>Ghost_n

I actually like this. Not all my clients needs to have a caching instance :-p

pascalandy avatar Nov 15 '18 03:11 pascalandy

Yes, it would be a 1-to-1. The other option would be to replace layer 7 reverse proxy (Traefik) with something that can do both DNS routing and caching... like nginx... but I feel like that's harder to get right.

BretFisher avatar Nov 15 '18 18:11 BretFisher

Thanks for your input on this :) BTW, I'll will not replace Traefik anytime soon :-p

pascalandy avatar Nov 15 '18 19:11 pascalandy

I'm not very knowledgeable with Caddy, but it sounds like an elegant solution

  • https://github.com/caddyserver/examples/tree/master/ghost
  • https://caddyserver.com/docs/http.cache

pascalandy avatar Nov 21 '18 16:11 pascalandy