FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
Nginx
Tweaking fastcgi-buffers
Topics
On this page
-
- Getting Started
- Git and File-System Layout (non-default setup)
- Version Constraints
- Managing Themes and Plugins (for entire WordPress site)
- Updating Themes and Plugins (for entire WordPress site)
- Adding Composer Support to Your Own Themes and Plugins (for developers)
- Using Composer to Manage Own Theme/Plugin Dependencies (for developers)
-
- Assigning Multiple IP Addresses to Single LAN Card
- Disable IPv6 on Ubuntu 12.04
- dsh – distributed shell
- fdupes – find & replace duplicate files with hardlinks
- GPG Keys Cheatsheet
- Increase "Open Files Limit"
- kill all php, nginx, mysql or any kind of processes
- Passwordless Authentication for SSH
- Screen
- search replace in multiple files useing grep xargs sed
- Setup sftp
- sysctl.conf
- Timezone Sync
- Using Google Public DNS on Ubuntu Server
- Using openssl to match private key, cerificate and CSR
- Configure Postfix to Use Gmail SMTP on Ubuntu
- Logrotate Example for Custom Logs
- PHP 5.5, MySQL, Postfix, Nginx and WordPress on Ubuntu
- Serverdensity
- Upgrade Ubuntu 10.04 to 12.04
- Using find and sed to replace strings in multiple files
- Webmin
-
- .my.cnf – mysql user & password
- Analyse slow-query-log using Anemometer
- Improving MySQL Query Cache
- MySQL Query Profiling
- Reset MySQL root password
- tuning-primer.sh – an alternative for mysqltuner
- Using MariaDB 10
- Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS
- Change WordPress Domain Name
- Character Sets and Collations
- Enable innodb_file_per_table
- Enable Remote Access (Grant)
- Installing Percona Toolkit
- Using tmpfs for temporary folder creation
- YARPP and InnoDB
- Convert MyISAM to InnoDB
- Using tmpfs for mysqldump & mysqlimport
- Convert from INNODB to MYISAM
- Analyse slow-query-log using mysqldumpslow & pt-query-digest
- mysqlcheck with cron to optimize automatically
- Using MySQLTuner to Optimize MySQL configuration
-
-
- Directly connect to PHP-FPM
- Generating core-dump for php5-fpm
- GeoIP
- Having php5 and php7 on same system.
- Install Xdebug and configure it with webgrind
- Installation of PHP Code Review Tools
- memcache
- PHP's Zend Opcache Config & Web Viewer
- Setting Sqlite support with PHP
- Using HHVM with PHP-FPM Fallback
- Using Redis for PHP Sessions on Ubuntu Server
- Installing PhpMyAdmin Quickly
- Moving PHP's session storage to tmpfs
- Install Xdebug and configure it with Netbeans
- Nginx – Enable PHP-FPM Status Page
- PHP-FPM: Socket vs TCP/IP and sysctl tweaking
- APC Cache Optimization & Monitoring Using Web Interface
- Checking if PHP/WordPress can send mails
- Debugging PHP Scripts Using slow_log and more
- Increase file upload size limit in PHP-Nginx
- Increase PHP script execution time with Nginx
-
- Performance Optimization
- Remove Query string of css/js files
- Setup ElasticSearch with ElasticPress
- Using Redis for WordPress Object-Cache
- WooCommerce Window Shopping Caching Technique
- Moving WordPress To New Server (Faster)
- Better wp-cron using linux's crontab
- 404 error- Page not Found!!!
- Debugging WordPress with Nginx
Maximum Response Size
Average Response Size
Tweaking fastcgi-buffers
Following can help you tweak fastcgi_buffers size & numbers.
Maximum Response Size
awk '($9 ~ /200/)' access.log | awk '{print $10}' | sort -nr | head -n 1
Please note we taking HTTP 200 OK response only into consideration.
Average Response Size
echo $(( `awk '($9 ~ /200/)' access.log | awk '{print $10}' | awk '{s+=$1} END {print s}'` / `awk '($9 ~ /200/)' access.log | wc -l` ))
Based on above result, for rtCamp.com we found following values:
Avg. 24807
Max. 629622
So we are using:
fastcgi_buffers 32 32k;
fastcgi_buffer_size 32k;
Related: Nginx Log Parsing Examples
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
PREVIOUS
Using $upstream_cache_status in access.log
NEXT
Comments
-
ovidiu
Ok so you’re setting the buffer to be slightly bigger than the average response size but I currently have the same settings show above here in the example and my values are avg. 5286 max. 635 so I could get a way with a buffer of 1kb but I doubt my current values are correct since phpfpm has been restarted recently….
So if I keep my values for now, is a bugger that is too big bad or is it just a waste of resources?
-
Dave
Wouldn’t fastcgi_buffers 32 32k; give you a buffer size of 1m, much more than you need?
-
As far as I know, Nginx won’t allocate 1mb in one go.
fastcgi_buffers 32 32k;will allocate buffers in pages of size 32k. First 32 will limit number of buffers/pages allowed to use in memory.We used 32k because average response size was around 24k as shown from calculation in article above.
We limited max to 1mb because top most response was over 600k.Idea is to set default single buffer size for average response size so that multiple buffer allocation won’t be needed for average size. It is controlled using
fastcgi_buffer_size.
Then usefastcgi_buffersto provision additional buffers, in chunks, to hold max response in memory.If I missed anything, feel free to correct me.
-
-
Moscato
Is there a major downside to using too many buffers or buffers that are too large?
Are these buffers duplicated per connection? Process?
I run a server with several wordpress installs, with 2 GB of ram with nginx and php-fpm with like over a gig of ram free
-
Answers:
1. No. Tweaking buffers will not make noticeable difference to even sites with million daily hits (unless fastcgi output way larger than default size output)
2. I think they are allocated per request.
-
Features
- Server Setup & Management
- Site Creation & Management
- Create WP Cloud Sites
- Speed & Caching
- Firewall Protection
- Backups & Recovery
- Logs & Monitoring
- Deployments & Developer Tools
- Team Access & User Permissions
Useful Links
Product
Other Products
Subscribe for curated product updates, tips, and announcements.
"*" indicates required fields
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.