Is having more CPU cores a better thing for running a web server?

570

Solution 1

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.

Solution 2

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.

Solution 3

Yes.

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.

Share:
570

Related videos on Youtube

LofEra
Author by

LofEra

Updated on September 18, 2022

Comments

  • LofEra
    LofEra over 1 year

    I can read/write an external sdram using fmc in stm32f429. But working with address and read/write functions is not proper for my purpose. I want to introduce external sdram as if internal sram is clearly extended and whenever I define a big variable it is projected to external sdram automatically.

    I checked stm32f4 cubemx repository examples (SDRAM+DATAMEMORY) and searched a lot but it seems this is not straightforward.

    Following these steps based on what I found, I get hardfault after system_init.

    1. Defining external sdram address and size in the linker (off-chip ram)

    2. Adding some code in startup_stm32f420xx.s

    3. Defining DATA_IN_ExtSDRAM for initializing sdram before main function

    4. Enabling system clock before main function

    My external sdram is connected to SDRAM1 in stm32f429.

    What is the correct procedure? Is SystemInit_ExtMemCtl() function implemented correctly? Is any modification needed? Is enabling clock before main function and after system_init needed?

    Can anyone tell what is the correct code step by step?

    Thanks in advance.