3 ms·
Probably true. But it depends. Let's say you've got 5 queries that take 1 second each.. There's a potential 5x speedup if you can run them in parallel. I think
by dhotson 16y ago
Probably true. But it depends. Let's say you've got 5 queries that take 1 second each.. There's a potential 5x speedup if you can run them in parallel.
I think some basic concurrency support in PHP (such as Futures) would have a pretty huge benefit. The other alternative is to have async APIs for libraries like mysql.
You could argue that anything that is taking too long that it needs parellelizing is probably a candidate for a background queue + frontend polling (or similar).
- atomical 16y agoIt still doesn't make sense to me. I can either use my time to fix the queries or use my time to play around with this disaster waiting to happen.
- dhotson 16y agoIt's not just db queries though.. it's also things like 3rd party API calls (S3 for example). Basically anything where you're blocked waiting for a response you could be busy doing something else. Synchronous APIs are kind of wasteful in a lot of cases. Node.js does a good job of this by using async APIs. It's a tradeoff. But the extra complexity can be worth it if it means your pages load 2x faster.