Mysql too many connections

Вариант А
В случае медленных запросов, оптимизируем их, добавляем индексы и т.д.

Вариант Б
Одновременные соединения. В этом случае распределяем их на разное время запуска, чтобы они были выполнены не в одинаковое время. Т.е. убрать вот такие варианты:

1
2
3
4
$otime = date('i');
while ( true ) {
if ( $otime != date('i') ) { mysql_query('SELECT 1'); $otime = date('i'); }
}

А может быть оптимизация кода Вам не подойдет, тогда можно увеличить кол-во одновременных подключений. Это делается в файле конфигурации mysql, а именно /etc/my.cnf, вот в этой строчке:

1
max_connections = 250

Стандартное значение после установки 100. После внесения изменений, нужно рестартануть демона mysqld, делается это командой:

1
/etc/init.d/mysqld restart

и теперь можно проверить, все ли ок, sql запросом:

1
SHOW VARIABLES LIKE 'max_connections'

Вот и всё. Не забывайте делать резервные копии перед внесением изменений в конфигурационные файлы!

Mysql too many connections

3 мыслей о “Mysql too many connections

  • 12.03.2024 в 17:51
    Permalink

    Wow, incredible blog structure! How long have you ever been blogging for?
    you made running a blog glance easy. The full glance of your
    web site is fantastic, as well as the content material!
    You can see similar here ecommerce

  • 13.03.2024 в 01:08
    Permalink

    Today, I went to the beach with my children. I found a sea shell and gave
    it to my 4 year old daughter and said «You can hear the ocean if you put this to your ear.» She put the shell to her ear and screamed.

    There was a hermit crab inside and it pinched her ear. She never
    wants to go back! LoL I know this is entirely off topic but I had to tell
    someone! I saw similar here: Dobry sklep

  • 14.03.2024 в 16:23
    Permalink

    If you wish for to obtain a good deal from this article
    then you have to apply these strategies to your won web site.
    I saw similar here: Najlepszy sklep

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *