• Home
  • WP tuts
  • Hosting talk
    • Free hosting
    • Cheap Hosting
    • comparison cloud , vps, shared, wordpress
    • managed wordpress hosting
    • managed cloud hosting
  • Speed up wordpress
  • Pc world
  • Services
  • About Me

RAaz Kumar .com

wordpress tutorials seo hosting etc

apache performance tuning mpm-worker vs prefork vs event modules

#1 understanding apache architecture

Selecting multiprocessing module based on application and traffic type.

#1 apache mpm worker module

: (multi threaded) multiple child processes,  each child with many threads.each thread handles one connection.
ServerLimit, (upper limit child processes)
default 16 child process.
ThreadsPerChild,  default 25
MaxRequestWorkers /serverlimit
sets limit for all threads , apache don’t spawn threads to handle new connections
error message maxclient reached.
serverlimit * threadsperchild = maxrequestworkers.
cpucores= serverlimit
2 cpu cores
2*64=128 worker connections per second.
4*32=128 worker connection/sec
threadsperchild 1 equals to mpm Prefork.
Minsparethreads (idle threads waiting to handle rather than spawning on new connection)
Maxsparethreads (50% of maxrequestworkers)
(Idle threads uses shared memory, make sure to know avg connections for server by monitoring)
thread limit 64 default

apache mpm event worker module :

same as worker, but assigns some connections to other threads to free up main thread active vs inactive connections with keep alive(separately).

apache mpm-prefork module

Prefork: child process, (single threaded)
each child process with one thread, each process handles one,(memory allocates based on process)
<IfModule mpm_prefork_module>
  StartServers              4
MinSpareServers          20
MaxSpareServers          40
MaxRequestWorkers       200
MaxConnectionsPerChild 4500</IfModule>

MaxRequestWorkers / MaxClients

maximum connections handled by (single threaded process)
default 256
(increase based on traffic &server resources)
starts servers (greater than min spare servers)
server means a child process of apache
threadsperchild, minsparethreads
minspareservers (25% of max spare servers)
maximum spare servers (equal to request workers)

maxrequestsperchild/maxconnectionsperchild

before a process respawns or die it should handle the these connections. (respawning frequently causes highload)
default =0(unlimited) already decides by threadsperchild *maxconnectionsperchild
it’s better use to avoid memory leaks.
set minimum of 10000 if necessary.
in php-fpm pool manager with nginx default it is 500;
ServerLimit directive represents the upper limit of MaxRequestWorkers

check mpm module apache2 using

apache2 -v
root@instance-1:/home/ubuntu/.ssh# apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2020-03-13T12:26:16
you see mom module along with apache version.
Mpm-prefork module and php-fpm confirmation uses same methodology.
root@instance-1:/home/ubuntu/.ssh# apache2 -V
[Fri Aug 07 10:55:45.384106 2020] [core:warn] [pid 9663] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2020-03-13T12:26:16
Server's Module Magic Number: 20120211:68
Server loaded:  APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"
root@instance-1:/home/ubuntu/.ssh#

 

/etc/apache2/mods-enabled

 

you can change in apache2.conf or enabling disabling module

 

mpm_prefork_module (shared)

 

nano /etc/apache2/apache2.conf

Disable unnecessary modules

sudo a2dismod modname
to view loaded modules
apache2ctl -M
root@instance-1:~# apache2ctl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php7_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)
root@instance-1:~#

 

Time-outs

default 60 sec or 1 minute
to control dos /ddos or brute force attacks.

keep alive

connections while browser reading a page
directives also govern KeepAlive. MaxKeepAliveRequests and KeepAliveTimeout.
default 100
keep alive timeout 2
task vs process vs child process vs threads

Increase Max Open Files

If you are handling high loads increase the number of allowed open files.  On linux, increase /proc/sys/fs/file-max and run ulimit -H -n 4096.
HostnameLookups off;

disable htaccess

AllowOverride should be directory specific.

enable caching in to separate static content.
CacheQuickHandler on; for static

Disable extended status in apache2.conf

ExtendedStatus off
install MySQL tuner to suggestions based on your sever environment.

optimize linux system

ListenBacklog
soffilelimit

cpu intensive or memory intensive

