質問

I have a few servers stateside, Django + MySQL. It all works fine but when I set up a server in Asia I faced a very strange problem. Basically, migrate --list or shell run fine, despite a small lag. But when I try to load some pages that use the DB extensively I get 502 and a uWSGI worker dies. After I increased the timeout value on nGinx the pages started to load 40 seconds after the request. During these 40 seconds, the browser is just stuck at connecting to .... After about 40 seconds, the page renders just fine and the process is quite snappy as it should be.

I kinda figured out this may be a lag, since there is data transfer involved, apart from the queries. But, when pinging the database host, there is almost no delay. When I inspect MySQL connections, the Asia's server connection sleeps the whole 40 seconds, and then additional connections just appear out of nowhere and the page loads.

Server configuration is exactly the same. I am wondering if it's indeed the database location or I need to modify the configs.

But when I run runserver the effect is the same. So, I doubt there is something wrong with the way nGinx or uWSGI are set up.

役に立ちましたか?

解決

This was the MySQL lag. After implementing the replication (circular in my case) all servers work flawlessly and MySQL replication is really fast!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top