Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Reducing Memory Usage and Improving Perfomance 1 GB RAM Nginx MariaDB Php-fpm
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Reducing Memory Usage and Improving Perfomance 1 GB RAM Nginx MariaDB Php-fpm

Hi, new member here ☺️.
I have a server with specs:

  • Ubuntu Linux
  • Xanmod Kernel
  • 1 vcpu, 1 gb of ram, 20 gb of ssd
  • Dedicated

I currently run

  • wordpress, mariadb, nginx, php-fpm
  • docker (usememos)
  • prosody (xmmp)

My question is simple, how to reducing ram usage? Is it impossible to make lower than 200?
Now my ram usage is 280M

My.cnf file:

[mysqld]
performance_schema = off
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K

www.conf

pm = ondemand
Pm.max_children = 9
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2

Comments

  • Since it is Wordpress try to use OLS and the use LiteCache (LS Cache Plug-in) this will reduce your PHP request and this will helps yo to reduce your CPU and RAM usage.

  • al1r4dal1r4d Member

    @imgmoney said:
    Since it is Wordpress try to use OLS and the use LiteCache (LS Cache Plug-in) this will reduce your PHP request and this will helps yo to reduce your CPU and RAM usage.

    I'm not OLS fan :/, so i would not use that

  • al1r4dal1r4d Member

    up +1 hehe :smile:

  • If you want really lightweight than you can use WordOps without the dashboard panel.

    without wo stack install , directly with command wo site create DOMAIN.COM --othercommands

  • System: Debian

  • alt_alt_ Member
    edited June 2023

    Use static mode for php-fpm to reduce waiting time for spamming worker processes, therefore will significantly improve performance.

  • al1r4dal1r4d Member

    @febryanvaldo said:
    If you want really lightweight than you can use WordOps without the dashboard panel.

    without wo stack install , directly with command wo site create DOMAIN.COM --othercommands

    Thanks for recommendation. But i dont need a panel :smile:. I'm already used to the command line interface

  • al1r4dal1r4d Member

    @Microcharon said:
    System: Debian

    I dont have time to migrate. If i can, i would choose alpine as os :smiley:

  • al1r4dal1r4d Member

    @alt_ said:
    Use static mode for php-fpm to reduce waiting time for spamming worker processes, therefore will significantly improve performance.

    Any guide?

  • alt_alt_ Member

    @al1r4d said:

    @alt_ said:
    Use static mode for php-fpm to reduce waiting time for spamming worker processes, therefore will significantly improve performance.

    Any guide?

    https://geekflare.com/php-fpm-optimization/

  • al1r4dal1r4d Member

    @alt_ said:

    @al1r4d said:

    @alt_ said:
    Use static mode for php-fpm to reduce waiting time for spamming worker processes, therefore will significantly improve performance.

    Any guide?

    https://geekflare.com/php-fpm-optimization/

    pm = ondemand
    Pm.max_children = 9
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 2

    🫡 Need suggesttion to reduce memory usage and increase perfomance. Is it pm = static enough?

  • ailiceailice Member

    What you want achieve with 800mb space RAM?
    280mb is aleardy lightweight.

    pm static make more memory hungry because it initialize workers on memory, so no.

    Your can probably can squeeze more ram by compiling kernel with your specific case or alpine have -virt kernel which remove any desktop-related module from kernel.

  • al1r4dal1r4d Member

    @ailice said:
    What you want achieve with 800mb space RAM?
    280mb is aleardy lightweight.

    I want to reach the point of maximum lightening. It's fun to see a bloatless server.
    Is it impossible to run WordPress under 128 MB nowadays? hahahah

    pm static make more memory hungry because it initialize workers on memory, so no.

    thank you, sir.

    Your can probably can squeeze more ram by compiling kernel with your specific case or alpine have -virt kernel which remove any desktop-related module from kernel.

    okay, thank you, sir :smile:

  • alt_alt_ Member
    edited June 2023

    @al1r4d said:

    @alt_ said:

    @al1r4d said:

    @alt_ said:
    Use static mode for php-fpm to reduce waiting time for spamming worker processes, therefore will significantly improve performance.

    Any guide?

    https://geekflare.com/php-fpm-optimization/

    pm = ondemand
    Pm.max_children = 9
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 2

    🫡 Need suggesttion to reduce memory usage and increase perfomance. Is it pm = static enough?

    Using the 'static' mode may need some adjustments as stated by Hayden James in his article "PHP-FPM tuning: Using ‘pm static’ for max performance" available here.

    The different modes are distinguished as follows:

    Governor = ondemand: This mode adjusts the CPU frequency in accordance with the current load. It quickly jumps to the highest frequency before scaling down as idle time increases.
    Governor = dynamic: Like 'ondemand', it adjusts the CPU frequency based on the current load, but scales the frequency more steadily.
    Governor = static: This mode operates the CPU at its maximum frequency consistently.
    In addition, Hayden James has provided a valuable guide on how to set up the 'static' mode.

    https://static.haydenjames.io/wp-content/uploads/2017/10/php-fpm-pm-bench-1024x512.png

    For those interested, my archived configuration for the 'dynamic' mode can be found here. The configuration for start_servers, min_spare_servers, and max_spare_servers remains the same. However, the max children count might vary depending on the specific environment. I prefer to use this setting, which can be found here.

    To set the child count, you can estimate it based on the RAM size divided by the result you get from the following command (remember to change it to match your PHP version):

    ps --no-headers -o "rss,cmd" -C php-fpm8.0 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }

    One more thing that you need to be pay attention if you application have some memory lacking issues or not exit after executing. Consider setting time limits and execution time or otherwise it will be more likely to be killed by oom killer.

    I hope you find this information useful.

  • amarcamarc Veteran
    edited June 2023

    @al1r4d said: Is it impossible to make lower than 200?Now my ram usage is 280M

    Why would you do that ? Please post output of free -m -w

    Remember, unused memory is wasted memory

  • memory is almost cost nothing now. just go for 2GB ram

  • @amarc said: Remember, unused memory is wasted memory

    Yes, especially in Linux.

  • GanonkGanonk Member

    welcome @al1r4d o:)

  • al1r4dal1r4d Member

    @alt_ said:

    @al1r4d said:

    @alt_ said:

    @al1r4d said:

    @alt_ said:
    Use static mode for php-fpm to reduce waiting time for spamming worker processes, therefore will significantly improve performance.

    Any guide?

    https://geekflare.com/php-fpm-optimization/

    pm = ondemand
    Pm.max_children = 9
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 2

    🫡 Need suggesttion to reduce memory usage and increase perfomance. Is it pm = static enough?

    Using the 'static' mode may need some adjustments as stated by Hayden James in his article "PHP-FPM tuning: Using ‘pm static’ for max performance" available here.

    The different modes are distinguished as follows:

    Governor = ondemand: This mode adjusts the CPU frequency in accordance with the current load. It quickly jumps to the highest frequency before scaling down as idle time increases.
    Governor = dynamic: Like 'ondemand', it adjusts the CPU frequency based on the current load, but scales the frequency more steadily.
    Governor = static: This mode operates the CPU at its maximum frequency consistently.
    In addition, Hayden James has provided a valuable guide on how to set up the 'static' mode.

    https://static.haydenjames.io/wp-content/uploads/2017/10/php-fpm-pm-bench-1024x512.png

    For those interested, my archived configuration for the 'dynamic' mode can be found here. The configuration for start_servers, min_spare_servers, and max_spare_servers remains the same. However, the max children count might vary depending on the specific environment. I prefer to use this setting, which can be found here.

    To set the child count, you can estimate it based on the RAM size divided by the result you get from the following command (remember to change it to match your PHP version):

    ps --no-headers -o "rss,cmd" -C php-fpm8.0 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }

    One more thing that you need to be pay attention if you application have some memory lacking issues or not exit after executing. Consider setting time limits and execution time or otherwise it will be more likely to be killed by oom killer.

    I hope you find this information useful.

    thanks :)

  • al1r4dal1r4d Member

    @amarc said:

    @al1r4d said: Is it impossible to make lower than 200?Now my ram usage is 280M

    Why would you do that ? Please post output of free -m -w

    Remember, unused memory is wasted memory

               total        used        free      shared     buffers       cache   available
    

    Mem: 962 255 119 57 24 563 514
    Swap: 0 0 0

  • al1r4dal1r4d Member

    @cybertech said:
    memory is almost cost nothing now. just go for 2GB ram

    ya i know.. i just like to optimize

  • al1r4dal1r4d Member

    @Ganonk said:
    welcome @al1r4d o:)

    halo :smile:

  • LeviLevi Member

    my.cnf tuning without mysqltuner.pl is magic from coffee beans. www.conf tuning is worthless.

  • al1r4dal1r4d Member

    @LTniger said:
    my.cnf tuning without mysqltuner.pl is magic from coffee beans. www.conf tuning is worthless.

    okay, sir.. i dont use mysqltuner.pl btw

Sign In or Register to comment.