S
S
SlavikF2018-12-17 09:53:32
linux
SlavikF, 2018-12-17 09:53:32

Which Linux distribution to choose for hosting Apache + PHP sites?

Basically, you need to host audio recordings of conferences.
The traffic is not very large (4000 visitors per month according to GA), but the materials are about a terabyte.
For this case, there is a self-written CMS that can play these records in the right way to search, etc.
Requirements: PHP 7, Apache, MySQL.

I took a dedik on OVH (32GB RAM, 8cores), rolled Hyper-V onto it, and in it - Ubuntu 18.04 VM (8GB RAM, 3cores).
And it slows down. And it seems because of the network. One of the symptoms is that sometimes the site opens quickly, and sometimes you wait 10-20 seconds for the first page!
While I was sorting it out, I saw that I had a bunch of connections hanging in the CLOSE_WAIT state:
[email protected]:/home/slavik# netstat -tupn | grep CLOSE_WAIT
tcp 1 103452 142.44.185.104:443 213.180.203.53:58602 CLOSE_WAIT 30305 / apache2
tcp 1 99258 30937 142.44.185.104:443 213.180.203.53:39694 CLOSE_WAIT / apache2
tcp 1 142.44.185.104:443 37.9.113.126:41087 CLOSE_WAIT 29358 32766 / apache2
tcp 1 114636 142.44.185.104:443 213.180.203.53:54569 CLOSE_WAIT 30338/apache2
...
And that's not good. And there are questions about this on StackOverflow, but I did not find a solution - it looks like a problem with the Ubuntu network stack.

Well, I tried and deployed another VM, now CentOS 7 (8GB, 3 cores).
All the class works, fast, there are no CLOSE_WAIT hangings.
But in CentOS, one process constantly hangs - kswapd0, which loads one core by 100%. It seems to be related to swapping memory. I also tried everything, different settings - I didn’t overcome it, it also looks like a problem with the OS kernel.
Although at work it does not seem to be displayed - nothing seems to be slowing down, but somehow unpleasant.

Now I'm thinking - try Debian? 9.6?
Or is there some configuration that people will advise?

PS Installed Debian 9.6 + Nginx + PHP-FPM. It's been working for about a month now. Very stable.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
Boris Syomov, 2018-12-17
@kotomyava

Why do you need Hyper-V? Extra overhead out of the blue.
The distribution kit does not play a special role, in fact. The network stack is the same, only some default settings are different, but they can be completely changed.
But your problem, most likely, is not in CLOSE_WAIT, nevertheless, and not in the network stack, but in the fact that all Apache processes are busy processing existing requests, i.e. giving back your audio data. And it would be better to do it not with the help of Apache at all.

S
Saboteur, 2018-12-17
@saboteur_kiev

What's the difference: Apache or Nginx, if the problem is at the OS kernel level?

If it seems to you that the problem is at the OS kernel level, then in all Linux distributions - the Linux kernel.
It makes no sense to change the distribution, deal with your problem on the current distribution.

O
OnYourLips, 2018-12-17
@OnYourLips

Now I'm thinking - try Debian? 9.6?
We must not try, but fix the problem. Changing Ubuntu to Debian (or vice versa) is a piece of cake.

R
Roman Sokolov, 2018-12-18
@jimquery

Specifically, in my practice I encountered a problem in the apache remoteip module, but this was a very specific case. I did not see in your question a report from the Network tab of the browser. There is a TTFB parameter that can indirectly indicate which side the problem is on. It also happens that apache thinks for a long time when the processor frequency is cut, but this is more relevant for hosting. Well, the execution time of php does not hurt to measure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question