504 ошибка при добавлении/обновлении нод

Главные вкладки

Аватар пользователя gruzz gruzz 21 января 2011 в 0:25

При создании/сохранении/удалении ноды, вылазит 504 ошибка nginx (где-то после минутного ожидания)
При этом в Recent log entries (drupal), messages(/var/log), mysqld.log, /var/log/nginx/error.log, /var/log/httpd/error.log ничего не добавляется
devel не помог выяснить причину.
В error.log иногда встречается PHP Fatal error: Allowed memory size of 171966464 bytes exhausted (tried to allo...) - после такой ошибки обычно увеличиваю в php.ini память.

и много такого (но не при каждой 504 ошибке):

[Thu Jan 20 22:49:28 2011] [error] [client 195.226.218.56] PHP Warning:  MySQL server has gone away\nquery: INSERT INTO watchdog\n    (uid,
type, message, variables, severity, link, location, referer, hostname, timestamp)\n    VALUES\n    (5, 'php', '%message in %f
ile on line %line.', 'a:4:{s:6:\\"%error\\";s:12:\\"user warning\\";s:8:\\"%message\\";s:84:\\"
MySQL server has gone away\\nquery: UPDATE users SET access = 1295556568 WHERE uid = 5\\";s:5:\\"%file\\";s:56:\\"/var/w
ww/tadmin/data/www/1gabba.com/includes/session.inc\\";s:5:\\"%line\\";i:75;}', 3, '', 'http://1gabba.in/n
ode/7438/edit', 'http://1gabba.in/node/7438/edit', '195.226.218.56', 1295556568) in /var/www/tadmin/data/www/1gabba
.com/includes/database.mysql.inc on line 136, referer: http://1gabba.in/node/7438/edit

Отключение модуля Database logging не помогает (пробовал отключать еще некоторые модули - не помогло)

Сайт на VPS : RAM 1.8GB CPU 750MHz
nginx/0.9.2

обычно по top как-то так:
Tasks:  34 total,   3 running,  30 sleeping,   0 stopped,   1 zombie
Cpu(s):  4.2%us,  1.6%sy,  0.0%ni, 91.1%id,  3.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1843200k total,   614752k used,  1228448k free,        0k buffers

настройки:

php.ini:
max_execution_time = 60; Maximum execution time of each script, in seconds
max_input_time = 60     ; Maximum amount of time each script may spend parsing request data
memory_limit = 164M; Maximum amount of memory a script may consume
полный: <a href="http://pastebin.com/EUfwfd80">http://pastebin.com/EUfwfd80</a>
my.cnf:
# The MySQL server
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 1M
table_cache = 512
sort_buffer_size = 521K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
net_buffer_length = 2K
thread_stack = 128K
tmp_table_size = 284MB

max_heap_table_size = 284MB
max_connections = 50
max_join_size = 1000000
sort_buffer_size = 2M
max_sort_length = 20

back-log = 20
table_cache = 1000
log-slow-queries = /var/log/mysql-slow.log
long_query_time = 1

thread_cache_size = 6
key_buffer_size = 56M
query_cache_size = 180M
myisam_sort_buffer_size = 32M
net_read_timeout = 12
net_write_timeout = 15
wait_timeout = 90
interactive_timeout = 900
long_query_time = 10
skip-innodb
skip-bdb
полный: <a href="http://pastebin.com/Xm8qy0T4">http://pastebin.com/Xm8qy0T4</a>

nginx.conf

user              nginx;
worker_processes  2;
worker_priority -4;
worker_rlimit_nofile 1000;
timer_resolution 100ms;

error_log  /dev/null;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;

#----------------------------------------------------------------------
# Events Module
#
#   http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------

events {
    worker_connections  2048;
}

#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.nginx.org/NginxHttpCoreModule
#
#----------------------------------------------------------------------

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /dev/null  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout 20;

    gzip  on;
gzip_min_length 1100;
gzip_buffers 64 8k;
gzip_comp_level 3;
gzip_http_version 1.1;
gzip_proxied any;
gzip_types text/plain application/xml application/x-javascript text/css;

        server {
                listen ip:80;
                server_name xxx.com www.xxx.com;
                root /var/www/use/data/www/xxx.com;
                charset utf-8;
                client_max_body_size 4m;
                error_page 404 = [user=fallback]fallback[/user];
                location ~ /\.ht {
                       deny  all;
                       }
                location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
                        proxy_pass http://in:8080;
                        proxy_redirect http://xx.com:8080/ /;
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header X-Real-IP $remote_addr;
                }
                location / {
                        proxy_pass http://ip:8080;
                        proxy_redirect http://xxx.com:8080/ /;
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header X-Real-IP $remote_addr;
                }
                location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ {
                        access_log /var/www/httpd-logs/xxx.com.access.log ;
                        access_log /var/www/nginx-logs/user isp;
                        log_not_found off;
                        expires max;
                }
                location [user=fallback]fallback[/user] {
                        proxy_pass http://ip:8080;
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header X-Real-IP $remote_addr;
                }
        }

httpd.conf

<IfModule prefork.c>
StartServers       4
MinSpareServers    4
MaxSpareServers   6
ServerLimit      40
MaxClients       40
MaxRequestsPerChild  100
</IfModule>

полный: <a href="http://pastebin.com/2WKg8zv9">http://pastebin.com/2WKg8zv9</a>

mysqltuner:

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.91-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated -InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 228M (Tables: 219)
[!!] Total fragmented tables: 14

-------- Performance Metrics -------------------------------------------------
[--] Up for: 7h 58m 23s (2M q [72.835 qps], 101K conn, TX: 12B, RX: 650M)
[--] Reads / Writes: 77% / 23%
[--] Total buffers: 550.0M global + 3.0M per thread (50 max threads)
[OK] Maximum possible memory usage: 700.0M (38% of installed RAM)
[OK] Slow queries: 0% (3/2M)
[OK] Highest usage of available connections: 50% (25/50)
[OK] Key buffer size / total MyISAM indexes: 56.0M/55.2M
[OK] Key buffer hit rate: 99.9% (21M cached / 17K reads)
[OK] Query cache efficiency: 76.0% (1M cached / 1M selects)
[!!] Query cache prunes per day: 27241
[OK] Sorts requiring temporary tables: 0% (232 temp sorts / 34K sorts)
[!!] Temporary tables created on disk: 45% (21K on disk / 46K total)
[OK] Thread cache hit rate: 99% (320 created / 101K connections)
[OK] Table cache hit rate: 97% (207 open / 213 opened)
[OK] Open file limit used: 16% (346/2K)
[OK] Table locks acquired immediately: 99% (646K immediate / 646K locks)

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Increasing the query_cache size over 128M may reduce performance
    Temporary table size is already large - reduce result set size
    Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
    query_cache_size (> 200M) [see warning above]

установленные модули:

Boost (boost)
Content (content)
Content Copy (content_copy)
Content Permissions (content_permissions)
Editablefields (editablefields)
Fieldgroup (fieldgroup)
Node Reference (nodereference)
Number (number)
Option Widgets (optionwidgets)
Text (text)
User Reference (userreference)
Flexifilter (flexifilter)
Block user messages (pm_block_user)
Private messages (privatemsg)
Privatemsg Email Notification (pm_email_notify)
Privatemsg filter (privatemsg_filter)
Anonymous Comment (anonymous_comment)
Better Formats (better_formats)
Comment Publish (comment_publish)
Comment RSS (commentrss)
Comment subjects (comment_subject)
Filter By Node Type (filterbynodetype)
Form Defaults (formdefaults)
Google CSE (google_cse)
Integrated Metatags (int_meta)
Integrated Metatags - CCK (int_meta_cck)
Jump (jump)
LiveJournal crossposter (ljxp)
Modr8 (modr8)
Path redirect (path_redirect)
Slashcomments (slashcomments)
Taxonomy List (taxonomy_list)
Token (token)
Token actions (token_actions)
TokenSTARTER (tokenSTARTER)
CAPTCHA (captcha)
Image CAPTCHA (image_captcha)
Cloud Menu (tf_cloud)
Context Menu (tf_context)
Count Results (tf_count)
Dynamic Tree Menu (tf_dynamic)
Multi Term (tf_multi)
Taxonomy Filter Core (taxonomy_filter)
Theme Editor (theme_editor)
Ajax Load (ajax_load)
Minimax pager (drpager)
Better Exposed Filters (better_exposed_filters)
Bonus: Paged Feed (views_bonus_paged_feed)
Bonus: Views Export (views_bonus_export)
Views (views)
Views Bulk Operations (views_bulk_operations)
Views exporter (views_export)
Views UI (views_ui)
Fivestar (fivestar)
Voting API (votingapi)
XML sitemap (xmlsitemap)
XML sitemap engines (xmlsitemap_engines)
XML sitemap node (xmlsitemap_node)
XML sitemap taxonomy (xmlsitemap_taxonomy)
Abarre (abarre)

Сайт на 95% для анонимусов, зарегеных пользователей максимум 4 одновременно иногда бывает.
По google analytics 1500 уников (Absolute Unique Visitors), 6200 Visits, 27000 просмотров (Pageviews) в сутки

Помогите, подскажите где/что рыть, с друпалом давно, но на VPS впервые, на шаред-хостинге проблем не было.
Если надо еще какие-то данные - пишите выложу.
Заранее благодарен.

Комментарии

Аватар пользователя gruzz gruzz 21 января 2011 в 20:28

увеличил с 1000 до 16384 worker_rlimit_nofile в nginx - без изменений
сделал ulimit -n 100000 - без изменений
включил LogLevel debug
появились сообщения в логах:
редко:
[info] [client 195.226.218.56] (32)Broken pipe: core_output_filter: writing data to the network
каждые несколько секунд:
[Fri Jan 21 19:23:50 2011] [debug] mod_headers.c(756): headers: ap_headers_output_filter()

Аватар пользователя Shi3A Shi3A 16 марта 2012 в 9:34

Подпишусь, проблема похожая, борюсь уже с неделю, заметил, что во время вылезания ошибки друпал пытается вставить в кеш свои данные, образуется очередь запросов.

Аватар пользователя Shi3A Shi3A 17 марта 2012 в 11:43

Частично облегчил добавление/обновление путем перевода некоторых таблиц с MyISAM на Innodb (кеши, watchdog, accesslog и некоторых прочих, в который было за 30к записей)
Но все равно добавление происходит от 2 сеукнд до 50 в среднем.

Аватар пользователя Shi3A Shi3A 11 апреля 2012 в 20:42

Помогло отключение кеша в настройках mysql
query_cache_type = off
query_cache_size = 0
Строчки должны быть равносильными, судя по описанию, я лично пользуюсь только первой.
Запросы каждый раз перестраивали кеш, что только вредило. Сейчас стою перед выбором - забить и радоваться или все же покопаться в этих запросах (стандартные друпаловские), чтобы исправить.