By activepizzah
I’m running the 20$ droplet (4gb RAM, 2 core). My response time, or i’d say TTFB is too high. It even goes up to 4 secs sometimes, apart from the TTFB, the page loads pretty quicly (under 1 sec)
OS: Ubuntu 20.04 PHP-fpm Apache2 MySQL CMS: Wordpress CDN: Stackpath Caching: WP Rocket Website: https://subwhale.com
I really need some help regarding this, how can i optimize my server. I tried some online available resources but nothing works. I would really appretiate the help.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Same issue here with $60/mo droplet with dedicated CPU and 8G RAM.
I have also switched to http2 and fastcgi and I still get the same huge TTFB. I have my wordpress in another server and the TTFB there is 1/5 of DO and don’t know what to do…
I would definitely like to switch but can’t fix the TTFB issue.
For anyone else stumbling upon this still.
there are several strategies you can implement to optimize server performance and reduce TTFB.
1. Optimize PHP-FPM Configuration
PHP-FPM manages PHP processes, and its configuration directly affects response times.
pm Settings: Modify the process manager settings to better handle your site’s load.sudo nano /etc/php/7.4/fpm/pool.d/www.conf
Update the following directives:
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
These values are examples; adjust them based on your server’s resources and traffic patterns.
Enable OPcache: OPcache improves PHP performance by storing precompiled script bytecode in memory.
sudo nano /etc/php/7.4/fpm/php.ini
Ensure the following settings are present:
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=0
After making changes, restart PHP-FPM.
2. Optimize Apache Configuration
Apache’s configuration plays a crucial role in handling requests efficiently.
sudo a2enmod http2
Then, update your Apache configuration to use HTTP/2:
sudo nano /etc/apache2/sites-available/your-site.conf
Add the following line within the <VirtualHost *:443> block:
Protocols h2 http/1.1
sudo systemctl restart apache2
KeepAlive Settings: Persistent connections can improve performance.sudo nano /etc/apache2/apache2.conf
Set the following:
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 2
3. Optimize MySQL Configuration
Efficient database performance is vital for reducing TTFB.
innodb_buffer_pool_size: Allocate a significant portion of RAM to InnoDB buffer pool.sudo nano /etc/mysql/my.cnf
Under the [mysqld] section, add or modify:
innodb_buffer_pool_size = 2G
This allocates 2GB; adjust based on your server’s RAM.
Enable Query Caching: Although deprecated in newer MySQL versions, if available, it can improve performance.
query_cache_type = 1
query_cache_size = 64M
After changes, restart MySQL:
sudo systemctl restart mysql
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.