CDN and Server Architecture : Picture upload feature for my web app

1.4k views Asked by At

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 ! :)

2

There are 2 answers

0
mitesh sharma On

If I'm too late please let me know what approach you took. One approach i tried was:

  1. When receive file from client on server, upload it directly on some CDN, block user till file is uploaded. i tried S3.
  2. Return response to user that file is uploaded with current url.
  3. Fire a async task where you resize your image to required size and then upload it to CDN, then update url to this new file.

With this approach, user can see image immediately with uploaded file size and later once we upload our resized file we use that.

0
Vinod On

It really depends on your requirement :) If you directly want the user to upload the images to CDN(Akamai) then you can create FTP access to them(hoping these users are less). Then they can use any software like WinScp and upload the images straight to CDN.

Then in akamai configuration you can define a rule saying for any image request go to Akamai Netstorage and server it.

To be honest before implementing this, i suggest to spend some more time on architecture design.