Not understading how NGINX Reverse Proxy handle image/video file

December 5, 2016 898 views
Nginx Load Balancing Ubuntu 16.04

First off, I'll explain my situation to you. I'm new to Nginx.What I know point of using load balancing/reverse proxy is to improve performance and reliability by distributing the workload across multiple servers. It work fine with dynamic/static content. But i'm not understand while it working with image/video file. Let say below is mine Nginx config file

upstream backend  {
    server backend1.example.com;
    server backend2.example.com;
    server backend3.example.com;
}    
server {
    listen   80; 

    server_name example.com; 

    location / {
        proxy_pass  http://backend;
    }
}

I'm building android/ios application which will request image by the url. Example i will request example.com/picture/image.jpg but i'm not quite understand what should i do when i request image,

I have few question here.

First while i request an image/video file, did i need to save all image into those 3 backend server?

Second if I just save it to a seperate server which only store image then what is the point of load balancing with image/video file since reverse proxy is to improve performance and reliability by distributing the workload across multiple servers?

Any help will be my life saver please help me getting out of this struggle.

1 Answer

Yes. When using this type of setup the content returned from all three backend servers should be identical so you would have to host the content in all three places. This can be accomplished either by having three servers that keep in sync with all your content, or three worker nodes that process requests but use a shared data store (NFS, object store, etc) to host the actual content. If you use a shared central location for your files the individual nodes would handle the workload of processing the request and delivering the file to the end user.

  • To add on...

    If you need more load balancing, you should use a CDN on top of your distributed contents.

Have another answer? Share your knowledge.