This pull request introduces the capability for the DefaultServer to run in a multithreaded cluster mode, enhancing its performance and scalability. The key changes involve adding cluster and OS modules, updating the server properties to include a multithreaded option, and modifying the server's start method to support clustering.
src/common/server/DefaultServer.ts: Added a multithreaded property to the DefaultServerProps type and the DefaultServer class to allow configuration of the server's multithreaded mode. [1][2]
src/common/server/DefaultServer.ts: Modified the start method to fork worker processes based on the number of CPUs when multithreaded is enabled, and to handle worker exits by respawning new workers. [1][2]
Example usage:
src/examples/cluster/index.ts: Added a new example demonstrating how to configure and start a DefaultServer in cluster mode, including setting up DNS over UDP, TCP, and HTTP networks, and using a custom handler to log requests.
This pull request introduces the capability for the
DefaultServer
to run in a multithreaded cluster mode, enhancing its performance and scalability. The key changes involve adding cluster and OS modules, updating the server properties to include a multithreaded option, and modifying the server's start method to support clustering.Enhancements to
DefaultServer
:src/common/server/DefaultServer.ts
: Imported thecluster
andos
modules to enable cluster mode functionality.src/common/server/DefaultServer.ts
: Added amultithreaded
property to theDefaultServerProps
type and theDefaultServer
class to allow configuration of the server's multithreaded mode. [1] [2]src/common/server/DefaultServer.ts
: Modified thestart
method to fork worker processes based on the number of CPUs whenmultithreaded
is enabled, and to handle worker exits by respawning new workers. [1] [2]Example usage:
src/examples/cluster/index.ts
: Added a new example demonstrating how to configure and start aDefaultServer
in cluster mode, including setting up DNS over UDP, TCP, and HTTP networks, and using a custom handler to log requests.