N
N
Nikita2015-01-19 23:58:23
Nginx
Nikita, 2015-01-19 23:58:23

Horizontal nginx static scaling?

Given: nginx server that stores statics - GIFs (1-20mb). There are 10 subdomains (img1.,img2. and so on).
Nginx on Ubuntu, Ubuntu on DigitalOcean. GIFs are streaming from the app via ssh.
In fact, now the instance rests on disk space and for now I want to do everything on a budget, that is, it is desirable to simply copy the instances.
Question: what is the easiest way to scale nginx and how to upload files to servers? Are there any well-established schemes? There are a couple of ideas, tell me which of them are correct:
1) put a balancer in front of 2+ instances and duplicate the content on all servers (through some kind of lsynd?).
2) write an instruction in the incoming nginx to search for files in other instances if there is none on the requested one? Here the point of failure is confusing in the form of the "main" nginx at the entrance.
3) at the moment, 10 subdomains are filled under URLs for gifs. Just take and gradually migrate them to different servers with parallel ip substitution? Manual version, not really like it.
4) just take a bigger disk and more memory and not worry? I don’t want to, because the project is more for learning and I still want to somehow scale it up to several instances.
Thanks in advance for the advice, while this is a dark forest for me.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Eugene, 2015-01-20
@Nigrimmist

The most normal option is sharding, that is, the number of the server on which we pour the picture in case of 10 servers will be n = (id % 10 + 1), while doing cross backups so that if something falls, distribute it from other servers.

S
Sergey, 2015-01-20
Protko @Fesor

If you have a lot of gifs, I recommend that you also think about how to convert them to html5 videos (webp, etc.). It is very annoying that gifs take a long time to load, and gfycat does not work very fast.

V
Vlad Zhivotnev, 2015-01-20
@inkvizitor68sl

> 3) at the moment, 10 subdomains are filled under urls for gifs. Just take and gradually migrate them to different servers with parallel ip substitution? Manual version, not really like it.
But the simplest (and in your case - working).
In general, instead of 404, you can make a 301 redirect to neighboring servers (sharded by subdomains) + proxy_store/proxy_cache for especially popular pictures (so that they are everywhere).

I
index0h, 2015-01-20
@index0h

gravefs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question