CDN
Available on builds with
cdnfeature enabled.It is enabled by default so you’re probably fine.
Multi-CDN setup
This is a draft. Go ping Somobu and ask him to improve this section!
- basically you can live with a single CDN server;
- but you might want to improve media loading times / reduce server load;
- in that case you cant launch multiple
cdnmodules – preferably in different geo zones – one CDN server must haveregionset to"master"value, others could have any region names you want as long as each CDN server has unique region name assigned; - then you have to somehow append
X-Dcas-Regionheader to API requests and gateway websocket connection open request. This is typically done with a reverse proxy. The exact scheme of mapping request data to region name is up to you (see below); - api/gw would point clients to their CDNs depending on
X-Dcas-Regionrequest header; - !! you absolutely have to drop/overwrite
X-Dcas-Regionsent by client; - revers proxy is allowed to report non-existent regions, it is fine: in that case non-existent region would be mapped to a (stable-randomly picked) existing one;
Who is who:
- master CDN server:
- has region name =
"master"; - stores entire volume of media;
- handles client uploads;
- its domain/ip is hard-coded into vanilla DC client …;
- … which means that vanilla clients would also fetch small assets from it (like guild icons, app icons or avatars);
- has region name =
- slave CDN servers:
- have region name = some name (probably country code or whatever);
- each CDN must have unique region name;
- store some of the media and serve it to clients;
- fetch media on-demand;
- do not handle client uploads;
- pro tip: if you do two-cdn setup (one master, one slave), enable
prefetch_new_media(see option description for details).
Region names???
- you can use any region names you want;
- for example country codes or continent names;
- in the end, you have to somehow derive
$custom_regionstring and set it viaproxy_set_header X-Dcas-Region $custom_region;if you are using nginx, or something similar in the reverse proxy of your choice; - nginx tip: take a look at MaxMind GeoIP2;
Notes
- you might want to additionally restrict
/upload-misc/*route to be accessible by the main server only;