What to avoid for performance reasons in multithreaded code?

后端 未结 12 2451
执笔经年
执笔经年 2021-02-09 10:45

I\'m currently reviewing/refactoring a multithreaded application which is supposed to be multithreaded in order to be able to use all the available cores and theoretically deliv

12条回答
  •  一向
    一向 (楼主)
    2021-02-09 11:37

    I recommend looking into running multiple processes rather than multiple threads within the same process, if it is a server application.

    The benefit of dividing the work between several processes on one machine is that it is easy to increase the number of servers when more performance is needed than a single server can deliver.

    You also reduce the risks involved with complex multithreaded applications where deadlocks, bottlenecks etc reduce the total performance.

    There are commercial frameworks that simplifies server software development when it comes to load balancing and distributed queue processing, but developing your own load sharing infrastructure is not that complicated compared with what you will encounter in general in a multi-threaded application.

提交回复
热议问题