简体   繁体   中英

relation between request processing time and no of requests per second

My PHP script takes approx 7 secs to run since it fetches and prcess data from various sources in the web. How is this associated with the number of requests I can process per second?

It depends on what resources your script uses.

Basically, when you run out of CPU, disk I/O, memory on your script's server, or on your database server, or on any of the servers that you fetch data from, or hit third party API request limits, the game is over.

This generally has to do with concurrent requests rather than requests per second - how many requests can, at the same time, access the resources they require from the pool available to all requests. This is actually a lot more complicated in real life, since requests access different resources at different parts of their lifecycle, and also you will generally handle requests for different scripts on the same server, each with a different mix of resource requirements.

Long-running requests have an interesting interaction with requests per second. Usually, requests will take, say, 200ms. If you can handle 50 concurrent requests, that means you could handle something like 250 requests per second. Assuming you can only handle 50 concurrent requests, you can only handle 7 requests per second.

In the first second, you will have 7 running scripts. In the second, 14. Up to 49 in the seventh. Then, in the eighth, 7 will free up due to completion, and 7 will be added from new requests.

You may run into Apache configuration issues way before you run into actual resource usage issues - you will need to up the number of servers/workers because you have a somewhat non-standard use-case (ie, most requests are handled in less than a second). Depending on how complicated your processing is, you may be able to handle several hundred concurrent scripts if most of the time they are doing network I/O.

Benchmarking and other performance analysis is the only way to get more accurate information about requests per second and/or concurrent connections.

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