Answer the question
In order to leave comments, you need to log in
Instant file sync between 2 servers?
Have a good day everyone, I have such a problem,
there is a powerful server as much as fire but with a narrow Internet channel.
there is a second server with a p4 level processor but with a wide Internet channel.
on the first server there is a site where the main content is pictures, and the attendance is such that its entire channel is powered to death
the second server kicks the bullshit.
created a subdomain i.site.ru referring to the second server.
at the first, I figured out how to redirect requests from site.ru/images/* to i.site.ru/* at the nginx level,
now the question arises, how to keep up-to-date data between 2 servers, namely, one images directory
on site.ru by cron, a task is triggered that replenishes the catalog with pictures, what is the best thing to do so that at the same time all new pictures appear on the second server
1 thinking was to throw NFS between servers, the files will appear instantly, but they will be double work (1 when accessing a file on the second server, the second server will make a request to the first, I would like to avoid such an exchange all the time)
2 synchronization via rsync but this is also a question there is a site that received updates, received new pictures, and then synchronization with the second server began according to the picture, there will be more than 1 million files over 100,000 in half a year, and synchronization of these directories even through the picture will be quite lengthy and costly
, as a result, sometimes users will see fresh posts , and the pictures will not have time to pull up
, the dropbox will not have enough space :(
what to do? how to keep up-to-date data on 2 servers at once
I want it to be immediately ah, the files were stored immediately on 2 servers with instant synchronization
Answer the question
In order to leave comments, you need to log in
it would be more correct to immediately issue the addresses of images on i.site.ru
And why not put proxying locally on the second server in nginx (and nginx is also there, right?), And the first server as a source? Although, the question arises - only new pictures appear, or old ones can change?
Insidiously I suggest: https://code.google.com/p/lsyncd/ . How it works: we track changes using kernel functions. Synchronize when changes are found.
Sincerely,
S.
as an option.
1. we edit all the pictures on the site site.ru and give access to site.ru/images/
2. on i.site.ru - make an nginx proxy for the first site. Set a large cache size (think about the cache key) and a larger cache time. Proxy the first site site.ru
3. On site.ru/images/ — make forwarding for all IPs except i.site.ru
4. Change the mechanism for addressing pictures. At least preg_replace (ob_start), at least ngx_http_sub_module
That is, all the pictures are given are stored on the old site, publicly available from the new one, and the new one is simply a proxy for the old one.
Thus, it will synchronize "by itself". Pictures will be updated as the cache runs out. It is necessary to take care of the safety of content only on one server. Well, saving traffic. You should not fool around with something more complicated, in less than a year you will have several more servers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question