I am having trouble understanding a part of file storage system in a server architecture and CDN.
This is my environment:
1.) 1 nginx load balancer
2.) 2 node.js express.js web servers
3.) 1 mongodb database
4.) 1 CDN
What I am trying to do?
I am trying to implement a feature where my client can upload there profile picture and their product's images to my server. I researched for best practices and I found out that saving upload files to a CDN work best.
What I understand so far?
I understand that as in load balanced environment, I need to separate media files in a different server. However, it is confusing to me how the flowing of data works. ( I'm not asking about how to implement this for my node.js express.js , I'm just asking about the concept of data flow )
What I don't understand?
My questions are:
1.0) Do I need to also save those images on my web server?
1.1) If so (1.0), Do I need 1 more web server to my stack to save all images uploaded from user in order for the CDN to load from that server?
2.) How should the data flow when the user start uploading their images?
These are some steps I am so confused
step 1: user choose file to upload
step 2: the data upload to ....
step 3: server upload to CDN ?
or should the user upload right into CDN server
Thankyou very much ! :)
If I'm too late please let me know what approach you took. One approach i tried was:
With this approach, user can see image immediately with uploaded file size and later once we upload our resized file we use that.