简体   繁体   中英

Possibilities that may cause delay to MySQL insert queries

The system I have is made out of 3 parts: CMS / Tablet (APP) / MySQL database. The CMS has an API that handles data coming from the APP and saves it into the database so it appears on the CMS.

The problem : the APP sends around 100 entry requests (json) to the API (loop). Then the API reads each requests and sends over 10 insert queries to the database for each request.

Unfortunately, only half of these insert queries go through and the rest fail. But when I send 1 or 2 requests the inserts take few seconds to go through but eventually works fine.

Please can you help me point out the possibilities that may cause the delay to MySQL insert queries?

It sounds to me like your app is sending a whole lot of requests to your web endpoint without waiting for them to complete or checking their return status.

In this case, the web server running your php program will enqueue the requests until its queue fills up, and then reject them. You'll never know about enqueuing or rejection because you don't wait.

If the inserts for one request take three seconds, it should take 300 seconds (five minutes) for 100 requests. Your app should take that long to finish all the requests. If it doesn't take that long, it's probably not waiting for status.

It's clear that a five-minute wait is unpleasantly long for a typical mobile app. But that is a different problem. You should solve it after you have solved your lost-request problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM