javascript - The api interface only takes 30ms to run locally, and it takes at least five or six seconds to put it online. What's going on?
滿天的星座
滿天的星座 2017-06-10 09:47:32
0
4
766

Written an interface, the calculation amount is slightly larger, the data is cached data stored using Thinkphp's f method, there is no access to the database, why is the running speed only about 30ms during local testing, and it is the least when put on the server It takes about 5 seconds. Why is this? If you want to change where to start? My current local testing is very fast and I don’t know how to optimize it.

滿天的星座
滿天的星座

reply all(4)
为情所困

There is a problem when using file cache. There may be too much content in the file, causing problems when reading it. It is recommended to pull the cache file locally for testing and analysis. You can also clear the file cache regularly to reduce the increasing content of cached files

代言

xdebug or xhprof can analyze the bottlenecks of your code. . . The simplest way is to put time tags on key locations to see which code segment takes too long to execute

扔个三星炸死你

The online server should be very local and have different aspects: 1. The online server needs to go through the network and you can test a network, 2. The hardware resources of the online server
3. The online server may be running multiple applications, consuming server resources. 4. Application problems, consider whether the application accumulates a large amount of data in online services, resulting in increased data processing time

伊谢尔伦

Solved, it won’t work after changing the server. I don’t know why this happens...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template