: How should I set up and use a CDN for my web application? I plan to create and run my own CDN. Currently, media and other static content is being served by the web-servers which are behind
I plan to create and run my own CDN. Currently, media and other static content is being served by the web-servers which are behind a load balancer which is a waste of resources. The network structure of my web application (with the CDN) will be as follows:
1 load balancer node for the web servers (nginx)
3 web server nodes (apache, php)
2 database nodes (mysql)
1 load balancer node for the CDN (nginx)
3 CDN storage nodes (apache, php)
How could I transfer files to the CDN from the nodes which generate media? For example image processing after file uploads.
More posts by @Radia820
A content delivery network works as a proxy server. You would have to have a canonical source for your media. The CDN servers would then contact the central canonical source for the file the first time that it is requested. After that, they would serve the cached copy that they had retrieved the first time.
Different CDNs use different schemes for the central copy of the file. One way to set it up would be to have your main web server continue to serve all the files as normal. Users would be directed to the CDN which would take most of tho load off of your main servers.
I've also seen CDN setups where static media is hosted on a server run by the CDN company. In this case you might get FTP access to that server to upload new content. The nodes that generate the media would have to use FTP to place the content on the central server to then be distributed by the CDN nodes.