LXC containers, socket connections

Apr 8, 2016
8
0
1
Bordeaux
Hi,

Due to a large number of queries from an application we have, based on two LXC containers on a local private network (Php/MariaDB - debian 8), we noticed more than 15000 socket connections in TIME_WAIT in few seconds.

On a recently fresh install of Proxmox 4.2, the application crashes after a while.

On an old install of Proxmox 3.4, the same process works fine till the end, or even forever (Open VZ containers)...

How can we explain this regression ?

What should be the way to manage the amount of socket connections between the two LXC containers ?
 
Hi
Which of your container is seeing these connections in TIME_WAIT states ? Is that where the php application is running ?
It might be simply that MariaDB is too busy

Are the containers running on the same host ?

Which messages does the application crashs brings ?
 
Hi,

Thank you for your answer.

Yes, the container where the php application is running is seeing these connections in TIME_WAIT.

Yes, the containers are running on the same host.

Here is the message that appears before crash :

mysqli_connect(): (HY000/2002): Cannot assign requested address

I applied a patch to limit the number of connexions to MariaDB but it slows very much the application.

But the application was running before, with good performance and without any problem, on Proxmox 3.4 / Wheezy.

Thank you again for your recommendations.

Best regards
 
Yes, the php VM run out of sockets.

But this situation is new with Proxmox 4 and LXC containers and was not the case whith Proxmox 3 ans OpenVZ.

In order to manage this problem, I have to change values in the following files :

/proc/sys/net/ipv4/tcp_tw_reuse and /proc/sys/net/ipv4/tcp_fin_timeout

But these files do not exist in the LXC container and cannot be created.

The values come from the host, probably because of the isolation.

So, what can I do ?

Thank you for your answer,

Best regards
 
Hi
If you really want to go this way, yes. you have to set this on the host system, since it's a kernel setting and the container is using the host kernel.
(NB with KVMs you could set this inside the guest system)

Now to go back to the source of your problem, what don't you configure your PHP process to reuse existant tcp connections to mysql instead of recreating a connection each time ?

Seems it should be possible with:
http://php.net/manual/en/mysqli.persistconns.php
 
Hi,

I don't want to change tcp parameters for the full host, this is not a good idea. Other TCP services are running on this host with much more VM.

I know that I could set individual tcp values if I use KVM.

I can try persistent connections but this is not the point of view of my question.

The application was working fine on Proxmox 3 and OpenVZ, and Proxmox 2 and before, and was doing the job in one hour, every night, without any problem.

No need to rewrite the code.

The application consist in parsing some XML data, selecting, inserting and updating a database. It is not so far…

With Proxmox 4, the process is quite broken : more than 6 hours to the end.

Thank you for understanding.

Best regards,
Serge
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!