I'm having serious performance problems with Httpd on dedicated server. In traffic peaks httpd stucks on 512 connections and without any reason all connections are slow and files which are downloading are dropped with message: (btw. its high traffic server)

upstream prematurely closed connection while reading response header

Also worker connections are on the max with all params.

See below:

enter image description here

I have also tried to restart the server and change a config to max with tcp optimization and db, but it doesn't solve anything.

The queries log doesn't give any extra information. Could you please advice me how to fix or optimize that?

This throttling starts only with traffic peaks. Database runs on mariadb , Here is config for httpd:

<IfModule prefork.c>
   StartServers        3
   MinSpareServers     20
   MaxSpareServers     40
   ServerLimit         256
   MaxClients          256
   MaxRequestsPerChild 500

Also I noticed that a lot of httpd processes are created.

I have max_connections on 1000, for table I use caching memcache, also with config on my.cf:

  • table_open_cache = 256
  • thread_cache_size = 12
  • check table cache and see if other limits are reached. – danblack Apr 24 at 1:26

I beg to differ. A high max_connections can cause a problem. Here's the general picture:

When there are more than a few dozen database connections actively trying to perform SELECTs, etc, they contend for various resources -- mutexes, cpu, I/O, and various 'shared' things in the database server.

At that point, mysqld tries to be fair, giving each connection a share of the resources. This leads to each one taking longer and longer because it is held up waiting for one thing after another.

It is better to throttle the connections in the client. This way the connections that are "running" can run faster will less blockage and get out of the way.

When the blockage starts, it stays for some time. The number of "queries per second" stops growing. But the "latency" (how long it takes to finish the task) goes through the roof. This clogging backs up into the client (httpd).

Connection pooling does nothing to limit the number of connections that are vying for resources.

Memcached is a cache in front of a cache; it may or may not be aggregaving the situation. It is quite likely to be hurting if it is on the same server as the other pieces -- Memcached needs ram and CPU, thereby taking some of those resources away from mysqld.

Try max_connections = 200 and limit the number of children of httpd to that number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.