Nahodne zabijeni procesu apache

Jan Jurák yan.jurak at gmail.com
Sun May 22 08:58:46 CEST 2022


aha tak tohle si asi poznamenam.

nginx je eventovej celkove, taky by pomohlo asi prohodit tu revers proxy:

(optionaly: kdyz to overis, zasilam kvetiny obratem)

at to mas lehci:

1.

grep -Evx '[[:blank:]]*([#;].*)?' /usr/local/etc/nginx/nginx.conf
user www;
load_module /usr/local/libexec/nginx/ngx_stream_module.so;
worker_processes  2;
pid /var/run/nginx.pid;
events {
        worker_connections 2048;
  use kqueue;
}
http {
  include /usr/local/etc/nginx/mime.types;
  default_type application/octet-stream;
  access_log /var/log/nginx/access;
  error_log /var/log/nginx/error;
  charset utf-8;
  source_charset utf-8;
        sendfile        on;
        keepalive_timeout  65;
  gzip off;
  gzip_http_version 1.1;
  gzip_comp_level 6;
  gzip_proxied any;
  gzip_min_length  1100;
  gzip_buffers 16 8k;
  gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xml+rss text/javascript image/gif
image/jpeg image/png application/json image/svg+xml;
        types { text/plain log; }
        variables_hash_max_size 2048;
  client_max_body_size 10000m;
        limit_req_zone $binary_remote_addr
zone=brute_force_protect:10m rate=1r/s;
        include /usr/local/etc/nginx/sites-enabled/*;
}
stream {
  include /usr/local/etc/nginx/conf.stream.d/*;
  include /usr/local/etc/nginx/streams-enabled/*;

2.

grep -Evx '[[:blank:]]*([#;].*)?'
/usr/local/etc/nginx/sites-enabled/nette-test-app.blamaz.cz
upstream nette-test-app_upstream { server
unix:/var/run/php-fpm/nette-test-app.socket; }
server {
        server_name nette-test-app.blamaz.cz nette-test-app;
        listen 80;
        access_log /var/log/nginx/nette-test-app-access;
        error_log /var/log/nginx/nette-test-app-error;
        autoindex off;
        root /datapool/www/netteapps/nette-test-app/www;
        include /usr/local/etc/nginx/conf_d/common_nette.conf;
        include /usr/local/etc/nginx/conf_d/php_nette.conf;
        include /usr/local/etc/nginx/conf_d/nette_nette.conf;
        index index.php;
        include /usr/local/etc/nginx/conf_d/drop_location;
        include /usr/local/etc/nginx/conf_d/error_pages;
}

3 sem zjevne prehnal ty inludy :(

grep -Evx '[[:blank:]]*([#;].*)?' /usr/local/etc/nginx/conf_d/common_nette.conf
index index.html index.htm;
server_tokens off;
client_max_body_size 16m;
client_body_buffer_size 128k;
location ~ /\.|^\. {
        deny all;
}
location ~* \.(jpe?g|gif|png|css|js|ico|xml)$ {
        access_log off;
        log_not_found off;
        expires max;
}
location ~ \.combined\.(js|css)$ {
        ssi on;
        ssi_types text/css text/javascript application/x-javascript;
}

4. tohle je podstatna cast

grep -Evx '[[:blank:]]*([#;].*)?' /usr/local/etc/nginx/conf_d/php_nette.conf
index index.php index.html index.htm;
location ~ \.php$ {
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_keep_conn on;
        fastcgi_pass nette-test-app_upstream;
}

5. taky

grep -Evx '[[:blank:]]*([#;].*)?' /usr/local/etc/nginx/conf_d/nette_nette.conf
location / { try_files $uri $uri/ index.php$is_args$args; }

jiny nete (tam bude obsolete ssl) ale muze pomoct

grep -Evx '[[:blank:]]*([#;].*)?'
/usr/local/etc/nginx/sites-available/intranetadm
upstream adminer_upstream { server unix:/var/run/fpm/intranetadm.socket; }
server { listen 80; server_name intranetadm.datapool.cz intranetadm;
return 301 https://intranetadm$request_uri; }
server { listen 443 ssl http2; server_name intranetadm.datapool.cz;
return 301 https://intranetadm$request_uri; }
server {
        listen 443 default_server ssl http2;
        server_name intranetadm;
        access_log /var/log/nginx/intranetadm-access;
        error_log /var/log/nginx/intranetadm-error;
        ssl_certificate /datapool/auth/ssl/nginx/intranetadm_chained.crt;
        ssl_certificate_key /datapool/auth/ssl/nginx/private/intranetadm.key;
        add_header Strict-Transport-Security "max-age=63072000;
includeSubdomains";
        autoindex off;
        root /datapool/www/adminer;
        index index.html;
        include /usr/local/etc/nginx/conf_d/ssl;
        include /usr/local/etc/nginx/conf_d/drop_location;
        location / { index index.php; try_files $uri $uri/ /index.php?$args; }
        location ~ \.php$ {
                try_files $uri =404;
                include /usr/local/etc/nginx/conf_d/proxy;
                include fastcgi_params;
                fastcgi_param HTTPS on;
                fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
                fastcgi_index index.php;
                add_header Front-End-Https on;
                fastcgi_pass adminer_upstream;
        }
        include /usr/local/etc/nginx/conf_d/error_pages;
}

jiny headery

grep -Evx '[[:blank:]]*([#;].*)?' /usr/local/etc/nginx/conf_d/proxy
                proxy_http_version 1.1;
                proxy_redirect off;
                client_body_buffer_size 128k;
                proxy_send_timeout 240s;
                proxy_read_timeout 240s;
                proxy_connect_timeout 59s;
                proxy_buffer_size 64k;
                proxy_buffers 16 32k;
                proxy_busy_buffers_size 64k;
                proxy_temp_file_write_size 64k;
                proxy_pass_header Set-Cookie;
                proxy_hide_header Vary;
                proxy_ignore_headers Cache-Control Expires;
                proxy_set_header Accept-Encoding '';
                proxy_set_header Referer $http_referer;
                proxy_set_header Host $host;
                proxy_set_header Cookie $http_cookie;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

a tady je priklad na toho uzivatele separe:

grep -Evx '[[:blank:]]*([#;].*)?' mamo.conf
[mamo]
listen = /var/run/fpm/mamo.socket
listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode=0660
user = b29189
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 400
request_terminate_timeout = 0
request_slowlog_timeout = 0
slowlog = /var/log/fpm/mamo-slow
env[HOSTNAME] = mamo.bulovka.cz
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

na test staci napsat cestu k socketu tu a v nginx upstreamu

----


ok, dobre o apachovi vedet....


ahoj

Many Regards
Jan Jurák

On Thu, Apr 14, 2022 at 12:30 PM Martin Stachura <martin.stachura at osu.cz> wrote:
>
> Prehozeni MPM Event na MPM Prefork pomohlo. Dekuji.
>
> Na trech servery s Apache (MPM event) + mod_php (ZTS), po přehozeni na
> MPM prefork hlasky zmizely. A na jednom serveru mam Apache (MPM event) +
> php-fpm, tam se objevuji hlasky zridka (od noveho roku 8 hlasek).
>
> Ted kdyz vim, čim to je, tak jsem patral:
> Na php.net doporucuji vubec nepouzivat pro UNIX systemy Apache s
> vlaknovym MPM, kdyz tak Apache MPM event + FastCGI (PHP-FPM):
> - https://www.php.net/manual/en/install.unix.apache2.php
> -
> https://www.php.net/manual/en/faq.installation.php#faq.installation.apache2
>
> HTTP2 nepodporuje MPM prefork:
> -
> https://docs.freebsd.org/en/books/handbook/network-servers/#_http2_support
>
> A pouzivani mod_php (ZTS) s Apache MPM event jsou hlaseny potize:
> -
> https://blog.remirepo.net/post/2017/11/17/Fedora-27-changes-in-http-and-php
> - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254752
>
> >> a apache je neumi znovu vytvorit
> > To je problem [B]
> >
> > Problemy A a B mohou, ale nemusi, mit spolecnou pricinu.
> >
> >
> Zkoušel jsem si přes kill -10 zabijet procesy apache (MPM Event +
> mod_php ZTS), a vzdy se mi po prekroceni minimalni hodnoty
> (MinSpareThreads vs. pocet procesu * ThreadsPerChild) zase vytvorily
> nove procesy. Nyni u tech serveru s Apache MPM prefork to zatim vypada
> dobre, a toho posledniho serveru s Apache MPM Event + PHP-FPM tam to
> budu sledovat. Pro info: hned jak jsem zjistil, ze apache po zabiti
> nevytvoril nove procesy, tak jsem si udelal skript, ktery mi to hlidal a
> kdyz pocet procesu byl 3 a min tak reloadnul apache, zde prehled logu,
> jak se to chovalo:
>
> 20220316 14:28:00 - ok - 5
> 20220316 14:30:00 - ok - 4
> 20220316 14:32:00 - ok - 4
> 20220316 14:34:00 - error - 2
> 20220316 14:36:00 - ok - 8
> 20220316 14:38:00 - ok - 8
>
> 20220329 21:48:00 - ok - 4
> 20220329 21:50:00 - ok - 4
> 20220329 21:52:00 - error - 3
> 20220329 21:54:00 - ok - 8
> 20220329 21:56:00 - ok - 8
>
> <IfModule mpm_event_module>
>      StartServers             8
>      MinSpareThreads        120
>      MaxSpareThreads        420
>      ThreadsPerChild         35
>      MaxRequestWorkers      1050
>      MaxConnectionsPerChild   0
>      ServerLimit                30
> </IfModule>
> --
> FreeBSD mailing list (users-l at freebsd.cz)
> http://www.freebsd.cz/listserv/listinfo/users-l



More information about the Users-l mailing list