Sponsor:

Server and Web Integrator
Link:
Kloxo-MR logo
6.5.0 or 7.0.0
Click for "How to install"
Donation/Sponsorship:
Kloxo-MR is open-source.
Donate and or Sponsorship always welcome.
Click to:
Click Here
Please login or register. 2024-05-21, 03:09:32

Author Topic: Php-fpm  (Read 10540 times)

0 Members and 1 Guest are viewing this topic.

Offline lupetalo

  • Senior Member
  • *
  • Posts: 182
  • Karma: +0/-0
    • View Profile
Php-fpm
« on: 2012-12-28, 04:30:24 »
What is optimal template for using with large number of users (150+)? My memory always get swamped and all domains are always using some part of it...
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Php-fpm
« Reply #1 on: 2012-12-28, 19:01:33 »
Better use small users (with large domains) rather than large users (with small domains).

It's because (by default) php-fpm refer to user rather than to global or domains.

You can see setting for every user inside /etc/php-fpm.d
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline lupetalo

  • Senior Member
  • *
  • Posts: 182
  • Karma: +0/-0
    • View Profile
Re: Php-fpm
« Reply #2 on: 2012-12-28, 19:08:33 »
I know that, but question is how to optimise current situation :)
I tried lowering:
Code: [Select]
pm.max_requests = 200but it not help a lot...
Is it possible to kill those process that are not active but taking memory? I only have ~20 regulary active users at all times.
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Php-fpm
« Reply #3 on: 2012-12-28, 19:19:01 »
This is example for my modified for /home/php-fpm/tpl/custom.php53-fpm-pool.conf.tpl
Code: [Select]
<?php
    $userinfo 
posix_getpwnam($user);

    if (
$userinfo) {
        
$fpmport = (50000 $userinfo['uid']);
    } else {
        return 
false;
    }

    if (
$user == 'apache') {
        
$pool 'default';
    } else {
        
$pool $user;
    }

    if (
$user === 'riginta') {
        
$startserver '20';
        
$minspareserver '20';
        
$maxspareserver '40';
        
$maxchildren '200';
    } else {
        
$startserver '2';
        
$minspareserver '2';
        
$maxspareserver '4';
        
$maxchildren '10';
    }


?>

[<?php echo $pool?>]
listen = 127.0.0.1:<?php echo $fpmport?>

listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = <?php echo $user?>

group = <?php echo $user?>

pm = dynamic
pm.max_children = <?php echo $maxchildren?>

pm.start_servers = <?php echo $startserver?>

pm.min_spare_servers = <?php echo $minspareserver?>

pm.max_spare_servers = <?php echo $maxspareserver?>

pm.max_requests = 500
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
request_terminate_timeout = 0
request_slowlog_timeout = 0
slowlog = /var/log/php-fpm/slow.log
rlimit_files = 1024
rlimit_core = 0
;chroot =
;chdir = /var/www
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f webmaster@domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/error.log
php_admin_value[session.save_path] = /var/lib/php/session
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 64M

« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline lupetalo

  • Senior Member
  • *
  • Posts: 182
  • Karma: +0/-0
    • View Profile
Re: Php-fpm
« Reply #4 on: 2012-12-28, 19:39:07 »
Can you please tell mi what is changed and will it kill not active processes?
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline lupetalo

  • Senior Member
  • *
  • Posts: 182
  • Karma: +0/-0
    • View Profile
Re: Php-fpm
« Reply #5 on: 2012-12-28, 19:57:33 »
That did opposite, memory fills in just few minutes, every process for every user is takeni even more memory....
1.4% of memory or 152.52 Mb per user, that is too much....
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Php-fpm
« Reply #6 on: 2012-12-28, 21:32:38 »
You can try something like:
Code: [Select]
       $startserver = '2';
        $minspareserver = '2';
        $maxspareserver = '4';
        $maxchildren = '4';
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline lupetalo

  • Senior Member
  • *
  • Posts: 182
  • Karma: +0/-0
    • View Profile
Re: Php-fpm
« Reply #7 on: 2013-01-10, 15:23:53 »
Ended up with creating script which checks for free memory and if below 200mb restart php-fpm. Takes 2 sec and it is not noticable a lot. But for two weeks on two occasions restart did not worked without any real reason. service php-fpm restart did not kill all php-fpm processes.
« Last Edit: 1970-01-01, 01:00:00 by Guest »

 


Top 4 Global Search Engines:    Google    Bing    Baidu    Yahoo
Click Here

Page created in 0.035 seconds with 17 queries.

web stats analysis