Slow SQL connection over sea

依然范特西╮ 提交于 2019-12-11 19:23:35

问题


This is what we have know: web server in the UK + SQL SERVER in the UK Because we can't make live replication of the database we come up this solution for the US: web server in the US + talk with the SQL SERVER in the UK.

And we see a strange result, we got a slow connection of the page, it's more slow from making proxy from the US to the UK and we don't understand why.

The logic said to us that the sql data is smaller then the proxy (of all the data in the page).

Do you have any ideas?


回答1:


If you want your SQL database to be that far away from your server, you need to seriously think about reducing the number of sequential queries used.

If your round-trip ping is 0.2ms to the MySQL server, and you make a query, this waits for round-trip communication. If you make 5 round-trip queries sequentially (that is, you wait for the first query to end before starting the second), it will take 0.2ms * 5 = 1ms.

Adding 1ms extra latency is no big deal. You probably won't notice.

If your database server is located outside the same datacenter, you'll probably get at least 20ms latency to the database. Five queries in a row would then take 100ms. Still not that bad.

If you're located across the ocean from your datacenter, you're probably talking 100-200ms latency. Five sequential queries would then take as long as a full second to return.

If you use 20-30 queries throughout the backend, it could take 10+ seconds to load your page.


Solutions?

  1. Put your database server in the same datacenter as your web server. Unless you can do all queries in parallel, or reduce the system to a single query per page, it's actually faster to have your webserver in the UK than to separate the web server and database server by an ocean.
  2. Greatly reduce the number of queries.
  3. Cache.


来源:https://stackoverflow.com/questions/10353083/slow-sql-connection-over-sea

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!