W
W
WebDev2016-11-17 13:09:49
Nginx
WebDev, 2016-11-17 13:09:49

How much will this method load the server?

Various images are published on the site, or rather links to them. I ran into a number of problems, for example, when reposting to Twitter, not all pictures from third-party links are pulled up for various reasons.
I solved this problem like this:
1) I generate a link like mysite.ru?proxy=base64encodedurl
That is, I take a third-party link, encode it in base64 and substitute parameters in the address bar.
This request is processed on the server like this

header("Content-type: image");

    $url = base64_decode($url);

    if (getFileSize($url) > 500000) {//Если размер картинки больше 500кб, не обрабатываем
        return $url;
    }

    $handle = fopen($url, "r");

    if ($handle) {
        while (!feof($handle)) {
            $buffer = fgets($handle, 4096);

            echo $buffer;
        }

        fclose($handle);
    }

That is, the server downloads the picture and gives it.
What are the pitfalls of such a decision? Should I be worried about the extra load or will it be minimal?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bogdan Romanov, 2016-11-17
@st_scar

Why nginx theme?
To begin with, describe what kind of server, how many connections approximately? There is little information. And so I think that you need to constantly monitor the load, and then look.
PS
https://en.wikipedia.org/wiki/Load_testing

A
Andrey, 2016-11-17
@GhOsT_MZ

Why is PHP here? Isn't it easier to use error_page and proxy_pass in nginx?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question