Very slow initial page load using Wordpress CMS


I finally setup my website on a Cloud server with Virtualmin.

I used Wordpress and somehow it takes up to 10 seconds just for the initial load of the page. Everything else (images, css, js, etc) load very fast it’s just the initial html loading that takes ages.

I turned on APC OPcode cache and MySQL database cache (in my.cnf) and set them up at my best but it still loads very very slow. This is the website: www (dot)

I have 4GB of RAM and usually half of it is always occupied, 2GB of virtual memory (I don’t even know what it is) and it’s always at 0.

I’m pretty sure it has something to do with the database. It is in total 350MB and just one table is 200MB.

Can somebody help me find out what the problem is? Thank you very much!

These are the settings I have in my.cnf

datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock

thread_concurrency = 8
query_cache_type = 1
query_cache_size = 384M
query_cache_limit = 128M
thread_cache_size = 8
myisam_sort_buffer_size = 64M
read_rnd_buffer_size = 8M
read_buffer_size = 2M
sort_buffer_size = 2M
table_cache = 512
max_allowed_packet = 1M
key_buffer_size = 384M


The defaults of Virtualmin and Wordpress should be such that the initial page load is considerably faster. It can have a number of reasons why it’s like 10 seconds for you. In addition to PHP or MySQL issues, it might be due to DNS name resolution.

If you have e.g. two nameservers configured, one returns the proper IP for your server, and the other does not respond, you can have random delays of the type you observed due to DNS timeouts.

So as a first test you might do an “nslookup www.yourdomain.tld” in a command line, repeatedly, spread out over a day or so (to include randomness and DNS caches into the test), and see if you get slow responses there at some point.

If you find that name resolution is always fast, we can test further.

Thank you locutus. I’m testing as you said. So far the “nslookup www.mydomain.tld” is pretty fast but I’ll check it out repeatedly during the day and post the result tomorrow.

Thanks again

I’ve tried testing “nslookup www.mydomain.tld” during the day, several times but it’s fast, so I don’t think it’s a matter of DNS.

Could you suggest me some other helpful testing or an adjustment to apc.ini or my.cnf?

Thank you

Is loading of the first page always so slow, or only sometimes? Even without cache, it should never take 10 seconds to load a Wordpress page, except you have lots of stuff on there, or use plugins or so that need to fetch things from other websites.

Unfortunately I’m not really familiar with MySQL or APC optimization, never had the need for that really. :slight_smile: You’d need to first find out if it’s really the database connection that’s slow, or maybe the PHP code or something else.

Is this a root server or managed? Database on the same machine? Did you try a different setup (like a physical server as opposed to “cloud”) to see if the cloud hardware might be the issue? What exactly is that “cloud server” you mentioned?

You might want to google for tips on how to profile website performance and find out which aspects of it use the most time, I never did that myself. “atop” run on the server might give a hint if some PHP process has high CPU load or disk I/O when the page loads slowly.


Yeah, the issue is rarely settings like those you are trying to tweak… the sort of problem you’re seeing can often be the result of a poorly performing plugin.

If you have any WordPress plugins enabled, perhaps you try try disabling them to see if the performance improves.


I’ve checked if it was a plugin issue but it isn’t. I’ve disabled all the plugins and tried but it only gave a very little speed up (1 sec on 10 or more seconds).

Yes Locutus, the website is quite big, it has more than 200.000 pages and so the database is big as well. I’m using W3 Total Cache for Wordpress, APC Opcode cache and MySQL cache but for logged in users I have caching disabled otherwise Wordpress will not work very well, at least that’s what’s written in the plugin.

So logged in users will see a tremendously slow website (it was faster when I was on a shared host) and normal visitors will see it fast enough (<2 sec) only sometimes because apparently sometimes it goes slow even if caching is enabled, maybe the cache clears itself too often.

I bought the Cloud service from Aruba (here in italy) and I’m using a VMWare Hypervisor with CentOS 6.x 64bit - Web Server LAMP operating system. 1 CPU, 4 GB of RAM and 20GB of hard disk.

Okay, I’m sorry but this is too complex a topic for me to go into details over the forum. That would involve too much guesswork, and I’m not overly familiar with optimizing a huge Wordpress installation like that. I’m afraid I can’t offer free help here, since it would quite probably take a few hours to get familiar with your installation and to do the proper research on the topic.


Well, I haven’t seen WordPress pages take that long to load before, except in cases where there was some sort of misbehaving SQL query… usually that query is part of a plugin, but it could be elsewhere too.

