Hacker News new | ask | show | jobs
by pron 3560 days ago
> I think the first thing people should be taught about concurrency... is when not to use it.

Concurrency is usually not a feature of the algorithm but a feature of the problem domain. If you have many requests coming in at the same time, all competing for a limited amount of computational resources -- you have concurrency.

How you handle it is a different matter. You can decide to handle the requests one by one, but then, by Little's law, your throughput would be very low, and your server will crash if the rate of requests is over some small limit (which depends on the time it takes to service each request).

1 comments

No. If the problem is computational resources, performance can't be increased by mere concurrency (while even completely deterministic STM-style parallelism would help).

Concurrency improves performance when a process accesses both the same computational resource and some other high-latency sharable resource.

What is your "no" referring to? I totally agree with you. When I said "computational resource" I wasn't referring necessarily to CPU, let alone on the same machine, but resources of any kind. When one request is blocked, say, waiting for the DB (a computational resource), another can do some computation.