I was reading about how User threads are mapped to kernel threads on Wikipedia. From this article I understand that FreeBSD uses the 1:1 (Kernel-level threading).

So each User thread created by the application is mapped to a Kernel thread. If I assume I'm building a web server that will handle each new request in a thread and I'm running on FreeBSD will increasing the number of cores improve the overall performance of the application?

I have read this question CPU Cores: The more the better?, but I want the scope of the answers to be influenced specifically by the 1:1 mapping between user and kernel threads.

  • 2
    More cores will help with more multi-processing. You'll need to investigate whether it would help your web server - it may not help if the server is limited by memory, disk, or components. – ernie Jan 27 '14 at 20:03

The short answer is yes.

The long answer is .... having more CPU core means having more processing power. In case of a PHP / Ruby / Python / etc. web application, it means more resources to handle simultaneous connections. Having more cores truly make the difference in case of a load heavy application.

My personal opinion is that in case of a choice between more processing power and more RAM, I choose more RAM in most cases. With RAM, you can reduce the bottleneck that is disk I/O.

By using caches systems such as PHP APC, Varnish, and MySQL tuning (table cache, query cache, etc...), you can greatly enhance your website performance without needing more CPU power to generate content.

If your website can be cached, make this choice. Just increasing number of CPU core is a losing choice for the long term.

| improve this answer | |


Modern web server software use a separate process or thread for each computer connecting to the server. In addition, backend software such as MySQL or PHP also run in separate processes or threads for each user it needs to service, so having more cores always helps.

Of course, in more intensive environments, disk performance, memory, or network bandwidth may end up becoming bottlenecks. More memory allows more read caching, which will reduce accesses to slow disk storage. As suggested by Biapy, if you're dealing with lots of requests per second, you should look into specialized caching software such as Varnish, which will greatly reduce system load.

| improve this answer | |

As usual , the answer will be that it depends.

For instance, the nginx web server performs very well, even though it doesn't use threads. It uses an event-driven architecture instead. It can and does use several worker processes, so it can make use of multiple cores.

As you can see in the linked performance measurements, the threaded apache web server spawns more threads and uses more memory if the amount in concurrent connections increases. The amount of memory uses by nginx stays fairly constant. And in the amount of requests served per second, nginx beats apache by a wide margin.

So threads aren't always the best solution.

Performance also depends on where your data resides. If it is parked on a harddisk, access is going to be slow compared to when it is in RAM, which in turn is much slower than the processor cache. If you want to speed up your webserver, consider using an accellerator like varnish. Consider reading this article by the primary author of varnish about performance in web serving. The message here is that you should use the operating system's built-in chaching mechanisms and that you should not try to do the same job yourself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.