You could always try going into MySQL while your site is loading, and run “show full processlist” a few times to try and get an idea of what’s happening.

There’s also a MySQL slow query log that you could enable and review.

Some folks use memcache to improve database performance – WordPress should have a memcache plugin available.

This is a big topic though, as Locutus mentioned… if you get stuck, you could always consider the option of hiring someone familiar with MySQL application performance to assist in tracking down the bottlenecks you’re experiencing.



MySQL may just be configured to use too much memory. What you may want to try is using settings from a MySQL config designed to use a bit less memory than that.

Distributions include a few different examples – I’m not sure what distro you’re using, but on Debian/Ubuntu, those examples are here:


Take a peek at the file “my-medium.cnf.gz” – I suspect the settings within in will help lower the amount of RAM your MySQL instance is using.


Hi andreychek, thank you. I did as you said and now RAM is used less but somehow it always bugs anyway. MySQL is taking from 49% to 80% of CPU usage. Is that normal?

Well, with what you described above regarding the website being a bit slower – it sounds like the queries being run may be “heavy”.

You may need to review the queries your application is using, and either simplify them, add some indexes, or reduce the amount of data they’re looking at.

It sounds like the issue is with your website though – you may want to do some profiling of your site, and determine what it is your site is doing that’s taking so long to run, and hitting MySQL that hard.


Thank you Eric for your support. I’ve also tried using memcached as you suggested in a previous post but still the database is eating all server resourses. It goes all right and very fast for 20/30 minutes and then everything stops working, so I restart mysql server and it goes fast again for 20/30 minutes, etc etc.

Unluckily I’m not familiar with MySQL. I’ve tried repairing and optimizing all databases but nothing changed. Are you, or do you know someone, who’s knowledgable enough with mySQL that could do this work for me? Not for free, that’s clear!

Hi There,

I also had some initial problems with my VPS on DigitalOcean but I solved it.
In my case I misconfigured Xcache and MySQL was not optimised.

I would suggest the following:
run and perhaps it will suggest some config that would be better for your environment
or try with Percona configuration wizard:

Newrelic is also a great tool, they have a 14 day trial with all the functionality, In my case it showed the error in Xcache in alerts screen.

Do you use W3TC?
You can try disabling DB cache, maybe it will help.

Hope you make it work.

Thank you gstarr. I’ve tried mysqltuner like you said and it’s going better, no more peaks however RAM is almost always at max and mysqltuner keeps on telling me to increase:

query_cache_size (> 128M)
tmp_table_size (> 192M)
max_heap_table_size (> 192M)

Hi Danyz,

I would suggest the following:

  1. Try to create config file with percona configuration wizzard, you will answer couple of questions and then they will provide you with a MySQL config that they find appropriate based on your environment.
    It’s just a questioner and it’s free, just back up the old config first.
    In my case mysqltuner did it, but in your case with bigger DB, I suggest to try percona config as well.
    You have only 5 minutes to loose.

  2. Install newrelic monitoring for PHP.
    Its just an agent, then login to your account and monitor which queries and plugins consume the most resources, you will be able to resolve when you find out the problem. It’s amazing service and for 14 days you will have all the options, then it will fall back to free account which is a bit limited.

I hope you fix the problem.

Hi gstarr, thank you for your suggestions. I did as you said and tried the configuration wizzard with percona but it was giving me very bad results and one of the websites I have was totally messed up. I’ve tried different configuarations but in the end I went back to my original my.cnf that I set up using

NEWRELIC: I installed it and am running it since 24 hours, so far I understand that the process taking the most time is database specifically the table called “wp_posts” which is not even the biggest table!

However I’m not really familiar with the interface of newrelic so I can’t analyse data at my best.


Would you be able to post screenshots for:

On the left menu go to applications, then

screenshot for
Monitoring - Overview

screenshot for
Monitoring - Database

screenshot for
Monitoring - Map

you can delete in Paint sensitive data should you have some.


Hi gstarr, thanks for your help. Here are the screenshots


Maybe you could check memcache configuration?
I don’t use it so I can’t help, but I guess it could cache better.
Or you could try with latest Xcache, I have seen it doing wonders.
It can be used as PHP cache only or it can be used to replace memcache as well.
With digitialocean it’s very easy to create replica of main servrer and use second one for testing,
I don’t know how it’s done with your provider.
But if you can spin another copy of your main server and use it as a test verrsion you could test various configurations.