Skip to content

Is the framework multi threaded

kytooooo edited this page May 20, 2020 · 5 revisions

Is the framework multi-threaded?

NF uses multi-process with a single business thread rather than using multiple threads in one process.

In general, multi-threaded applications automatically share memory among threads. A pointer to a block of memory is automatically accessible to all threads. This can improve performance especially we handle so many user's requests concurrently, but it requires you to think a lot about locking and mutual exclusion to prevent threads from corrupting memory, it's dangerous when developing a big project.

In contrast, multi-process applications run in isolated address spaces and can modify memory without locking. So it's easy to maintain and the code can be read clean.

In NF's world, the business logic will run with a single-threaded style. As a result, we can write our business without thinking a lot for thread-lock to meet the highest performance and, it's a thing that reduces your mental burden.

In NF's world, we commend the developer using a single-threaded style but running all our business with multi-process which to void the single point of failure and to enhance the load when meeting too many users suddenly.

In addition, if developers want to process some heavy tasks which might block the main thread, NF provides the actor model to deal with this situation (Actor runs with the background threads).

About how to scale your game server please read the document Scaling-Workflow and the document Load-Balancing-Workflow