Discussion on whether the game server is multithreaded or single threaded

Source: Internet
Author: User

A good discussion of how to do a single thread for a game server or a multithreaded one recently
A classmate asked: The server logic full single-threaded model, in order to avoid querying offline player data caused by blocking, in addition to starting the full load of servers There is a better way?
Classmate B: Single-threaded logical models are also common. Logic itself is not prone to problems.
IO has to be all out.
Classmate B: Loads an event with an asynchronous load. After the data load is complete. And then re-queue the tasks into single-threaded task queues.
Classmate C: All kinds of active NPCs will disappear from the scene. Fighting threads and scene threads are inseparable
Classmate C: Scenario threads depend on the result of the battle
Classmate C: The result of the battle will affect the dynamic display of the NPC in the scene.
Classmate C: Then there's the deal, or the same online instant trading as the end tour.
Classmate C: Easy to brush items with multithreading
Classmate C: Easy to brush items with multithreading
Classmate C: The first thing I thought about was trading the items on a third-party thread, but if the player is halfway down or off the line or in various states, you have to return the item to the player.
Classmate C: But during this time the player may also be able to operate the backpack
Classmate D: The thing that was traded when it was traded was locked.
Classmate C: What do you mean by the idea of being locked up, is it impossible to do anything else?
Classmate E: You can trade without a lock. Do thread queuing
Classmate B:Our previous deal was exactly the same as Wow.
Put it on. Cannot move or discard in the backpack before the trade succeeds/fails
The player then clicks on the move and cancels the entire transaction immediately.
Classmate E: Cancel and let him get into the thread line.
Classmate B: Roll back no need to think so complicated
Can be designed to be a copy operation before the transaction succeeds
A trading container is used to store these temporary objects and States in the trading process.
Classmate F: Interactions involving multiple players are either locked or thrown into their own threading, and then callbacks are used.
For example, I buy your things, after I have deducted money, send a request to your thread deduction items, deduct the results and then back to my side. decided to fail to return the money to me, or to succeed in adding items to me.
This efficiency is the highest without locking.
Classmate C: I said the deal wasn't a stall.
Classmate B: This architecture is going to kill the programmer, and after that, the maintenance period is gone.
Classmate M: How do you differentiate between a single thread or a multithreaded
If you want to change a single thread, you don't have to.
Classmate B: Receive request multithreading
Processing a single thread after logically splitting to a different queue
Some specific scenarios, activities, and then single thread
All in all, a single thread that receives multi-threading logic, occasionally with multiple threads, maintains the lock itself and uses Orderedthreadpoolexecutor


Discussion on whether the game server is multithreaded or single threaded

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.