3 ms·
> So think about the system your code is running in, if things are getting parallelized at a higher level, it may not do any good to do it again at a lower leve
by merb 10y ago
> So think about the system your code is running in, if things are getting parallelized at a higher level, it may not do any good to do it again at a lower level. Instead, focus on algorithms that run as efficiently as possible on a single core.
Generally this is a extremly bad advice. Especially with:
> What you forgot was that the web server was already parallelizing things at a higher level
Apache parallized like that. and it was bad.
Nginx then introduced a eventloop, which was way better. however your application still needs to deal with it. i.e. if one request is blocking (taking too much time) your nginx will block, too. if that happens on all worker threads your website will be extremly slow.
A EventLoop mechanism always means that your stuff should be non-blocking and that is hard. this is especially hard when dealing with external resources, i.e databases, external services, caches, file io. when you just say "well my webserver will handle that" you will be in a really really bad shape.
- deleted 10y ago[deleted]
- jackmott 10y ago> Nginx then introduced a eventloop, which was way better. >A EventLoop mechanism always means that your stuff should be non-blocking and that is hard. hmm ;) So you are saying you need to think about the system your code is running in? Even an Event Loop server, if CPU utilization is sufficiently highly, paralellizing a function can be counter productive due to overhead and cache thrashing.
- merb 10y ago> if CPU utilization is sufficiently highly that won't be the case in a EventLoop system, it could be the case if you just have too less hardware. But than even your "non paralized" code will fail.