Apache or nginx ? I like to understand the basic working flow of Nginx , its advantage and disadvantage -
pros & cons on apache or nginx , how work internally in order maximize resource utilization
can utilize apache & nginx ? if utilize nginx problem can face ?
apache has disadvantages, when used php module.
apache's process model such each connection uses separate process.each process carries overhead of php , other modules may have loaded. apache process might run php script 1 request, serve static request. if php has memory leak (which happen sometimes), process continues grow in size. also, when keepalive enabled, recommended, process stays live few seconds after connection, consuming "slot" client might able utilize , helping server reach maxclients sooner.
nginx alternative webserver uses linux "epoll" api process requests in non-blocking mode. means 1 single process can handle many simultaneous connections. epoll efficient way tell single process connection(s) needs deal , can wait. nginx has goal of solving "c10k" problem - how have 10,000 concurrent connections.
this naturally goes hand in hand php-fpm, fastcgi process manager. nginx not have php built in. when receives request php script, makes phone call out php-fpm run script, returns result nginx, returns client.
this uses much less memory similar apache+mod_php configuration.
there couple more huge advantages of php-fpm on mod_php:
- uses different "pools", each of can run separate linux user. provides simple , effective way of isolating web sites each other (for example, if run different customers should not read each others' code) without overhead or nastiness of suexec or suphp. - has slow log feature can dump php stack trace of script has been running greater x seconds. can help diagnose slow code issues. php-fpm can run apache, , in fact allows take advantage of apache's more efficient worker mpm (or event in apache 2.4). however, experience configuring in apache more complex configuring in nginx, , worker, still not quite efficient nginx.
disadvantages moving nginx - not many, things maintain in mind:
- not back upwards .htaccess files. think thing .htaccess files must parsed apache every request, can cause important overhead. - configuration files need re-written. if have many complex site configurations, take doing. simple cases not big deal. feature of nginx
nginx fast because not need create new process each new request. http proxy , web server features ability handle more 10,000 simultaneous connections low memory footprint (~2.5 mb per 10k inactive http keep-alive connections) handling of static files, index files, , auto-indexing reverse proxy caching load balancing in-band health checks fault tolerance nginx uses little memory, static web pages.. fastcgi, scgi, uwsgi back upwards caching name- , ip address-based virtual servers ipv6-compatible spdy protocol support flv , mp4 streaming web page access authentication gzip compression , decompression url rewriting having own rewrite engine custom logging on-the-fly gzip compression response rate , concurrent requests limiting bandwidth throttling server side includes ip address-based geolocation user tracking webdav xslt info processing embedded perl scripting nginx highly scalable, , performance not dependent on hardware.with nginx,you lose whole bunch of apache-specific features such mod_dav stuff. lose lot of modules,
the best utilize nginx in front end of apache if need apache modules. utilize load-balancer if might, between multiple apache instances, , have mixed set-up rather apache nginx
No comments:
Post a Comment