PHP-FPM 5.6和Nginx 1.6.2毫无疑问会提供最大的性能,至less在速度上是明智的。 所以,我想知道是否有任何优点/缺点添加清漆caching,以获得可能几乎没有更多的速度。 我读过很多博客,说nginx + varnish单独是有点矫枉过正,但我还没有得到一个反馈,可以certificate这一点。
这取决于你如何使用nginx。 如果你没有使用nginx的任何cachingfunction,那么你肯定会从Varnish中获益。 你必须决定每个function。 这说,如果你正在寻找“双caching”,我怀疑这是一个好主意。
也许你可以告诉我们你的堆栈是如何build立的
其实这取决于你的应用程序 。
如果你只提供静态文件,那么把一个Varnish代理放在Nginx Web服务器前是没有意义的。
关于PHP应用程序的加速,您可以使用Nginx(请参阅fastcgi_cache )来应用caching层。 这可能已经是获得额外速度的简单解决scheme。
但是有些情况下使用清漆会有帮助:
例
PHP应用程序必须发送适当的caching标题。
server { listen 80; listen [::]:80; server_name www.example.com; root /var/www/www.example.com/htdocs; # CVE 2013-4547 if ($request_uri ~ " ") { return 444; } location / { try_files $uri index.php?url=$uri&$query_string; } location ~ \.php$ { # global access log is off but for PHP we'd like to log access_log /var/log/nginx/access.log vhosts; # use fastCGI fastcgi_keep_conn on; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; # activate caching for fastCGI fastcgi_cache php; fastcgi_cache_bypass $cookie_PHPSESSID; # do not cache if session is active fastcgi_cache_key "$scheme$request_method$host$request_uri"; # cache key fastcgi_cache_use_stale error timeout invalid_header http_500; # stale on error fastcgi_cache_valid 200 301 720s; # cache only HTTP-200 and HTTP-301 responses and define a TTL fastcgi_pass_header Set-Cookie; # allow Set-Cookie header fastcgi_no_cache $cookie_PHPSESSID; # do not cache if session is active # include system wide fastCGI settings (Ubuntu/Debian style) include fastcgi_params; } }