search

Home  >  Q&A  >  body text

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?

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.

滿天的星座滿天的星座2785 days ago781

reply all(4)I'll reply

  • 为情所困

    为情所困2017-06-10 09:49:32

    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

    reply
    0
  • 代言

    代言2017-06-10 09:49:32

    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

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-10 09:49:32

    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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-10 09:49:32

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

    reply
    0
  • Cancelreply