• 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 vs nginx (connection handling, modules, memory usage)

 

 

Cons of nginx:

  1. Limited modules
  2. everything has to code when compare to apache. (nightmare for new server admins)
  3. static modules (deploy only once while installing the server)
  4. not handles dynamic content it self (its a  pros)

Pros of Nginx

  1. less cpu & memory required to handle 1000+ concurrent connection (existed to address apache problems)

 

 

Why nginx created in 2004 2 version open source and premium nginx plus

C10K problem handling ten thousand concurrent connections
in Apache every connection handle by 1 worker that holds some memory, ex: 126MB if 500 Connection simultaneously Apache server has to
500*126MB= 63000 MB or 63GB. (it also holds Php as a module to control memory limit.
however, if 500 connections per seconds in reached in Apache you get message like max clients reached. or you may also install a beautiful module that only servers plain html page
in peak time
(Solution caching dynamic content as static (no request database) fastcgi or nginx as revere proxy)
page

Apache core architecture

apache-worker

mpm-prefork: process with 1 thread to handle 1 connection 1 process = (126+MB memory just on limit in php )
mpm-worker: process with 2 threads thread for 1 connection handling 2 connections by 1 process. but keep alive connections (idle which pages active in browser but no request from user also count as active connection holds some memory)
mpm-event: only uses threads for active connections. keep alive connection handles separately.

you have to select best for your server or websites need.

Note: we can’t limit apache process memory limit not like php or php-fpm but we can do it by limiting processes or threads)

//traffic = visitors >> connection. 100 real time visitors = not 100 active connections to db,php server proxy.

<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

<IfModule mpm_event_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
(based on above php -fpm pool manger set as on demand,dynamic,static in nginx)

 

Nginx core architecture

nginx-architecture

Nginx workers equal to cpu cores

user       www www;  ## Default: nobody
worker_processes  auto;  ## Default: 
error_log  logs/error.log;
pid        logs/nginx.pid;
worker_rlimit_nofile 8192;

events {
  worker_connections  4096;  ## Default: 1024
}

 

nginx workers auto =2
worker process = 1024 default
2*1024=2048 concurrent connections per seconds or 2 vcore server*big deal

single-threaded and processes use an asynchronous, non-blocking, event-driven connection handling algorithm.
not spawn process based on connection (every process = memory cpu holding)
2 process in nginx based on cores.
connection handling:
connections handled by the worker are placed within the event loop where they exist with other connections. Within the loop, events are processed asynchronously, allowing work to be handled in a non-blocking manner. When the connection closes, it is removed from the loop.

why people use nginx as proxy for apache?

nginx passes the connection to php-fpm then database
and waits until the connection process.

modules: apache modules easy install and configure dynamically and lot of features.
nginx modules can de deployer only once as static. however nginx introduced dynamic module
feature but it has to deploy with again fresh nginx installation(install fresh nginx with new module as dynamic in same /live or another server with same os and version of nginx then copy the module file into production server)

.htaccess vs nginx server block

.htaccess look for all servers files when a request process. (you can place own .htaccess to rewrite main server rules like wp .htaccess) but nginx only look specified directory
By not allowing directory overrides, Nginx can serve requests faster by
doing a single directory lookup and file read for each request (assuming that the file is found in the conventional directory structure).

nginx does not allow to overwrite rules every directory. so problems in shared hosting, (memory limit, compression,ssl etc)
cpanel only works with apache.

file system vs uri (request interpretation)

apache processes to file system while nginx to url

The try_files directive commonly uses the $uri variable, which represents the part of the URL after the domain name

and its new 2004 vs 1995 apache

how litespeed faster than nginx and nginx plus

Litespeed released on 2003 in enterprise version its got popular when its released 2014 openlitespeed free version

& 2017 litespeed cache plugin for wordpress.

same architecture as nginx. built in litespeed cache. while windows IIS server not free at all.

nginx vs apche vs iis

 

also know how to tune nginx performance

and improve mysql performance

Related topics:

  1. apache performance tuning mpm-worker vs prefork vs event modules
  2. how to enable KeepAlive connections in apache nginx wordpress
  3. Speed up my PC windows too much memory 100% disk CPU usage fix
  4. MySQL innodb memory allocation & usage calculation
  5. apache modules list (explained, enable disable)

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)
    • nginx modules list (enable, disable, upgrade, install dynamic module)
    • SSL faster reduce TLS hand shake improve https performance
    • monitor nginx request with nginx status amplify datadog new relic
    • nginx installation on ubuntu 20.04 LTS
    • Redis performance metrics & tuning for nginx apache ubuntu & debian
    • enable brotli compression nginx brotli vs gzip
    • nginx performance tuning
    • Top 10 tips to improve nginx server security
    • letsencrypt install configure on ubuntu / debian nginx
    • what is TTFB & how to Reduce it (server response time) Google pagespeed
    • enable php fpm status page, monitor & understand the report to tweak performance
    • 2021 php fpm pool manager configuration settings based on server spike
    • Letsencrypt SSL Installation on apache/Nginx ubuntu / debian
    • nginx rewrite rules with examples 301 redirection
    • use nginx as reverse proxy and load balancer for apache wordpress
    • nginx conf explained best config file performance tuning nginx.conf
    • nginx errors (504,502, 413, unable to start, syntax errors)
    • Pagespeed module install, configure, monitor, errors ft nginx &apache
    • Apache vs nginx (connection handling, modules, memory usage)
    • install lemp Linux, Nginx 1.15.12, MySQL 8, PHP fpm 7.3 on Ubuntu 18.04
    • nginx fastcgi cache wordpress how to configure
    • Redis / memcached installation on ubuntu 20.04 with wordpress mysql configuration
    • cloudflare timeout error 522 524 fix by increasing limit
  • 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)

 

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