Skip to content

Instantly share code, notes, and snippets.

@JohnBat26
Created December 12, 2011 08:33
Show Gist options
  • Save JohnBat26/1465931 to your computer and use it in GitHub Desktop.
Save JohnBat26/1465931 to your computer and use it in GitHub Desktop.
NGINX + COMET problems part 2 ...
We have problem with nginx-push-stream-module. After about 10 days of work start to appear messages in nginx error.log:
2011/10/31 04:07:53 [crit] 28137#0: ngx_slab_alloc() failed: no memory
2011/10/31 04:07:53 [crit] 28137#0: ngx_slab_alloc() failed: no memory
2011/10/31 04:07:53 [crit] 28137#0: ngx_slab_alloc() failed: no memory
2011/10/31 04:07:53 [crit] 28137#0: ngx_slab_alloc() failed: no memory
And the nginx-push-stream-module stop work.
Version of nginx-push-stream-module: 0.2.5.
Version of nginx: 1.1.1
/usr/sbin/nginx -V
nginx: nginx version: nginx/1.1.1
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
nginx: TLS SNI support disabled
nginx: configure arguments: --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-http_secure_link_module --with-http_random_index_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-debug --with-mail --with-mail_ssl_module --with-cc-opt='-O2 -g -m64 -mtune=generic' --with-ipv6 --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx-upstream-fair --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx-upload-progress-module --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/mod_zip-1.1.6 --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx_upload_module-2.2.0 --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx_mod_h264_streaming-2.2.7 --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx-push-stream-module --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx_upstream_hash-0.3.1 --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/ngx_http_consistent_hash --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/nginx-memcached-hash-pass --add-module=/usr/src/redhat/BUILD/nginx-1.1.1/ngx_http_upstream_keepalive-2ee28064a04a
Part of nginx.conf:
========================================
user nginx;
worker_processes 4;
timer_resolution 100ms;
worker_rlimit_nofile 1000000;
worker_priority -5;
error_log /var/log/nginx/error.log crit;
pid /var/run/nginx.pid;
events {
worker_connections 100000;
use epoll;
}
http {
server_tokens off;
include mime.types;
default_type application/x-javascript;
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 /var/log/nginx/access.log main;
access_log off;
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
gzip on;
#gzip_static on;
gzip_min_length 640;
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;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
output_buffers 32 512k;
sendfile_max_chunk 128k;
postpone_output 1460;
server_names_hash_bucket_size 64;
client_max_body_size 15m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#timeouts
keepalive_timeout 45 45;
client_header_timeout 45;
client_body_timeout 45;
send_timeout 45;
reset_timedout_connection on;
memcached_connect_timeout 3;
memcached_read_timeout 20;
memcached_send_timeout 20;
#timeouts end
#maximum amount of memory the push module is allowed to use
#for buffering and stuff
push_stream_max_reserved_memory 100M; #default is 32M
#limitation connetion from single IP
#limit_zone one $binary_remote_addr 10m;
#limit_conn one 8;
}
server {
listen 80;
server_name_in_redirect off;
server_name x.x.x.x;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 10m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log /var/log/nginx/nginx.log main;
access_log off;
log_not_found off;
root /var/spool/nginx/;
location /channels_stats {
# activate channels statistics mode for this location
push_stream_channels_statistics;
# query string based channel id
set $push_stream_channel_id $arg_id;
}
location /app/v1/informing/pub {
# activate publisher mode for this location
push_stream_publisher;
# query string based channel id
set $push_stream_channel_id $arg_id;
# message template
#push_stream_message_template "<script>p(~id~,'~channel~','~text~');</script>";
# store messages
push_stream_store_messages off;
# max messages to store in memory
#push_stream_max_message_buffer_length 20;
# message ttl
# push_stream_min_message_buffer_timeout 5m;
push_stream_max_channel_id_length 200;
# client_max_body_size MUST be equal to client_body_buffer_size or
# you will be sorry.
client_max_body_size 32k;
client_body_buffer_size 32k;
}
location ~/app/v1/informing/sub/(.*) {
# activate subscriber mode for this location
push_stream_subscriber;
# positional channel path
set $push_stream_channels_path $1;
push_stream_max_channel_id_length 200;
# header to be sent when receiving new subscriber connection
#push_stream_header_template "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta http-equiv=\"Cache-Control\" content=\"no-store\">\r\n<meta http-equiv=\"Cache-Control\" content=\"no-cache\">\r\n<meta http-equiv=\"Pragma\" content=\"no-cache\">\r\n<meta http-equiv=\"Expires\" content=\"Thu, 1 Jan 1970 00:00:00 GMT\">\r\n<script type=\"text/javascript\">\r\nwindow.onError = null;\r\ndocument.domain = 'localhost';\r\nparent.PushStream.register(this);\r\n</script>\r\n</head>\r\n<body onload=\"try { parent.PushStream.reset(this) } catch (e) {}\">";
# message template
#push_stream_message_template "<script>p(~id~,'~channel~','~text~');</script>";
push_stream_message_template "~text~";
# content-type
push_stream_content_type "application/x-javascript; charset=utf-8";
# subscriber may create channels on demand or only authorized
# (publisher) may do it?
push_stream_authorized_channels_only off;
# ping frequency
#push_stream_ping_message_interval 10s;
# connection ttl to enable recycle
push_stream_subscriber_connection_timeout 15m;
#push_stream_broadcast_channel_prefix "broad_";
#push_stream_broadcast_channel_max_qtd 3;
}
.....
}
================================
In front of tne nginx there is a load balancer - HAproxy.
Why push_stream_module has memory leak in this situation ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment