Популярные WEB сервера и заметки о них (apache/httpd, nginx)

Сравнение можно посмотреть тут

  • nginx
  • apache
  • iis (deprecated)
  • apache tomcat

Apache обычно используется для отдачи статики, nginx для динамики. Данный блог на apache, проблем из-за этого не было.

 

Apache

Конфигурация apache для поддержки более 1000 одновременных сессий. Протестировал – работает корректно (создается много параллельных процессов apache).

  • https://httpd.apache.org/docs/2.4/mod/prefork.html
  • https://httpd.apache.org/docs/2.4/mod/mpm_common.html#maxconnectionsperchild
<IfModule prefork.c>
ServerLimit 1000 # Declares the maximum number of running Apache processes
StartServers 20 # The number of processes to start initially when starting the Apache daemon
MinSpareServers 20 # Minimum number of idle child server processes
MaxSpareServers 50 # Maximum number of idle child server processes
MaxRequestWorkers 5000 # The maximum number of simultaneous client connections (maximum amount of requests that can be served simultaneously)
MaxConnectionsPerChild 10000 # Limit on the number of connections that an individual child server will handle during its life
</IfModule>

Если есть подписка на redhat – можно конфиг посмотреть у них жадных.

Redhat lol
https://access.redhat.com/solutions/1279903 
SUBSCRIBER EXCLUSIVE CONTENT

 

Nginx

 Build nginx with debug support [9] and check the debug log.
      It should contain all details about connection and why it
      failed. All related messages contain "quic " prefix and can
      be easily filtered out.

Балансировка и отказоустойчивость WEB приложения легко делается через nginx. Хуже если балансер через DNS, там время кеша 2 минуты.

Бывает даже такой сценарий, что nginx находится на одном логическом сервере (в той же самой системе) с apache и выполняет функции redirect на apache.

location / {
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
log_not_found off;
server_name_in_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security 'max-age=31536000; preload';
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options SAMEORIGIN;
client_max_body_size 6m;
}

Конфиг, как в случае apache, редактируется в тексте. После модификации нужно перезагружать сервер.

vi /etc/nginx/conf.d/00_site_some_site.ru.conf
service nginx restart

Задание адреса на прослушивание в конфиге.

server {
listen 172.17.1.246:80;

Редирект.

 

IT monsters

Интересно, VK, как и yandex и многие другие нагруженные ресурсы, в том числе внутренние у компаний, в основном используют nginx, но есть, судя по всему, и apache. У youtube отдается свой собственный YouTubeFrontEnd.
Request URL:https://queuev4.vk.com/im467
Cache-Control:no-store
Connection:keep-alive
Content-Length:126
Content-Type:text/javascript; charset=UTF-8
Date:Wed, 31 Aug 2016 19:13:50 GMT
Pragma:no-cache
Server:Apache
Request URL:https://vk.com/al_im.php
cache-control:no-store
content-encoding:gzip
content-length:1838
content-type:text/plain; charset=windows-1251
date:Wed, 31 Aug 2016 19:13:24 GMT
pragma:no-cache
server:nginx

Leave a Reply