3 ms·
Concurrency question: Is their a good rule of thumb for this? In a web app, how much concurrency should one pursue? If a lot, one user can potentially hog al
by jgalt212 9y ago
Concurrency question:
Is their a good rule of thumb for this? In a web app, how much concurrency should one pursue? If a lot, one user can potentially hog all the machine's cores while computing a view function. If a little/zero, then the server is computing view functions slower than it could if it used more then one core or thread per page view.
- keymone 9y agofor a web apps concurrency is usually abstracted away into the database. concurrency within the web worker is usually boiled down to parallel access to separate blocking resources that don't interfere with each other. it's quite rare to see web worker sharing some state between requests (because as soon as you hit multiple workers you need to care about session stickiness, not to mention the fact that state itself becomes sharded, so not very useful for most purposes) or request having to do enough heavy lifting to require parallelisation. it's a capacity planning issue which is somewhat related to how you parallelize the work but in the end, roughly `work per request W * number of requests N must be <= worker capacity C * number of workers M` or you will have a growing backlog. i imagine sync vs async resource access affects request timing variance more than it affects the median when the system is saturated but that depends on how resources respond to contention. so to answer your question - there is no general rule, every system has it's own scaling characteristics, but simpler system is better than complicated one so start with sequential access and measure a lot as you change it.
- jgalt212 9y agomakes sense. given how much folks talk about concurrency you'd think it would be at top of mind from the beginning of a project.