开发者

Slow mysql connection to remote DB

Here's my scenario: I have a LAMP server hosted through Amazon AWS that is hosted in the US East region. That web server connects to a local mysql DB and everything runs quickly and smoothly. I recently installed Apache on my computer so I can develop locally and set it up to connect to the DB on the live server instead of setting up a database locally.

The problem is, the requests from my local machine to the DB server are slow. I tested 5 queries selecting a limit of 1, 10, 100, 1000, and 10000 from a random table. Here are my results:

Production server connecting locally:

Total time : 0.1961 sec开发者_StackOverflow社区onds
Connection : 0.069 seconds
Query Limit 1 : 0.0001 seconds
Query Limit 10 : 0.0001 seconds
Query Limit 100 : 0.0003 seconds
Query Limit 1000 : 0.002 seconds
Query Limit 10000 : 0.1246 seconds

My comp connecting remotely:

Total time : 8.2012 seconds
Connection : 0.813 seconds
Query Limit 1 : 0.2133 seconds
Query Limit 10 : 0.3243 seconds
Query Limit 100 : 0.8209 seconds
Query Limit 1000 : 1.2209 seconds
Query Limit 10000 : 4.8088 seconds

Here are my ping results to said server:

Reply from xx.xx.xx.xxx: bytes=32 time=117ms TTL=42
Reply from xx.xx.xx.xxx: bytes=32 time=120ms TTL=42
Reply from xx.xx.xx.xxx: bytes=32 time=126ms TTL=42
Reply from xx.xx.xx.xxx: bytes=32 time=116ms TTL=42

Ping statistics for xx.xx.xx.xxx:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 116ms, Maximum = 126ms, Average = 119ms

And here's the table description:

col1    mediumint(9)    unsigned NO    PRI    NULL    auto_increment
col2    varchar(128)             YES          NULL
col3    varchar(100)             NO    MUL    NULL  
col4    mediumtext               YES   MUL    NULL  
col5    tinyint(1)               YES   MUL    0 

I know about the skip_name_resolve mysql variable and have set it to ON, but I didn't see any improvements. Is this simply a latency/data transfer issue between my comp (US West Coast) to the DB server? Ideally I'd like to continue working with the remote db, but should I just work with a local copy of the DB instead?


I know this is an old question, but it's still probably relevant for some people. It turns out that this was simply a data transfer/latency issue. The latency from the queries on the local web server to the remote DB (across the country) were simply adding up. I decided to connect to a local DB for development and everything was much quicker.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