Create own CDN for WordPress with REDIS caching?


#1

Hi,

I would like to tackle a new project for my server setup.

I wish to create another droplet as a CDN for my static files.

I am running a WordPress site with REDIS cache configured through EE.

Anyone have any ideas etc or even if it’s possible with REDIS currently.

I can I sync my static files and rewrite host to my CDN?

Thanks


Best WordPress setup? FastCGI, HHVM (PHP5 Backup), Pagespeed?
#2

I would image it would be cheaper and easier to use something like KeyCDN to host your static files. No syncing required as you would have a domain (like cdn.example.com) pointing to KeyCDN which then points back to your server (like example.com). When a request goes through KeyCDN it sees if it has a copy and then serves the file. Otherwise it fetches the file from your server and caches it for future requests.


#3

Hey.

Thanks for your input. How does KeyCDN differ from other CDNs.

I mean I could go down that avenue. Problem is there isn’t any CDN I can find that had more than 1 server in Australia. I don’t need to cover the world just Australia.

I thought it would also be a bit of fun playing with a CDN also. From what I can see if I only want to make anger server to parralel download static assents then all I need to do is setup rsync and on my Wordpress server rewrite static content URL to my other server. This can be done using some caching plugins however I am using REDIS so complicated this for me.

Thanks.


#4

They’ve got a POP in Sydney --> https://www.keycdn.com/network They’re pay as you go, and only $0.04 per gigabyte. I’m really happy with them.

It sounds like serving your site via HTTP2 and SSL/TLS will accomplish what you’re trying to do. EasyEngine supports these out of the box. See https://easyengine.io/docs/commands/site/create/#enablessl-using-lets-encrypt

And here is a good read on why you should care about HTTP2 https://www.keycdn.com/blog/http2-cdn/


#5

I will add, to create a CDN, you will need at least 4 droplets, but also a geo ip-routing to deliver the content from the nearest server for your visitors.

But before using a CDN you should try Cloudflare. look : ->


#6

Hi,

Sorry I was more thinking a parallel host rather than CDN. sorry. So I can host images and css, js etc on another server. therefore will only need 2 servers.


#7

Yes but it will not make your website faster. For that you have the Cloudflare solution which is free, to cache your files by acting as proxy. Or the CDN like keycdn which will deliver your assets all around the world.

But if you have only small assets like some css and js, try cloudflare, it will already make a good boost.


#8

Hey,

Yes, I have used them before and didn’t find they helped. I don’t need a full blown CDN as I am only targeting 1 county. I just want to get the best performance for that country.

I might give cloudflare a go again and see.

The only reason I was thinking of splitting up the servers was I can use a server closer to home for the images and it would reduce server load.


#9

If you haven’t an huge traffic, the server load with EE should be around 1% :relaxed: But with cloudflare, you can use the pages rules to cache as much as possible the assets. Use a page rule like

with cache level -> cache everything browser TTL -> 1 month or more

And wait few hours, each visitors will create the cloudflare cache

Edit : you could also try Linode which is faster than DO


#10

Just have in mind that another server to serve your images would add another TTFB, which is usually around 100ms to 300ms just to serve images. it’s fine if you have a lot of images, but too much if it’s only a few.

I am using MaxCDN in conjunction with Cloudflare Free Plan and was able to reduce my loading time from 1s to under 600ms that way.

I have 3 cnames on MaxCDN: cdn.domain.com, cd1.domain.com and cdn2.domain.com.

I use cdn.domain.com to serve images, cdn1 to serve CSS and cdn2 to serve JS.

Cloudflare is my DNS Provider and also serves HTML. this way, very little is actually served from my server.


#11

Remember also than if you are using http2, domain sharding is not needed anymore and you should avoid to make useless DNS requests


#12

That’s some great info, thanks. I will read some more on that.

But I am using http2 and domain sharding definitely helped.


#13

Thanks for the info also.

Ok other than using a CDN what would be the next step in increasing performance. Mainly TTFB.

Would having another server for the database help with this?

I am quite happy with my setup however want to learn more and dig a little deeper.

Also has anyone had experience using a separate caching server sitting in front such as Varnish or NGINX FastCGI-cache. How does something like that compare to a REDIS setup on the same server?

Yeah I thought be providing my images from another server would help increase page load not so much TTFB. I will look into cloudflare and others as well. But I do want to play with server stuff a little more before adding the CDN in. As my site is only targeting 1 country.

Thanks


#14

If you want to have better performances, you can use mariadb & redis in a docker container. You should also add HSTS rules with your https to reduce the impact of ssl handshake.

It depend if you are looking for a page caching or if you need to keep the website dynamic for Nginx FastCGI-cache. But Cloudflare will have the biggest impact on your TTFB because the DNS are really faster than most of the other providers.

here my results : http://prnt.sc/c64f7s


#15