Wordpress site is too slow

  • Posted December 3, 2014

My wordpres site goes down when there are morethan 400 people online… My droplet is 8GB Ram 80GB SSD Disk New York 3 Ubuntu 1-12… Here is my site link

Can anybody help to solve this?


I’ve outlined the process for you below. Following these steps will allow you to move your MySQL database to a separate droplet while retaining your current droplet to provide the web service.

1.) First you will want to create a second droplet using a base OS image. For the purposes of this walk-through I’d recommend Ubuntu or Debian.

2.) On your new droplet you will need to install MySQL

apt-get update;
apt-get install mysql-server;

3.) On your new droplet edit the file /etc/mysql/my.cnf and change the bind_address line to your IP address. I recommend using your private IP address rather than the public one if you have private networking enabled on both droplets

bind-address = <private ip address>

4.) Now you will want to back up your MySQL database on your current Wordpress droplet. Log into it via ssh and get your root password from the file /root/.my.cnf then run mysqldump -uroot -p wordpress > wordpress-backup.sql

This will create a file “wordpress-backup.sql” that contains your database.

5.) On your new MySQL droplet use the following commands to create your new database.

connect to mysql

mysql -uroot -p 

create your new database

create database wordpress;

6.) Now we need to set up permissions for this database to be accessed remotely from your other droplet. Replace “webserver” with your other droplet’s IP address. If you are connecting via the private network this should be the private network IP.

GRANT ALL ON wordpress.* to "root"@'webserver';

In this case we are using your root user, you can also choose to create a separate user if you wish.

7.) Now, upload your wordpress-backup.sql to your new MySQL droplet and use the following command to import it.

mysql -uroot -p wordpress < wordpress-backup.sql

8.) Your new database server is now ready to take over. There is only one more thing to do to make the switch, we will now update your Wordpress configuration to start using the remote MySQL droplet instead of the local MySQL server. Connect to your existing Wordpress droplet and in your web root edit the file wp-config.php and change the following section to reflect your new MySQL server with being your private (or public) IP address on the new droplet and replacing “password” with the password you created.

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'password');

/** MySQL hostname */
define('DB_HOST', '');

9.) Once this change is made your site will immediately begin using the separate MySQL server instead of the local one so we can shut it down so those resources are available for your web service. service mysql stop

In addition to this you may want to consider setting up CloudFlare for your domain as this will provide some caching and lessen the load on your web service. Additionally switching to a lightweight web server like nginx can also improve performance.

@ryanpq It will be very helpful if you give a tutorial to move current wordpress site to nginx…

Thanks for the tutorial… Can u also give the tutorial to move current wordpress site to nginx. SO that ican do both and test…

Already using cloudfare … But still its there… IS there any tutorials available for seperating mysql and webservices between two or more droplets?

400 simultaneous users is quite a bit. I would recommend looking into the following options:

1.) Consider separating your MySQL and web services between two or more droplets 2.) Set up CloudFlare or another caching reverse proxy service to reduce the load on your droplet

We have a tutorial on scaling up Wordpress here as well which may be helpful.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, thank you for the tutorial. i have followed the top instructions exactly. I am able to ping the database server via the file server from the command line using the private IP without any issue. I get an instant response. But for some reason i am not able to connect to the sql server via wordpress. i get an error establishing a database connection.

@ryanpq we successfully moved our wordpress sites into two droplets, one for web and other for db… both droplets were in apache and uses private networking to connect… SO if i move web server to nginx and db server in apache is ther any problem to connection?

another doubt is if i want to expand my web droplet by creating snapshot and make new one from snapshot, is there any problem to connect in private networking, or do i need to configure again ?

@ryanpq changed database to another server but database is not accessible for my wordpress ? i Followed the above tutorial correclty but

Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at This could mean your host’s database server is down.

To do this with your existing Wordpress droplet you would want to do the following:

1.) Install the additional required packages

apt-get update;
apt-get install nginx php5-fpm php5-gd libssh2-php

The nginx service will attempt to start up but will fail since Apache is currently using port 80. This is not a problem at this point.

2.) Next we need to update the php.ini for php5-fpm:

sudo nano /etc/php5/fpm/php.ini

You will want to look for cgi.fix_pathinfo. This will be commented out with a semi-colon (;) and set to “1” by default. Now change it to:


3.) Now we can update the nginx configuration to work with php. Open the host configuration with:

sudo nano /etc/nginx/sites-available/default

and update the file so it appears like the one below:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name server_domain_name_or_IP;

    location / {
        try_files $uri $uri/ =404;

  <^>  error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

The changes are highlighted.

  1. Next we can copy over the Wordpress files from the Apache web root to the nginx web root.
cp -Rf /var/www/html/* /usr/share/nginx/html/.

We will also want to make sure these files remain owned by www-data to prevent any permissions issues.

chown -Rf www-data.www-data /usr/share/nginx/html/*

5.) Your new nginx server should be all ready to run now, lets test and make sure by stopping the apache service and starting nginx

service apache2 stop;
service nginx start;

Now you can load your site in a web browser to ensure everything is working properly.

6.) Once you are sure that things are working properly you can remove apache

apt-get remove apache2;

and if you moved your MySQL services to another droplet as outlined in my previous reply you can also remove the MySQL service

apt-get remove mysql-server;

@ryanpq this is for creating a new server , is there anyway to convert current apache server to nginx?

This tutorial covers the basics of setting up Wordpress with nginx. If you have already moved your database to another droplet there are a few things you should do differently.

1.) Skip step 1 as you already have your database set up.

2.) Instead of grabbing a new copy of wordpress you can just create a tarball of your current Wordpress install.

3.) If you set this up on a different server than your current Apache wordpress install and are using a remote MySQL server you will need to make sure you update your MySQL permissions to allow logins from the new droplet’s private IP.