There is so much to know about CDN, but for now will just understand some basic concepts and how to run our site securely. On my later post I will dive deep on this. :)
CDN - Content distribution Network
Well am big fan of marvel and this is how I understood about CDN! :P
Basically there are group of Avengers (CDN Servers) that are working together to provide fastest delivery of content over an internet. But "with great powers, comes great responsibility" (ps: don't judge me !) So there are certain issues to be looked over while delivering these contents and yet keeping your site secure, also keeping your fans happy.
This is how it is done:
There are people around the globe waiting for your content to be read with quick access. Sending your content across the globe is quite tenuous, and it may be faster only to the near by region but not all over the globe! which is a grate loss for you. So, each Avengers ( CDN servers ) connect themselves to origin server, by being present on different regions of globe for maximum coverage. Then from the origin server contents are passed to Avengers, these guys keeps the data so that the people around them when in need can have quick access without any threat or buffer!
How this is achieved
- we don't love waiting. Don't we ?: Since the CDN servers are distributed such a way that they are closer to website visitors and as said they store the data sent from origin server for faster response. This is why issue of loading the content is solved, its faster for every click you want! Thus welcoming more visitors for you :)
- Isn't Bangalore traffic enough already, that you would love to encounter Network Traffic?: Request received from visitors are hell in number which leads to traffic. Hence these requests are distributed evenly among the CDN servers only to provide more space for requests and also quick responses avoiding clashes among themselves. Here concept of load balancing is applied, which is helps to keep your site awake all the time. This is truly great. :D
- CDN Severs might get tried and low ! : Incase when server gets down where all the requests go? At times like this, requests are distributed among other near by CDN servers to avoid visitors disappointment. This is called Failover, keep your site up and running.
- They provide security: This concept is pretty intense for now let's just understand in brief. Your contents are safe under CDN and have a secret passage for communication to go smooth. And how this is achieved? Understand in simple terms. Your visitors sends the request to the server. Server, then sends the acknowledgment back to visitors. Now, visitor sends the acknowledgment too, back to the server. During this phase, there is lots going behind the scene, let's stick this for now. Upon receiving the acknowledgments from both side a secret passage is opened for communication to carry on !
And this is why CDN is important !
Now coming back to hosting your site securely and implementing the CDN concept, this is how it is done.
Namecheap: This is where I bought my domain. You can buy based on your preferences.
Cloudfare: This is where I secured my website and accelerated it. Presently, you are on it reading my post :D
- Buy a domain and create an account on Cloudfare.
- Login to cloudfare, add your website. You will be provided with "nameservers"
- Login to Namecheap, click on manage icon next to the domain name you bought. You will see "Custome DNS", under it copy those Nameservers.
- Cloudfare - under DNS - click on Add Records. Here add your domain name and ip address ( which is nothing but your aws ip )
- HURRAY ! Finally its done......
I know you are still confused what just happened in those steps. Don't worry even I was. :) ... Let me be your Avenger :p
a. You had a local server and you had an AWS.
b. You installed some stuff related on local server related to aws and configured it to each other for better communication.
c. You launched an EC2 instance which is nothing but your virtual server and it has its own ip address
d. On namecheap ( any of your domains you bought ) You bought rights for your domain name and said this is mine. But you donot want to maintain it.
c. You created cloudfare account and want to maintain it here. Mainly it's FREE, provides security and fastness. So when you added the site, you were provided with "nameservers" which is only authorized in cloudfare and you would like that authority under your at everywhere. Hence you added these "namserver" under namecheap.
d. In the previous two steps you just proved and nailed your authority on your domain name. And the complete platform is setup on your vitual server (aws), remeber yet none can see it. Now its time to link your Virtual server under the cloudfare by adding the ip address of it. And by this you made your site GLOBAL!
Now go grab your coffee and if you have ANY queries mail me.
Pheww... such a big day !