V
V
Vitaly Musin2016-03-13 14:39:17
linux
Vitaly Musin, 2016-03-13 14:39:17

How to organize the return of images from the CDN on the LEMP server only if the site is under heavy load?

There is a site that lives on a LEMP server (Linux, Nginx, MySQL, Php) the main content is pictures, with a heavy load of ~ 2000 thousand people on the site, the server cannot cope with the return of statics, so the pictures are placed on CDN. But CDN eats money, and 80% of the time the site is not loaded. It is necessary to make sure that during these 80% of the time the statics are returned from the main server, and when the load happens, images from the CDN are automatically returned. Any ideas?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
look2009, 2016-03-13
@look2009

Calculate PHPSESSID within 20 minutes and if more than 1500 use CDN.

L
lubezniy, 2016-03-13
@lubezniy

Alternatively, periodically count connections with netstat; when a certain amount is exceeded, turn on cdn, and when the indicator decreases slightly below the limit, transfer the return back. And dns also has a cache, so it's not an option.

V
Valery Ryaboshapko, 2016-03-14
@valerium

Alternatively, when the load increases, you can replace the nginx config so that it gives the 307th (temporary) redirect to the CDN for static requests. This will eat up some of the benefits of a CDN (one extra request) but won't require you to break the HTML cache. But in general, the decision is controversial, IMHO it's better to change the URL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question