Download presentation
Presentation is loading. Please wait.
Published byLizbeth Richard Modified over 8 years ago
1
©2012 der.hans, CC BY-SA 3.0 unported Nginx: Proxy Your Web Servers for Better Performance der.hans SCaLE 10x, 2012Jan21 Hilton LAX, Los Angeles A
2
©2012 der.hans, CC BY-SA 3.0 unported Nginx Origins Created by Igor Sysoev as an HTTP proxy for Rambler.ru FastMail.FM later paid Igor to add IMAP proxy
3
©2012 der.hans, CC BY-SA 3.0 unported Nginx Use Nginx now hosts nearly 12.18% (22.2M) of all domains worldwide, surpassing IIS for the second most used web server It was 11% in October Some sites using nginx: WordPress, Hulu, Github, SourceForge, TechCrunch
4
©2012 der.hans, CC BY-SA 3.0 unported Nginx Example Uses A single web server is no longer sufficient buy big, expensive hardware or distribute load to commodity hardware Add redundancy run Apache instances on multiple (virtual) machines
5
©2012 der.hans, CC BY-SA 3.0 unported Nginx Example Uses II Run various back-end web servers simultaneously Apache PHP-FPM gitweb
6
©2012 der.hans, CC BY-SA 3.0 unported What does it do? Nginx is a … reverse-proxy ( and some other stuff )
7
©2012 der.hans, CC BY-SA 3.0 unported Proxy Illustration
8
©2012 der.hans, CC BY-SA 3.0 unported Reverse-Proxy Illustration
9
©2012 der.hans, CC BY-SA 3.0 unported Reverse-proxy demonstration by default Nginx uses round-robin load-balancing
10
©2012 der.hans, CC BY-SA 3.0 unported Sample Apache config DocumentRoot /var/www/eins allow from all DocumentRoot /var/www/zwei allow from all
11
©2012 der.hans, CC BY-SA 3.0 unported Sample Nginx config upstream sample { server 127.0.0.1:8001; server 127.0.0.1:8002; server 127.0.0.1:8003; server 127.0.0.1:8004; } server { listen 80; server_name www.example.com; location / { proxy_pass http://sample; }
12
©2012 der.hans, CC BY-SA 3.0 unported Sessions What if you wanted someone to keep hitting the same web server? For example, if you don't want your web servers constantly having to pass session information back and forth? Use ip_hash directive
13
©2012 der.hans, CC BY-SA 3.0 unported ip_hash uses the /24 network for the browser IP as the key for a hash the key will hash the same every time, so it will keep going to the same web server well, unless the web server goes down there still needs to be some session sharing between the servers if maintaining sessions is important
14
©2012 der.hans, CC BY-SA 3.0 unported Sticky Backends Also see the nginx-sticky-module uses cookies to keep browsers going to the same backend server
15
©2012 der.hans, CC BY-SA 3.0 unported Notes When using round-robin, weighting can be used to drive more traffic to a particular server If you already have the big beefy machine, drive more traffic to it than the commodity servers you add to the pool Number of failures allowed and timeouts can be configured
16
©2012 der.hans, CC BY-SA 3.0 unported Nginx Advantages Asynchronous rather than forking or threading Event driven, using only a few threads Less resources needed Scales better Can proxy for many servers/services
17
©2012 der.hans, CC BY-SA 3.0 unported Nginx Service Capabilities What can Nginx serve by itself? Static files MP4 ( pseudo-streaming ) FLV ( pseudo-streaming ) SSI Pixel Perl
18
©2012 der.hans, CC BY-SA 3.0 unported Nginx Service !Capabilities What can't Nginx serve by itself? PHP CGI
19
©2012 der.hans, CC BY-SA 3.0 unported External Services Whatever can be served by a backend web server PHP via FastCGI/PHP-FPM GeoIP DBish Stuff Memcached Drizzle/MySQL PostgreSQL GridFS Redis
20
©2012 der.hans, CC BY-SA 3.0 unported Protocols HTTP SMTP IMAP POP3 TLS/SSL/SNI
21
©2012 der.hans, CC BY-SA 3.0 unported Features virtual servers load-balancing rewrites caching content filters authentication
22
©2012 der.hans, CC BY-SA 3.0 unported Features II rate-limiting compression chunking WebDAV Change config or update w/o shutting down service
23
©2012 der.hans, CC BY-SA 3.0 unported Credits CC BY-SA 3.0 unported Proxy Illustration – Brian Cluff Reverse-Proxy Illustration – Brian Cluff
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.