0

I have nginx web server running newest WordPress and DB server running MySQL 5.6 There is around 90-100ms latency(round-trip delay) between those 2 servers.

The problem is that It takes about 5000 ms to get response from my web-server if I access DB remotely.(The connection is encrypted by SSL)

In comparison it takes about 200 ms if I access MySQL locally(web-server & MySQL installed on one single machine).

1. Why is that ? Is it because WP has multiple MySQL queries per page and waits for each and every one to complete ? Therefore it adds up : 100+100+100+100..=5000ms ?

2. Can WP be modified to request from MySQL asynchronously, in order to reduce waiting time for request to be successful?

Thank you. :)

1

Yes

90-100ms round trip + time to prepare SQL statement + time to execute statement + time to send results back multiplied by the number of times you need to query the database.

Sure the connection may stay open but it's an inherently expensive thing to do.

Considering that some setups can respond in full in less than 100ms never mind the database connection, you should look into co-locating your database and your server, if not on to the same machine but somewhere very very close.

WordPress specific things that may help include:

  • Object caches
  • Database query caching
  • fewer SQL queries
  • Use of transients to store the results of expensive operations

You can see what SQL queries are made and slow queries using tools such as the query monitor plugin

| improve this answer | |
  • Thank you, 1. "Considering that some setups can respond in full in less than 100ms never mind the database connection" How ? 2. Suppose you want to run WP on multiple geographical locations. What would you do ? Install DB server in each location and replicate between databases ? (Replication introduces new problem of data consistency) 3. Is there any other out-of-box web app similar to WP that can work with such latency ? (It does not have to be php+mysql based, even mongo+ruby) – no6 Mar 31 '14 at 22:43
  • 1
    In this particular scenario, a fast server in the US would be faster worldwide than what you currently have, aside form exceptions such as China. Switching CMS isn't going to make the SQL query latency vanish if you want fast loading times. Continuing down this avenue leads to server related questions, and that would be off topic on this site. I suggest you find a good Server person – Tom J Nowell Mar 31 '14 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.