top command shows
dual core cpu
50% means one core utilized 100%.
avg cpu 75%
memory 75%
disk io & space (SSD must hdd no way hdd vs ssd)

use varnish nginx as reverse proxy and load balancer

nginx caches pages and serves directly without contacting the apache.
while apache busy with dynamic page generation. then nginx caches dynamic pages stores as satic pages seres faster.
nginx as load balancer :
stores cache multiple server based on algorithms.
you must read
use nginx as reverse proxy and load balancer for apache wordpress

Related topics:

  1. how to enable KeepAlive connections in apache nginx wordpress
  2. Redis performance metrics & tuning for nginx apache ubuntu & debian
  3. apache server tutorial (install,config, performance tuning, security, error handling)
  4. nginx performance tuning
  5. Apache vs nginx (connection handling, modules, memory usage)

tutorials

  • Android Studio tutorials syllabus Topics Course details #AndroidApplicationDevelopment
  • xampp tutorials 2021 installation errors fix wordpress phpmyadmin mysql apache
  • Devops Syllabus topics PDF
  • CCNA Syllabus pdf (CCNA / CCNP vs devops vs mcsa /MCSE)
  • how to create a website free of cost on google
  • what is vpn vs proxy vs tor, http vs https, http2, tcp vs udp, kali linux sql source code injection
  • nginx server tutorials (installation, configuration, performance tuning, security)
  • Vivek Bindra Videos Transcription (business strategy)
  • AUdio Editing Background Noise removal (Audacity, Adobe Premiere Addition, Camtasia Filmora Windows Obs)
  • MySQL Tutorial (create,connect database, update tables, export etc) Documentation & TIPS
  • [INTRO] Ethical hacking / cyber Security / Penetration testing Tutorial -{updates frequently}
  • ubuntu tutorials installation download issues etc
  • Php tutorials
  • HTML & CSS Tutorials
  • Core Java Tutorial Free online
  • Linux sysadmin tutorials linux system administrator
  • apache server tutorial (install,config, performance tuning, security, error handling)
    • what is If-Modified-Since HTTP header how to add to Wordpress website
    • htaccess tutorial tips for wordpress #redirect #leverage browser cache #Gzip #KeepAlive
    • apache modules list (explained, enable disable)
    • connect to server by SSH client Putty SFTP client winscp LAMP, LEMP nginx apache etc linux
    • Lamp stack install on Ubuntu 20.4 LTS apache, mysql, php 7.4(Debian 9 & Ubuntu 18.04 lts)
    • apache performance tuning mpm-worker vs prefork vs event modules
    • enable caching in apache server (mod cache disk cache) vs fastcgi cache
    • how to enable KeepAlive connections in apache nginx wordpress
    • Cache control Header & expires headers How to set Properly
    • apache2 conf sample explained apache configuration file modules etc

 

PUBG Mobile Tips & Tricks

free fire how to play (a-z guide) guns, tips &#038; tricks etc

Windows 10 tips & tricks

Pagespeed optimization

Pc building tips & tricks

nginx server tutorials

apache server tutorials

linux sysadmin tutorials

mysql Commands list pdf

Android studio tutorials

Gaming/ streaming tips

Airtel dth channel list

 

wordpress

 

Top 5  WP Google Analytics Plugins

WP Backup Plugins

Wp Comment Plugins

Top wordpress Security Plugins

WP Seo Plugins

WP Caching Plugins

Best Adsense Plugins for WordPress

Wp social Sharing Plugins

autoshare social media plugins

WP speed Optimization Plugins

Speedup WordPress google Score

More Wp tuts

Server Admin Cloud

 

Installing Nginx LEMP On ubuntu

Installing apache Lamp ubuntu

nginx fastcgi cache enable

php – fpm install  & Configuration

Opcache install & Configure

php -fpm pool manager explained

Mysql Install & Configuration

Redis Object cache install & configure

 

Nginx as Reverse Proxy and Load balancer

Load Balance / auto scaling in google cloud

Linux Commands PDF

Mysql Commands Pdf

Letsencrypt tutorial

mysqldump export & import 

Pagespeed Module install & configure

nginx.conf best file

mysql.conf best file

upgrade ubuntu

© 2021 - All Rights Reserved Disclaimer & Privacy Policy