I
I
Impeeeery2017-07-18 17:30:58
PHP
Impeeeery, 2017-07-18 17:30:58

Why does PHP run much slower on my VPS (results of 2 tests)?

The other day I already asked a question on this topic.
There is a long text, and not a single test.
The text is so long that no one bothered to read it and some gave answers completely out of place.
This time it will be the other way around.
I'll start with tests.
So here are 2 tests:
test_disk.php:

<?php
$starttime = microtime(true);
  file_get_contents('diskbump', true);
$endtime = microtime(true);
$timediff = $endtime - $starttime;
echo $timediff
?>

test_cpu.php:
<?php
$starttime = microtime(true);
  for ($i = 0; $i < 500000000; $i++) {
  }
$endtime = microtime(true);
$timediff = $endtime - $starttime;
echo $timediff
?>

Here are their hosted results:
http://***/test_disk.php
1.8835067749023E-5
3.4093856811523E-5
1.5974044799805E-5
1.5020370483398E-5
1.5974044799805E-5
1.7166137695
http://ctest_pu/3*** .php
5.4995031356812
6.6292271614075
11.630015850067
But the results on the VPS:
255.255.255.255/test_disk.php
3.814697265625E-5
4.5061111450195E-5
3.6001205444336E-5
3.6001205444336E-5
6.6041946411133E-5
4.0054321289062E-5
// 2-3 times longer
255.255.255.255/test_cpu.php
10.21071100235
13.526569843292
12.918704986572
// 2-2.5 times longer than the hosting average
What's the problem?
What can give such results? Hmm...

Apache settings, Internet channel, whether FastCGI or mod_php is used, and other "left" things - obviously, they can hardly affect such tests.
Is that the version of the PHP interpreter.
But she's pretty much the same.
On hosting PHP 7.0.7
On VPS - PHP 7.0.18
It is unlikely that there is a difference.
OS - on VPS Ubuntu x64, what kind of hosting - I don't know.
There is hardly any difference either.
So the problem is in the hardware.
But the fact is that on a VPS it is (in theory) even more powerful !
CPU:
on hosting (according to admins) there is a 4-core percent with a frequency of 2.2 GHz and a 30% usage limit
on VPS costs Xeon 3 cores at 3.4 GHz.
Hard disk:
I don’t know which one on hosting, but on VPS - of course, SSD.
So what's the deal?
Judging by the tests - it is in the processor, but how does the processor, interpreted on the VPS site as "powerful", turn out to be weaker than some lousy hosting?
I bought a VPS from greedy udacs and do I need to buy another VPS?
Or are all Xeons so slow and I have to look for a processor of another family, which is a rarity?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
4
4X_Pro, 2017-07-18
@XXXXPro

Batlab correctly answered above that on VDS processor resources are distributed through virtualization, and they are limited by the tariff plan, but guaranteed to each client.
On hosting, the distribution is different - all server resources can be used by all clients. Therefore, if you test hosting at a time when it is lightly loaded (say, at night from Saturday to Sunday), then the results on it will be better. But in those moments when the load from other clients grows on the hosting, the effect will be the opposite: the site will work slower than on VDS (although a lot still depends on the hoster itself).
Also, for a correct comparison, you need to take the same version of PHP both there and there (it affects synthetic tests like yours very much). And the test with the file will be strongly influenced by the disk cache.

S
Semyon Beloglazov, 2017-07-18
@Batlab

The processors on the VPS are not dedicated cores, but virtual ones (which are created through virtualization systems). Each hosting provider distributes these resources itself, so, apparently, the hosting provider has allocated more resources. That's all.

S
Sanes, 2017-07-18
@Sanes

The processor is dead or stabbed.

P
Puma Thailand, 2017-07-19
@opium

and what kind of VPS
do I have, for example, 4 nuclear xeons at 3.9 gigahertz
On hosting, I allow the use of all 4 cores without restrictions
on dead VPS, I limit the core to 1 GHz, although the processor is the same there, that is, on the VPS, in fact, the processor is about 16 times less .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question